3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* $Id: messagebox.c,v 1.26 2004/07/22 02:32:53 navaraf Exp $
21 * PROJECT: ReactOS user32.dll
22 * FILE: lib/user32/windows/messagebox.c
24 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
25 * Thomas Weidenmueller (w3seek@users.sourceforge.net)
27 * 2003/07/28 Added some NT features
28 * 2003/07/27 Code ported from wine
29 * 09-05-2001 CSH Created
32 /* INCLUDES ******************************************************************/
38 #define NTOS_MODE_USER
45 //typedef UINT *LPUINT;
48 /* DEFINES *******************************************************************/
50 #define MSGBOX_IDICON (1088)
51 #define MSGBOX_IDTEXT (100)
53 #define IDI_HANDA MAKEINTRESOURCEA(32513)
54 #define IDI_HANDW MAKEINTRESOURCEW(32513)
55 #define IDI_QUESTIONA MAKEINTRESOURCEA(32514)
56 #define IDI_QUESTIONW MAKEINTRESOURCEW(32514)
57 #define IDI_EXCLAMATIONA MAKEINTRESOURCEA(32515)
58 #define IDI_EXCLAMATIONW MAKEINTRESOURCEW(32515)
59 #define IDI_ASTERISKA MAKEINTRESOURCEA(32516)
60 #define IDI_ASTERISKW MAKEINTRESOURCEW(32516)
61 #define IDI_WINLOGOA MAKEINTRESOURCEA(32517)
62 #define IDI_WINLOGOW MAKEINTRESOURCEW(32517)
65 #define MB_TYPEMASK 0x0000000F
68 #define MB_ICONMASK 0x000000F0
71 #define MB_DEFMASK 0x00000F00
77 #define MSGBOXEX_SPACING (16)
78 #define MSGBOXEX_BUTTONSPACING (6)
79 #define MSGBOXEX_MARGIN (12)
80 #define MSGBOXEX_MAXBTNSTR (32)
81 #define MSGBOXEX_MAXBTNS (4)
83 typedef struct _MSGBOXINFO
{
87 MSGBOXCALLBACK Callback
;
93 } MSGBOXINFO
, *PMSGBOXINFO
;
95 /* INTERNAL FUNCTIONS ********************************************************/
97 static inline unsigned int strlenW( const WCHAR
*str
)
104 static INT_PTR CALLBACK
MessageBoxProc( HWND hwnd
, UINT message
,
105 WPARAM wParam
, LPARAM lParam
)
114 mbi
= (PMSGBOXINFO
)lParam
;
115 if(!GetPropW(hwnd
, L
"ROS_MSGBOX"))
117 SetPropW(hwnd
, L
"ROS_MSGBOX", (HANDLE
)lParam
);
119 SendDlgItemMessageW(hwnd
, MSGBOX_IDICON
, STM_SETICON
, (WPARAM
)mbi
->Icon
, 0);
120 SetWindowContextHelpId(hwnd
, mbi
->ContextHelpId
);
122 /* set control fonts */
123 SendDlgItemMessageW(hwnd
, MSGBOX_IDTEXT
, WM_SETFONT
, (WPARAM
)mbi
->Font
, 0);
124 for(i
= 0; i
< mbi
->nButtons
; i
++)
126 SendDlgItemMessageW(hwnd
, mbi
->Btns
[i
], WM_SETFONT
, (WPARAM
)mbi
->Font
, 0);
128 switch(mbi
->Style
& MB_TYPEMASK
)
130 case MB_ABORTRETRYIGNORE
:
132 RemoveMenu(GetSystemMenu(hwnd
, FALSE
), SC_CLOSE
, MF_BYCOMMAND
);
135 SetFocus(GetDlgItem(hwnd
, mbi
->DefBtn
));
136 if(mbi
->Timeout
&& (mbi
->Timeout
!= (UINT
)-1))
137 SetTimer(hwnd
, 0, mbi
->Timeout
, NULL
);
142 switch (LOWORD(wParam
))
153 EndDialog(hwnd
, wParam
);
156 /* send WM_HELP message to messagebox window */
157 hi
.cbSize
= sizeof(HELPINFO
);
158 hi
.iContextType
= HELPINFO_WINDOW
;
159 hi
.iCtrlId
= LOWORD(wParam
);
160 hi
.hItemHandle
= (HANDLE
)lParam
;
162 GetCursorPos(&hi
.MousePos
);
163 SendMessageW(hwnd
, WM_HELP
, 0, (LPARAM
)&hi
);
169 mbi
= (PMSGBOXINFO
)GetPropW(hwnd
, L
"ROS_MSGBOX");
172 memcpy(&hi
, (void *)lParam
, sizeof(hi
));
173 hi
.dwContextId
= GetWindowContextHelpId(hwnd
);
179 owner
= GetWindow(hwnd
, GW_OWNER
);
181 SendMessageW(GetWindow(hwnd
, GW_OWNER
), WM_HELP
, 0, (LPARAM
)&hi
);
186 mbi
= (PMSGBOXINFO
)GetPropW(hwnd
, L
"ROS_MSGBOX");
189 switch(mbi
->Style
& MB_TYPEMASK
)
191 case MB_ABORTRETRYIGNORE
:
195 EndDialog(hwnd
, IDCANCEL
);
201 EndDialog(hwnd
, 32000);
208 #define SAFETY_MARGIN 32 /* Extra number of bytes to allocate in case we counted wrong */
210 MessageBoxTimeoutIndirectW(
211 CONST MSGBOXPARAMS
*lpMsgBoxParams
, UINT Timeout
)
214 DLGITEMTEMPLATE
*iico
, *itxt
;
215 NONCLIENTMETRICSW nclm
;
220 LPWSTR caption
, text
;
224 int bufsize
, ret
, caplen
, textlen
, btnlen
, i
, btnleft
, btntop
, lmargin
, nButtons
= 0;
225 LONG Buttons
[MSGBOXEX_MAXBTNS
];
226 WCHAR ButtonText
[MSGBOXEX_MAXBTNS
][MSGBOXEX_MAXBTNSTR
];
227 DLGITEMTEMPLATE
*ibtn
[MSGBOXEX_MAXBTNS
];
228 RECT btnrect
, txtrect
, rc
;
232 DWORD units
= GetDialogBaseUnits();
234 hUser32
= GetModuleHandleW(L
"USER32");
236 if(!lpMsgBoxParams
->lpszCaption
|| !HIWORD((LPWSTR
)lpMsgBoxParams
->lpszCaption
))
238 LoadStringW(hUser32
, IDS_ERROR
, &capbuf
[0], 32);
239 caption
= &capbuf
[0];
242 caption
= (LPWSTR
)lpMsgBoxParams
->lpszCaption
;
244 if(!lpMsgBoxParams
->lpszText
|| !HIWORD((LPWSTR
)lpMsgBoxParams
->lpszText
))
247 text
= (LPWSTR
)lpMsgBoxParams
->lpszText
;
249 caplen
= strlenW(caption
);
250 textlen
= strlenW(text
);
252 /* Create selected buttons */
253 switch(lpMsgBoxParams
->dwStyle
& MB_TYPEMASK
)
257 Buttons
[1] = IDCANCEL
;
260 case MB_CANCELTRYCONTINUE
:
261 Buttons
[0] = IDCANCEL
;
262 Buttons
[1] = IDTRYAGAIN
;
263 Buttons
[2] = IDCONTINUE
;
266 case MB_ABORTRETRYIGNORE
:
267 Buttons
[0] = IDABORT
;
268 Buttons
[1] = IDRETRY
;
269 Buttons
[2] = IDIGNORE
;
280 Buttons
[2] = IDCANCEL
;
284 Buttons
[0] = IDRETRY
;
285 Buttons
[1] = IDCANCEL
;
295 /* Create Help button */
296 if(lpMsgBoxParams
->dwStyle
& MB_HELP
)
297 Buttons
[nButtons
++] = IDHELP
;
299 switch(lpMsgBoxParams
->dwStyle
& MB_ICONMASK
)
301 case MB_ICONEXCLAMATION
:
302 Icon
= LoadIconW(0, IDI_EXCLAMATIONW
);
303 MessageBeep(MB_ICONEXCLAMATION
);
305 case MB_ICONQUESTION
:
306 Icon
= LoadIconW(0, IDI_QUESTIONW
);
307 MessageBeep(MB_ICONQUESTION
);
309 case MB_ICONASTERISK
:
310 Icon
= LoadIconW(0, IDI_ASTERISKW
);
311 MessageBeep(MB_ICONASTERISK
);
314 Icon
= LoadIconW(0, IDI_HANDW
);
315 MessageBeep(MB_ICONHAND
);
318 Icon
= LoadIconW(lpMsgBoxParams
->hInstance
, (LPCWSTR
)lpMsgBoxParams
->lpszIcon
);
322 /* By default, Windows 95/98/NT does not associate an icon to message boxes.
323 * So ReactOS should do the same.
331 bufsize
= sizeof(DLGTEMPLATE
) +
332 2 * sizeof(WORD
) + /* menu and class */
333 (caplen
+ 1) * sizeof(WCHAR
); /* title */
338 bufsize
= (bufsize
+ 3) & ~3;
339 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
345 bufsize
= (bufsize
+ 3) & ~3;
346 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
348 (textlen
+ 1) * sizeof(WCHAR
);
351 for(i
= 0; i
< nButtons
; i
++)
356 LoadStringW(hUser32
, IDS_OK
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
359 LoadStringW(hUser32
, IDS_CANCEL
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
362 LoadStringW(hUser32
, IDS_YES
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
365 LoadStringW(hUser32
, IDS_NO
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
368 LoadStringW(hUser32
, IDS_TRYAGAIN
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
371 LoadStringW(hUser32
, IDS_CONTINUE
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
374 LoadStringW(hUser32
, IDS_ABORT
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
377 LoadStringW(hUser32
, IDS_RETRY
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
380 LoadStringW(hUser32
, IDS_IGNORE
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
383 LoadStringW(hUser32
, IDS_HELP
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
386 ButtonText
[i
][0] = (WCHAR
)0;
390 /* Space for buttons */
391 bufsize
= (bufsize
+ 3) & ~3;
392 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
394 (wcslen(ButtonText
[i
]) + 1) * sizeof(WCHAR
);
397 buf
= RtlAllocateHeap(GetProcessHeap(), 0, bufsize
+ SAFETY_MARGIN
);
398 /* Just to be safe.... */
405 hDC
= CreateCompatibleDC(0);
407 nclm
.cbSize
= sizeof(nclm
);
408 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, sizeof(nclm
), &nclm
, 0);
409 hFont
= CreateFontIndirectW (&nclm
.lfMessageFont
);
411 tpl
= (DLGTEMPLATE
*)buf
;
413 tpl
->style
= WS_CAPTION
| WS_POPUP
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_SYSMENU
| DS_CENTER
| DS_MODALFRAME
| DS_NOIDLEMSG
;
414 tpl
->dwExtendedStyle
= WS_EX_DLGMODALFRAME
| WS_EX_WINDOWEDGE
| WS_EX_CONTROLPARENT
;
415 if(lpMsgBoxParams
->dwStyle
& MB_TOPMOST
)
416 tpl
->dwExtendedStyle
|= WS_EX_TOPMOST
;
417 if(lpMsgBoxParams
->dwStyle
& MB_RIGHT
)
418 tpl
->dwExtendedStyle
|= WS_EX_RIGHT
;
421 tpl
->cdit
= nButtons
+ (Icon
!= (HICON
)0) + 1;
423 dest
= (BYTE
*)(tpl
+ 1);
425 *(WORD
*)dest
= 0; /* no menu */
426 *(((WORD
*)dest
) + 1) = 0; /* use default window class */
427 dest
+= 2 * sizeof(WORD
);
428 memcpy(dest
, caption
, caplen
* sizeof(WCHAR
));
429 dest
+= caplen
* sizeof(WCHAR
);
430 *(WCHAR
*)dest
= L
'\0';
431 dest
+= sizeof(WCHAR
);
436 dest
= (BYTE
*)(((ULONG_PTR
)dest
+ 3) & ~3);
437 iico
= (DLGITEMTEMPLATE
*)dest
;
438 iico
->style
= WS_CHILD
| WS_VISIBLE
| SS_ICON
;
439 iico
->dwExtendedStyle
= 0;
440 iico
->id
= MSGBOX_IDICON
;
442 dest
+= sizeof(DLGITEMTEMPLATE
);
443 *(WORD
*)dest
= 0xFFFF;
444 dest
+= sizeof(WORD
);
445 *(WORD
*)dest
= 0x0082; /* static control */
446 dest
+= sizeof(WORD
);
447 *(WORD
*)dest
= 0xFFFF;
448 dest
+= sizeof(WORD
);
450 dest
+= sizeof(WCHAR
);
452 dest
+= sizeof(WORD
);
455 /* create static for text */
456 dest
= (BYTE
*)(((DWORD
)dest
+ 3) & ~3);
457 itxt
= (DLGITEMTEMPLATE
*)dest
;
458 itxt
->style
= WS_CHILD
| WS_VISIBLE
| SS_NOPREFIX
;
459 if(lpMsgBoxParams
->dwStyle
& MB_RIGHT
)
460 itxt
->style
|= SS_RIGHT
;
462 itxt
->style
|= SS_LEFT
;
463 itxt
->dwExtendedStyle
= 0;
464 itxt
->id
= MSGBOX_IDTEXT
;
465 dest
+= sizeof(DLGITEMTEMPLATE
);
466 *(WORD
*)dest
= 0xFFFF;
467 dest
+= sizeof(WORD
);
468 *(WORD
*)dest
= 0x0082; /* static control */
469 dest
+= sizeof(WORD
);
470 memcpy(dest
, text
, textlen
* sizeof(WCHAR
));
471 dest
+= textlen
* sizeof(WCHAR
);
473 dest
+= sizeof(WCHAR
);
475 dest
+= sizeof(WORD
);
480 btnrect
.left
= btnrect
.top
= 0;
481 for(i
= 0; i
< nButtons
; i
++)
483 dest
= (BYTE
*)(((DWORD
)dest
+ 3) & ~3);
484 ibtn
[i
] = (DLGITEMTEMPLATE
*)dest
;
485 ibtn
[i
]->style
= WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
;
486 if(!defbtn
&& (i
== ((lpMsgBoxParams
->dwStyle
& MB_DEFMASK
) >> 8)))
488 ibtn
[i
]->style
|= BS_DEFPUSHBUTTON
;
489 mbi
.DefBtn
= Buttons
[i
];
493 ibtn
[i
]->style
|= BS_PUSHBUTTON
;
494 ibtn
[i
]->dwExtendedStyle
= 0;
495 ibtn
[i
]->id
= Buttons
[i
];
496 dest
+= sizeof(DLGITEMTEMPLATE
);
497 *(WORD
*)dest
= 0xFFFF;
498 dest
+= sizeof(WORD
);
499 *(WORD
*)dest
= 0x0080; /* button control */
500 dest
+= sizeof(WORD
);
501 btnlen
= strlenW(ButtonText
[i
]);
502 memcpy(dest
, ButtonText
[i
], btnlen
* sizeof(WCHAR
));
503 dest
+= btnlen
* sizeof(WCHAR
);
505 dest
+= sizeof(WORD
);
507 dest
+= sizeof(WORD
);
508 SelectObject(hDC
, hFont
);
509 DrawTextW(hDC
, ButtonText
[i
], btnlen
, &btnrect
, DT_LEFT
| DT_SINGLELINE
| DT_CALCRECT
);
510 btnsize
.cx
= max(btnsize
.cx
, btnrect
.right
);
511 btnsize
.cy
= max(btnsize
.cy
, btnrect
.bottom
);
514 if ((ULONG_PTR
) dest
!= ((ULONG_PTR
) buf
+ (ULONG_PTR
) bufsize
))
516 DbgPrint("Tell GvG he can't count: bufsize is %lu, but should be %lu\n", bufsize
, (ULONG_PTR
) dest
- (ULONG_PTR
) buf
);
519 /* make first button the default button if no other is */
522 ibtn
[0]->style
&= ~BS_PUSHBUTTON
;
523 ibtn
[0]->style
|= BS_DEFPUSHBUTTON
;
524 mbi
.DefBtn
= Buttons
[0];
527 /* calculate position and size of controls */
528 txtrect
.right
= GetSystemMetrics(SM_CXSCREEN
) / 5 * 4;
530 txtrect
.right
-= GetSystemMetrics(SM_CXICON
) + MSGBOXEX_SPACING
;
531 txtrect
.top
= txtrect
.left
= txtrect
.bottom
= 0;
532 SelectObject(hDC
, hFont
);
533 DrawTextW(hDC
, text
, textlen
, &txtrect
, DT_LEFT
| DT_NOPREFIX
| DT_WORDBREAK
| DT_CALCRECT
);
536 /* calculate position and size of the icon */
537 rc
.left
= rc
.bottom
= rc
.right
= 0;
542 rc
.right
= GetSystemMetrics(SM_CXICON
);
543 rc
.bottom
= GetSystemMetrics(SM_CYICON
);
544 #ifdef MSGBOX_ICONVCENTER
545 rc
.top
= MSGBOXEX_MARGIN
+ (max(txtrect
.bottom
, rc
.bottom
) / 2) - (GetSystemMetrics(SM_CYICON
) / 2);
546 rc
.top
= max(MSGBOXEX_SPACING
, rc
.top
);
548 rc
.top
= MSGBOXEX_MARGIN
;
550 btnleft
= (nButtons
* (btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
)) - MSGBOXEX_BUTTONSPACING
;
551 if(btnleft
> txtrect
.right
+ rc
.right
+ MSGBOXEX_SPACING
)
553 #ifdef MSGBOX_TEXTHCENTER
554 lmargin
= MSGBOXEX_MARGIN
+ ((btnleft
- txtrect
.right
- rc
.right
- MSGBOXEX_SPACING
) / 2);
556 lmargin
= MSGBOXEX_MARGIN
;
558 btnleft
= MSGBOXEX_MARGIN
;
562 lmargin
= MSGBOXEX_MARGIN
;
563 btnleft
= MSGBOXEX_MARGIN
+ ((txtrect
.right
+ rc
.right
+ MSGBOXEX_SPACING
) / 2) - (btnleft
/ 2);
566 iico
->x
= (rc
.left
* 4) / LOWORD(units
);
567 iico
->y
= (rc
.top
* 8) / HIWORD(units
);
568 iico
->cx
= (rc
.right
* 4) / LOWORD(units
);
569 iico
->cy
= (rc
.bottom
* 8) / HIWORD(units
);
570 btntop
= rc
.top
+ rc
.bottom
+ MSGBOXEX_SPACING
;
571 rc
.left
+= rc
.right
+ MSGBOXEX_SPACING
;
575 btnleft
= (nButtons
* (btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
)) - MSGBOXEX_BUTTONSPACING
;
576 if(btnleft
> txtrect
.right
)
578 #ifdef MSGBOX_TEXTHCENTER
579 lmargin
= MSGBOXEX_MARGIN
+ ((btnleft
- txtrect
.right
) / 2);
581 lmargin
= MSGBOXEX_MARGIN
;
583 btnleft
= MSGBOXEX_MARGIN
;
587 lmargin
= MSGBOXEX_MARGIN
;
588 btnleft
= MSGBOXEX_MARGIN
+ (txtrect
.right
/ 2) - (btnleft
/ 2);
592 /* calculate position of the text */
593 rc
.top
= MSGBOXEX_MARGIN
+ (rc
.bottom
/ 2) - (txtrect
.bottom
/ 2);
594 rc
.top
= max(rc
.top
, MSGBOXEX_MARGIN
);
595 /* calculate position of the buttons */
596 btntop
= max(rc
.top
+ txtrect
.bottom
+ MSGBOXEX_SPACING
, btntop
);
597 for(i
= 0; i
< nButtons
; i
++)
599 ibtn
[i
]->x
= (btnleft
* 4) / LOWORD(units
);
600 ibtn
[i
]->y
= (btntop
* 8) / HIWORD(units
);
601 ibtn
[i
]->cx
= (btnsize
.cx
* 4) / LOWORD(units
);
602 ibtn
[i
]->cy
= (btnsize
.cy
* 8) / HIWORD(units
);
603 btnleft
+= btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
;
605 /* calculate size and position of the messagebox window */
606 btnleft
= max(btnleft
- MSGBOXEX_BUTTONSPACING
, rc
.left
+ txtrect
.right
);
607 btnleft
+= MSGBOXEX_MARGIN
;
608 btntop
+= btnsize
.cy
+ MSGBOXEX_MARGIN
;
609 /* set size and position of the message static */
610 itxt
->x
= (rc
.left
* 4) / LOWORD(units
);
611 itxt
->y
= (rc
.top
* 8) / HIWORD(units
);
612 itxt
->cx
= (((btnleft
- rc
.left
- MSGBOXEX_MARGIN
) * 4) / LOWORD(units
));
613 itxt
->cy
= ((txtrect
.bottom
* 8) / HIWORD(units
));
614 /* set size of the window */
615 tpl
->cx
= (btnleft
* 4) / LOWORD(units
);
616 tpl
->cy
= (btntop
* 8) / HIWORD(units
);
618 /* finally show the messagebox */
621 mbi
.ContextHelpId
= lpMsgBoxParams
->dwContextHelpId
;
622 mbi
.Callback
= lpMsgBoxParams
->lpfnMsgBoxCallback
;
623 mbi
.Style
= lpMsgBoxParams
->dwStyle
;
624 mbi
.nButtons
= nButtons
;
625 mbi
.Btns
= &Buttons
[0];
626 mbi
.Timeout
= Timeout
;
631 ret
= DialogBoxIndirectParamW(lpMsgBoxParams
->hInstance
, tpl
, lpMsgBoxParams
->hwndOwner
,
632 MessageBoxProc
, (LPARAM
)&mbi
);
637 RtlFreeHeap(GetProcessHeap(), 0, buf
);
641 /* FUNCTIONS *****************************************************************/
655 return MessageBoxExA(hWnd
, lpText
, lpCaption
, uType
, LANG_NEUTRAL
);
671 MSGBOXPARAMSA msgbox
;
673 msgbox
.cbSize
= sizeof(msgbox
);
674 msgbox
.hwndOwner
= hWnd
;
675 msgbox
.hInstance
= 0;
676 msgbox
.lpszText
= lpText
;
677 msgbox
.lpszCaption
= lpCaption
;
678 msgbox
.dwStyle
= uType
;
679 msgbox
.lpszIcon
= NULL
;
680 msgbox
.dwContextHelpId
= 0;
681 msgbox
.lpfnMsgBoxCallback
= NULL
;
682 msgbox
.dwLanguageId
= wLanguageId
;
684 return MessageBoxIndirectA(&msgbox
);
700 MSGBOXPARAMSW msgbox
;
702 msgbox
.cbSize
= sizeof(msgbox
);
703 msgbox
.hwndOwner
= hWnd
;
704 msgbox
.hInstance
= 0;
705 msgbox
.lpszText
= lpText
;
706 msgbox
.lpszCaption
= lpCaption
;
707 msgbox
.dwStyle
= uType
;
708 msgbox
.lpszIcon
= NULL
;
709 msgbox
.dwContextHelpId
= 0;
710 msgbox
.lpfnMsgBoxCallback
= NULL
;
711 msgbox
.dwLanguageId
= wLanguageId
;
713 return MessageBoxTimeoutIndirectW(&msgbox
, (UINT
)-1);
723 CONST MSGBOXPARAMSA
*lpMsgBoxParams
)
725 MSGBOXPARAMSW msgboxW
;
726 UNICODE_STRING textW
, captionW
, iconW
;
729 if (HIWORD((UINT
)lpMsgBoxParams
->lpszText
))
731 RtlCreateUnicodeStringFromAsciiz(&textW
, (PCSZ
)lpMsgBoxParams
->lpszText
);
733 * UNICODE_STRING objects are always allocated with an extra byte so you
734 * can null-term if you want
736 textW
.Buffer
[textW
.Length
/ sizeof(WCHAR
)] = L
'\0';
739 textW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszText
;
741 if (HIWORD((UINT
)lpMsgBoxParams
->lpszCaption
))
743 RtlCreateUnicodeStringFromAsciiz(&captionW
, (PCSZ
)lpMsgBoxParams
->lpszCaption
);
745 * UNICODE_STRING objects are always allocated with an extra byte so you
746 * can null-term if you want
748 captionW
.Buffer
[captionW
.Length
/ sizeof(WCHAR
)] = L
'\0';
751 captionW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszCaption
;
753 if (HIWORD((UINT
)lpMsgBoxParams
->lpszIcon
))
755 RtlCreateUnicodeStringFromAsciiz(&iconW
, (PCSZ
)lpMsgBoxParams
->lpszIcon
);
757 * UNICODE_STRING objects are always allocated with an extra byte so you
758 * can null-term if you want
760 iconW
.Buffer
[iconW
.Length
/ sizeof(WCHAR
)] = L
'\0';
763 iconW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszIcon
;
765 msgboxW
.cbSize
= sizeof(msgboxW
);
766 msgboxW
.hwndOwner
= lpMsgBoxParams
->hwndOwner
;
767 msgboxW
.hInstance
= lpMsgBoxParams
->hInstance
;
768 msgboxW
.lpszText
= textW
.Buffer
;
769 msgboxW
.lpszCaption
= captionW
.Buffer
;
770 msgboxW
.dwStyle
= lpMsgBoxParams
->dwStyle
;
771 msgboxW
.lpszIcon
= iconW
.Buffer
;
772 msgboxW
.dwContextHelpId
= lpMsgBoxParams
->dwContextHelpId
;
773 msgboxW
.lpfnMsgBoxCallback
= lpMsgBoxParams
->lpfnMsgBoxCallback
;
774 msgboxW
.dwLanguageId
= lpMsgBoxParams
->dwLanguageId
;
776 ret
= MessageBoxTimeoutIndirectW(&msgboxW
, (UINT
)-1);
778 if (HIWORD((UINT
)lpMsgBoxParams
->lpszText
))
779 RtlFreeUnicodeString(&textW
);
781 if (HIWORD((UINT
)lpMsgBoxParams
->lpszCaption
))
782 RtlFreeUnicodeString(&captionW
);
784 if (HIWORD((UINT
)lpMsgBoxParams
->lpszIcon
))
785 RtlFreeUnicodeString(&iconW
);
797 CONST MSGBOXPARAMSW
*lpMsgBoxParams
)
799 return MessageBoxTimeoutIndirectW(lpMsgBoxParams
, (UINT
)-1);
814 return MessageBoxExW(hWnd
, lpText
, lpCaption
, uType
, LANG_NEUTRAL
);
830 MSGBOXPARAMSW msgboxW
;
831 UNICODE_STRING textW
, captionW
;
834 if (HIWORD((UINT
)lpText
))
835 RtlCreateUnicodeStringFromAsciiz(&textW
, (PCSZ
)lpText
);
837 textW
.Buffer
= (LPWSTR
)lpText
;
839 if (HIWORD((UINT
)lpCaption
))
840 RtlCreateUnicodeStringFromAsciiz(&captionW
, (PCSZ
)lpCaption
);
842 captionW
.Buffer
= (LPWSTR
)lpCaption
;
844 msgboxW
.cbSize
= sizeof(msgboxW
);
845 msgboxW
.hwndOwner
= hWnd
;
846 msgboxW
.hInstance
= 0;
847 msgboxW
.lpszText
= textW
.Buffer
;
848 msgboxW
.lpszCaption
= captionW
.Buffer
;
849 msgboxW
.dwStyle
= uType
;
850 msgboxW
.lpszIcon
= NULL
;
851 msgboxW
.dwContextHelpId
= 0;
852 msgboxW
.lpfnMsgBoxCallback
= NULL
;
853 msgboxW
.dwLanguageId
= wLanguageId
;
855 ret
= MessageBoxTimeoutIndirectW(&msgboxW
, (UINT
)dwTime
);
857 if (HIWORD(textW
.Buffer
))
858 RtlFreeUnicodeString(&textW
);
860 if (HIWORD(captionW
.Buffer
))
861 RtlFreeUnicodeString(&captionW
);
879 MSGBOXPARAMSW msgbox
;
881 msgbox
.cbSize
= sizeof(msgbox
);
882 msgbox
.hwndOwner
= hWnd
;
883 msgbox
.hInstance
= 0;
884 msgbox
.lpszText
= lpText
;
885 msgbox
.lpszCaption
= lpCaption
;
886 msgbox
.dwStyle
= uType
;
887 msgbox
.lpszIcon
= NULL
;
888 msgbox
.dwContextHelpId
= 0;
889 msgbox
.lpfnMsgBoxCallback
= NULL
;
890 msgbox
.dwLanguageId
= wLanguageId
;
892 return MessageBoxTimeoutIndirectW(&msgbox
, (UINT
)dwTime
);
901 SoftModalMessageBox(DWORD Unknown0
)
913 MessageBeep(UINT uType
)
921 if(waveOutGetNumDevs() == 0)
922 return Beep(500, 100); // Beep through speaker
925 EventName
= L
"SystemDefault";
927 case MB_ICONASTERISK
:
928 EventName
= L
"SystemAsterisk";
930 case MB_ICONEXCLAMATION
:
931 EventName
= L
"SystemExclamation";
934 EventName
= L
"SystemHand";
936 case MB_ICONQUESTION
:
937 EventName
= L
"SystemQuestion";
941 return PlaySoundW((LPCWSTR
)EventName
, NULL
, SND_ALIAS
| SND_NOWAIT
| SND_NOSTOP
| SND_ASYNC
);
943 return Beep(500, 100); // Beep through speaker