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.30 2004/12/12 20:40:06 weiden 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 ******************************************************************/
44 /* DEFINES *******************************************************************/
46 #define MSGBOX_IDICON (1088)
47 #define MSGBOX_IDTEXT (100)
49 #define IDI_HANDA MAKEINTRESOURCEA(32513)
50 #define IDI_HANDW MAKEINTRESOURCEW(32513)
51 #define IDI_QUESTIONA MAKEINTRESOURCEA(32514)
52 #define IDI_QUESTIONW MAKEINTRESOURCEW(32514)
53 #define IDI_EXCLAMATIONA MAKEINTRESOURCEA(32515)
54 #define IDI_EXCLAMATIONW MAKEINTRESOURCEW(32515)
55 #define IDI_ASTERISKA MAKEINTRESOURCEA(32516)
56 #define IDI_ASTERISKW MAKEINTRESOURCEW(32516)
57 #define IDI_WINLOGOA MAKEINTRESOURCEA(32517)
58 #define IDI_WINLOGOW MAKEINTRESOURCEW(32517)
61 #define MB_TYPEMASK 0x0000000F
64 #define MB_ICONMASK 0x000000F0
67 #define MB_DEFMASK 0x00000F00
73 #define MSGBOXEX_SPACING (16)
74 #define MSGBOXEX_BUTTONSPACING (6)
75 #define MSGBOXEX_MARGIN (12)
76 #define MSGBOXEX_MAXBTNSTR (32)
77 #define MSGBOXEX_MAXBTNS (4)
79 typedef struct _MSGBOXINFO
{
83 MSGBOXCALLBACK Callback
;
89 } MSGBOXINFO
, *PMSGBOXINFO
;
91 /* INTERNAL FUNCTIONS ********************************************************/
93 static inline unsigned int strlenW( const WCHAR
*str
)
100 static INT_PTR CALLBACK
MessageBoxProc( HWND hwnd
, UINT message
,
101 WPARAM wParam
, LPARAM lParam
)
110 mbi
= (PMSGBOXINFO
)lParam
;
111 if(!GetPropW(hwnd
, L
"ROS_MSGBOX"))
113 SetPropW(hwnd
, L
"ROS_MSGBOX", (HANDLE
)lParam
);
115 SendDlgItemMessageW(hwnd
, MSGBOX_IDICON
, STM_SETICON
, (WPARAM
)mbi
->Icon
, 0);
116 SetWindowContextHelpId(hwnd
, mbi
->ContextHelpId
);
118 /* set control fonts */
119 SendDlgItemMessageW(hwnd
, MSGBOX_IDTEXT
, WM_SETFONT
, (WPARAM
)mbi
->Font
, 0);
120 for(i
= 0; i
< mbi
->nButtons
; i
++)
122 SendDlgItemMessageW(hwnd
, mbi
->Btns
[i
], WM_SETFONT
, (WPARAM
)mbi
->Font
, 0);
124 switch(mbi
->Style
& MB_TYPEMASK
)
126 case MB_ABORTRETRYIGNORE
:
128 RemoveMenu(GetSystemMenu(hwnd
, FALSE
), SC_CLOSE
, MF_BYCOMMAND
);
131 SetFocus(GetDlgItem(hwnd
, mbi
->DefBtn
));
132 if(mbi
->Timeout
&& (mbi
->Timeout
!= (UINT
)-1))
133 SetTimer(hwnd
, 0, mbi
->Timeout
, NULL
);
138 switch (LOWORD(wParam
))
149 EndDialog(hwnd
, wParam
);
152 /* send WM_HELP message to messagebox window */
153 hi
.cbSize
= sizeof(HELPINFO
);
154 hi
.iContextType
= HELPINFO_WINDOW
;
155 hi
.iCtrlId
= LOWORD(wParam
);
156 hi
.hItemHandle
= (HANDLE
)lParam
;
158 GetCursorPos(&hi
.MousePos
);
159 SendMessageW(hwnd
, WM_HELP
, 0, (LPARAM
)&hi
);
165 mbi
= (PMSGBOXINFO
)GetPropW(hwnd
, L
"ROS_MSGBOX");
168 memcpy(&hi
, (void *)lParam
, sizeof(hi
));
169 hi
.dwContextId
= GetWindowContextHelpId(hwnd
);
175 owner
= GetWindow(hwnd
, GW_OWNER
);
177 SendMessageW(GetWindow(hwnd
, GW_OWNER
), WM_HELP
, 0, (LPARAM
)&hi
);
182 mbi
= (PMSGBOXINFO
)GetPropW(hwnd
, L
"ROS_MSGBOX");
185 switch(mbi
->Style
& MB_TYPEMASK
)
187 case MB_ABORTRETRYIGNORE
:
191 EndDialog(hwnd
, IDCANCEL
);
197 EndDialog(hwnd
, 32000);
205 MessageBoxTimeoutIndirectW(
206 CONST MSGBOXPARAMSW
*lpMsgBoxParams
, UINT Timeout
)
209 DLGITEMTEMPLATE
*iico
, *itxt
;
210 NONCLIENTMETRICSW nclm
;
215 LPCWSTR caption
, text
;
219 int bufsize
, ret
, caplen
, textlen
, btnlen
, i
, btnleft
, btntop
, lmargin
, nButtons
= 0;
220 LONG Buttons
[MSGBOXEX_MAXBTNS
];
221 WCHAR ButtonText
[MSGBOXEX_MAXBTNS
][MSGBOXEX_MAXBTNSTR
];
222 DLGITEMTEMPLATE
*ibtn
[MSGBOXEX_MAXBTNS
];
223 RECT btnrect
, txtrect
, rc
;
227 DWORD units
= GetDialogBaseUnits();
229 hUser32
= GetModuleHandleW(L
"USER32");
231 if(!lpMsgBoxParams
->lpszCaption
|| !HIWORD((LPWSTR
)lpMsgBoxParams
->lpszCaption
))
233 LoadStringW(hUser32
, IDS_ERROR
, &capbuf
[0], 32);
234 caption
= &capbuf
[0];
237 caption
= (LPWSTR
)lpMsgBoxParams
->lpszCaption
;
239 if(!lpMsgBoxParams
->lpszText
|| !HIWORD(lpMsgBoxParams
->lpszText
))
242 text
= lpMsgBoxParams
->lpszText
;
244 caplen
= strlenW(caption
);
245 textlen
= strlenW(text
);
247 /* Create selected buttons */
248 switch(lpMsgBoxParams
->dwStyle
& MB_TYPEMASK
)
252 Buttons
[1] = IDCANCEL
;
255 case MB_CANCELTRYCONTINUE
:
256 Buttons
[0] = IDCANCEL
;
257 Buttons
[1] = IDTRYAGAIN
;
258 Buttons
[2] = IDCONTINUE
;
261 case MB_ABORTRETRYIGNORE
:
262 Buttons
[0] = IDABORT
;
263 Buttons
[1] = IDRETRY
;
264 Buttons
[2] = IDIGNORE
;
275 Buttons
[2] = IDCANCEL
;
279 Buttons
[0] = IDRETRY
;
280 Buttons
[1] = IDCANCEL
;
290 /* Create Help button */
291 if(lpMsgBoxParams
->dwStyle
& MB_HELP
)
292 Buttons
[nButtons
++] = IDHELP
;
294 switch(lpMsgBoxParams
->dwStyle
& MB_ICONMASK
)
296 case MB_ICONEXCLAMATION
:
297 Icon
= LoadIconW(0, IDI_EXCLAMATIONW
);
298 MessageBeep(MB_ICONEXCLAMATION
);
300 case MB_ICONQUESTION
:
301 Icon
= LoadIconW(0, IDI_QUESTIONW
);
302 MessageBeep(MB_ICONQUESTION
);
304 case MB_ICONASTERISK
:
305 Icon
= LoadIconW(0, IDI_ASTERISKW
);
306 MessageBeep(MB_ICONASTERISK
);
309 Icon
= LoadIconW(0, IDI_HANDW
);
310 MessageBeep(MB_ICONHAND
);
313 Icon
= LoadIconW(lpMsgBoxParams
->hInstance
, lpMsgBoxParams
->lpszIcon
);
317 /* By default, Windows 95/98/NT does not associate an icon to message boxes.
318 * So ReactOS should do the same.
326 bufsize
= sizeof(DLGTEMPLATE
) +
327 2 * sizeof(WORD
) + /* menu and class */
328 (caplen
+ 1) * sizeof(WCHAR
); /* title */
333 bufsize
= (bufsize
+ 3) & ~3;
334 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
340 bufsize
= (bufsize
+ 3) & ~3;
341 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
343 (textlen
+ 1) * sizeof(WCHAR
);
346 for(i
= 0; i
< nButtons
; i
++)
351 LoadStringW(hUser32
, IDS_OK
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
354 LoadStringW(hUser32
, IDS_CANCEL
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
357 LoadStringW(hUser32
, IDS_YES
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
360 LoadStringW(hUser32
, IDS_NO
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
363 LoadStringW(hUser32
, IDS_TRYAGAIN
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
366 LoadStringW(hUser32
, IDS_CONTINUE
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
369 LoadStringW(hUser32
, IDS_ABORT
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
372 LoadStringW(hUser32
, IDS_RETRY
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
375 LoadStringW(hUser32
, IDS_IGNORE
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
378 LoadStringW(hUser32
, IDS_HELP
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
381 ButtonText
[i
][0] = (WCHAR
)0;
385 /* Space for buttons */
386 bufsize
= (bufsize
+ 3) & ~3;
387 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
389 (wcslen(ButtonText
[i
]) + 1) * sizeof(WCHAR
);
392 buf
= RtlAllocateHeap(GetProcessHeap(), 0, bufsize
);
399 hDC
= CreateCompatibleDC(0);
401 nclm
.cbSize
= sizeof(nclm
);
402 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, sizeof(nclm
), &nclm
, 0);
403 hFont
= CreateFontIndirectW (&nclm
.lfMessageFont
);
405 tpl
= (DLGTEMPLATE
*)buf
;
407 tpl
->style
= WS_CAPTION
| WS_POPUP
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_SYSMENU
| DS_CENTER
| DS_MODALFRAME
| DS_NOIDLEMSG
;
408 tpl
->dwExtendedStyle
= WS_EX_DLGMODALFRAME
| WS_EX_WINDOWEDGE
| WS_EX_CONTROLPARENT
;
409 if(lpMsgBoxParams
->dwStyle
& MB_TOPMOST
)
410 tpl
->dwExtendedStyle
|= WS_EX_TOPMOST
;
411 if(lpMsgBoxParams
->dwStyle
& MB_RIGHT
)
412 tpl
->dwExtendedStyle
|= WS_EX_RIGHT
;
415 tpl
->cdit
= nButtons
+ ((Icon
!= (HICON
)0) ? 1 : 0) + 1;
417 dest
= (BYTE
*)(tpl
+ 1);
419 *(WORD
*)dest
= 0; /* no menu */
420 *(((WORD
*)dest
) + 1) = 0; /* use default window class */
421 dest
+= 2 * sizeof(WORD
);
422 memcpy(dest
, caption
, caplen
* sizeof(WCHAR
));
423 dest
+= caplen
* sizeof(WCHAR
);
424 *(WCHAR
*)dest
= L
'\0';
425 dest
+= sizeof(WCHAR
);
430 dest
= (BYTE
*)(((ULONG_PTR
)dest
+ 3) & ~3);
431 iico
= (DLGITEMTEMPLATE
*)dest
;
432 iico
->style
= WS_CHILD
| WS_VISIBLE
| SS_ICON
;
433 iico
->dwExtendedStyle
= 0;
434 iico
->id
= MSGBOX_IDICON
;
436 dest
+= sizeof(DLGITEMTEMPLATE
);
437 *(WORD
*)dest
= 0xFFFF;
438 dest
+= sizeof(WORD
);
439 *(WORD
*)dest
= 0x0082; /* static control */
440 dest
+= sizeof(WORD
);
441 *(WORD
*)dest
= 0xFFFF;
442 dest
+= sizeof(WORD
);
444 dest
+= sizeof(WCHAR
);
446 dest
+= sizeof(WORD
);
449 /* create static for text */
450 dest
= (BYTE
*)(((DWORD
)dest
+ 3) & ~3);
451 itxt
= (DLGITEMTEMPLATE
*)dest
;
452 itxt
->style
= WS_CHILD
| WS_VISIBLE
| SS_NOPREFIX
;
453 if(lpMsgBoxParams
->dwStyle
& MB_RIGHT
)
454 itxt
->style
|= SS_RIGHT
;
456 itxt
->style
|= SS_LEFT
;
457 itxt
->dwExtendedStyle
= 0;
458 itxt
->id
= MSGBOX_IDTEXT
;
459 dest
+= sizeof(DLGITEMTEMPLATE
);
460 *(WORD
*)dest
= 0xFFFF;
461 dest
+= sizeof(WORD
);
462 *(WORD
*)dest
= 0x0082; /* static control */
463 dest
+= sizeof(WORD
);
464 memcpy(dest
, text
, textlen
* sizeof(WCHAR
));
465 dest
+= textlen
* sizeof(WCHAR
);
467 dest
+= sizeof(WCHAR
);
469 dest
+= sizeof(WORD
);
474 btnrect
.left
= btnrect
.top
= 0;
475 for(i
= 0; i
< nButtons
; i
++)
477 dest
= (BYTE
*)(((DWORD
)dest
+ 3) & ~3);
478 ibtn
[i
] = (DLGITEMTEMPLATE
*)dest
;
479 ibtn
[i
]->style
= WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
;
480 if(!defbtn
&& (i
== ((lpMsgBoxParams
->dwStyle
& MB_DEFMASK
) >> 8)))
482 ibtn
[i
]->style
|= BS_DEFPUSHBUTTON
;
483 mbi
.DefBtn
= Buttons
[i
];
487 ibtn
[i
]->style
|= BS_PUSHBUTTON
;
488 ibtn
[i
]->dwExtendedStyle
= 0;
489 ibtn
[i
]->id
= Buttons
[i
];
490 dest
+= sizeof(DLGITEMTEMPLATE
);
491 *(WORD
*)dest
= 0xFFFF;
492 dest
+= sizeof(WORD
);
493 *(WORD
*)dest
= 0x0080; /* button control */
494 dest
+= sizeof(WORD
);
495 btnlen
= strlenW(ButtonText
[i
]);
496 memcpy(dest
, ButtonText
[i
], btnlen
* sizeof(WCHAR
));
497 dest
+= btnlen
* sizeof(WCHAR
);
499 dest
+= sizeof(WORD
);
501 dest
+= sizeof(WORD
);
502 SelectObject(hDC
, hFont
);
503 DrawTextW(hDC
, ButtonText
[i
], btnlen
, &btnrect
, DT_LEFT
| DT_SINGLELINE
| DT_CALCRECT
);
504 btnsize
.cx
= max(btnsize
.cx
, btnrect
.right
);
505 btnsize
.cy
= max(btnsize
.cy
, btnrect
.bottom
);
508 /* make first button the default button if no other is */
511 ibtn
[0]->style
&= ~BS_PUSHBUTTON
;
512 ibtn
[0]->style
|= BS_DEFPUSHBUTTON
;
513 mbi
.DefBtn
= Buttons
[0];
516 /* calculate position and size of controls */
517 txtrect
.right
= GetSystemMetrics(SM_CXSCREEN
) / 5 * 4;
519 txtrect
.right
-= GetSystemMetrics(SM_CXICON
) + MSGBOXEX_SPACING
;
520 txtrect
.top
= txtrect
.left
= txtrect
.bottom
= 0;
521 SelectObject(hDC
, hFont
);
522 DrawTextW(hDC
, text
, textlen
, &txtrect
, DT_LEFT
| DT_NOPREFIX
| DT_WORDBREAK
| DT_CALCRECT
);
525 /* calculate position and size of the icon */
526 rc
.left
= rc
.bottom
= rc
.right
= 0;
531 rc
.right
= GetSystemMetrics(SM_CXICON
);
532 rc
.bottom
= GetSystemMetrics(SM_CYICON
);
533 #ifdef MSGBOX_ICONVCENTER
534 rc
.top
= MSGBOXEX_MARGIN
+ (max(txtrect
.bottom
, rc
.bottom
) / 2) - (GetSystemMetrics(SM_CYICON
) / 2);
535 rc
.top
= max(MSGBOXEX_SPACING
, rc
.top
);
537 rc
.top
= MSGBOXEX_MARGIN
;
539 btnleft
= (nButtons
* (btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
)) - MSGBOXEX_BUTTONSPACING
;
540 if(btnleft
> txtrect
.right
+ rc
.right
+ MSGBOXEX_SPACING
)
542 #ifdef MSGBOX_TEXTHCENTER
543 lmargin
= MSGBOXEX_MARGIN
+ ((btnleft
- txtrect
.right
- rc
.right
- MSGBOXEX_SPACING
) / 2);
545 lmargin
= MSGBOXEX_MARGIN
;
547 btnleft
= MSGBOXEX_MARGIN
;
551 lmargin
= MSGBOXEX_MARGIN
;
552 btnleft
= MSGBOXEX_MARGIN
+ ((txtrect
.right
+ rc
.right
+ MSGBOXEX_SPACING
) / 2) - (btnleft
/ 2);
555 iico
->x
= (rc
.left
* 4) / LOWORD(units
);
556 iico
->y
= (rc
.top
* 8) / HIWORD(units
);
557 iico
->cx
= (rc
.right
* 4) / LOWORD(units
);
558 iico
->cy
= (rc
.bottom
* 8) / HIWORD(units
);
559 btntop
= rc
.top
+ rc
.bottom
+ MSGBOXEX_SPACING
;
560 rc
.left
+= rc
.right
+ MSGBOXEX_SPACING
;
564 btnleft
= (nButtons
* (btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
)) - MSGBOXEX_BUTTONSPACING
;
565 if(btnleft
> txtrect
.right
)
567 #ifdef MSGBOX_TEXTHCENTER
568 lmargin
= MSGBOXEX_MARGIN
+ ((btnleft
- txtrect
.right
) / 2);
570 lmargin
= MSGBOXEX_MARGIN
;
572 btnleft
= MSGBOXEX_MARGIN
;
576 lmargin
= MSGBOXEX_MARGIN
;
577 btnleft
= MSGBOXEX_MARGIN
+ (txtrect
.right
/ 2) - (btnleft
/ 2);
581 /* calculate position of the text */
582 rc
.top
= MSGBOXEX_MARGIN
+ (rc
.bottom
/ 2) - (txtrect
.bottom
/ 2);
583 rc
.top
= max(rc
.top
, MSGBOXEX_MARGIN
);
584 /* calculate position of the buttons */
585 btntop
= max(rc
.top
+ txtrect
.bottom
+ MSGBOXEX_SPACING
, btntop
);
586 for(i
= 0; i
< nButtons
; i
++)
588 ibtn
[i
]->x
= (btnleft
* 4) / LOWORD(units
);
589 ibtn
[i
]->y
= (btntop
* 8) / HIWORD(units
);
590 ibtn
[i
]->cx
= (btnsize
.cx
* 4) / LOWORD(units
);
591 ibtn
[i
]->cy
= (btnsize
.cy
* 8) / HIWORD(units
);
592 btnleft
+= btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
;
594 /* calculate size and position of the messagebox window */
595 btnleft
= max(btnleft
- MSGBOXEX_BUTTONSPACING
, rc
.left
+ txtrect
.right
);
596 btnleft
+= MSGBOXEX_MARGIN
;
597 btntop
+= btnsize
.cy
+ MSGBOXEX_MARGIN
;
598 /* set size and position of the message static */
599 itxt
->x
= (rc
.left
* 4) / LOWORD(units
);
600 itxt
->y
= (rc
.top
* 8) / HIWORD(units
);
601 itxt
->cx
= (((btnleft
- rc
.left
- MSGBOXEX_MARGIN
) * 4) / LOWORD(units
));
602 itxt
->cy
= ((txtrect
.bottom
* 8) / HIWORD(units
));
603 /* set size of the window */
604 tpl
->cx
= (btnleft
* 4) / LOWORD(units
);
605 tpl
->cy
= (btntop
* 8) / HIWORD(units
);
607 /* finally show the messagebox */
610 mbi
.ContextHelpId
= lpMsgBoxParams
->dwContextHelpId
;
611 mbi
.Callback
= lpMsgBoxParams
->lpfnMsgBoxCallback
;
612 mbi
.Style
= lpMsgBoxParams
->dwStyle
;
613 mbi
.nButtons
= nButtons
;
614 mbi
.Btns
= &Buttons
[0];
615 mbi
.Timeout
= Timeout
;
620 ret
= DialogBoxIndirectParamW(lpMsgBoxParams
->hInstance
, tpl
, lpMsgBoxParams
->hwndOwner
,
621 MessageBoxProc
, (LPARAM
)&mbi
);
626 RtlFreeHeap(GetProcessHeap(), 0, buf
);
630 /* FUNCTIONS *****************************************************************/
644 return MessageBoxExA(hWnd
, lpText
, lpCaption
, uType
, LANG_NEUTRAL
);
660 MSGBOXPARAMSA msgbox
;
662 msgbox
.cbSize
= sizeof(msgbox
);
663 msgbox
.hwndOwner
= hWnd
;
664 msgbox
.hInstance
= 0;
665 msgbox
.lpszText
= lpText
;
666 msgbox
.lpszCaption
= lpCaption
;
667 msgbox
.dwStyle
= uType
;
668 msgbox
.lpszIcon
= NULL
;
669 msgbox
.dwContextHelpId
= 0;
670 msgbox
.lpfnMsgBoxCallback
= NULL
;
671 msgbox
.dwLanguageId
= wLanguageId
;
673 return MessageBoxIndirectA(&msgbox
);
689 MSGBOXPARAMSW msgbox
;
691 msgbox
.cbSize
= sizeof(msgbox
);
692 msgbox
.hwndOwner
= hWnd
;
693 msgbox
.hInstance
= 0;
694 msgbox
.lpszText
= lpText
;
695 msgbox
.lpszCaption
= lpCaption
;
696 msgbox
.dwStyle
= uType
;
697 msgbox
.lpszIcon
= NULL
;
698 msgbox
.dwContextHelpId
= 0;
699 msgbox
.lpfnMsgBoxCallback
= NULL
;
700 msgbox
.dwLanguageId
= wLanguageId
;
702 return MessageBoxTimeoutIndirectW(&msgbox
, (UINT
)-1);
712 CONST MSGBOXPARAMSA
*lpMsgBoxParams
)
714 MSGBOXPARAMSW msgboxW
;
715 UNICODE_STRING textW
, captionW
, iconW
;
718 if (HIWORD((UINT
)lpMsgBoxParams
->lpszText
))
720 RtlCreateUnicodeStringFromAsciiz(&textW
, (PCSZ
)lpMsgBoxParams
->lpszText
);
722 * UNICODE_STRING objects are always allocated with an extra byte so you
723 * can null-term if you want
725 textW
.Buffer
[textW
.Length
/ sizeof(WCHAR
)] = L
'\0';
728 textW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszText
;
730 if (HIWORD((UINT
)lpMsgBoxParams
->lpszCaption
))
732 RtlCreateUnicodeStringFromAsciiz(&captionW
, (PCSZ
)lpMsgBoxParams
->lpszCaption
);
734 * UNICODE_STRING objects are always allocated with an extra byte so you
735 * can null-term if you want
737 captionW
.Buffer
[captionW
.Length
/ sizeof(WCHAR
)] = L
'\0';
740 captionW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszCaption
;
742 if(lpMsgBoxParams
->dwStyle
& MB_USERICON
)
744 if (HIWORD((UINT
)lpMsgBoxParams
->lpszIcon
))
746 RtlCreateUnicodeStringFromAsciiz(&iconW
, (PCSZ
)lpMsgBoxParams
->lpszIcon
);
748 * UNICODE_STRING objects are always allocated with an extra byte so you
749 * can null-term if you want
751 iconW
.Buffer
[iconW
.Length
/ sizeof(WCHAR
)] = L
'\0';
754 iconW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszIcon
;
759 msgboxW
.cbSize
= sizeof(msgboxW
);
760 msgboxW
.hwndOwner
= lpMsgBoxParams
->hwndOwner
;
761 msgboxW
.hInstance
= lpMsgBoxParams
->hInstance
;
762 msgboxW
.lpszText
= textW
.Buffer
;
763 msgboxW
.lpszCaption
= captionW
.Buffer
;
764 msgboxW
.dwStyle
= lpMsgBoxParams
->dwStyle
;
765 msgboxW
.lpszIcon
= iconW
.Buffer
;
766 msgboxW
.dwContextHelpId
= lpMsgBoxParams
->dwContextHelpId
;
767 msgboxW
.lpfnMsgBoxCallback
= lpMsgBoxParams
->lpfnMsgBoxCallback
;
768 msgboxW
.dwLanguageId
= lpMsgBoxParams
->dwLanguageId
;
770 ret
= MessageBoxTimeoutIndirectW(&msgboxW
, (UINT
)-1);
772 if (HIWORD((UINT
)lpMsgBoxParams
->lpszText
))
773 RtlFreeUnicodeString(&textW
);
775 if (HIWORD((UINT
)lpMsgBoxParams
->lpszCaption
))
776 RtlFreeUnicodeString(&captionW
);
778 if ((lpMsgBoxParams
->dwStyle
& MB_USERICON
) && HIWORD((UINT
)iconW
.Buffer
))
779 RtlFreeUnicodeString(&iconW
);
791 CONST MSGBOXPARAMSW
*lpMsgBoxParams
)
793 return MessageBoxTimeoutIndirectW(lpMsgBoxParams
, (UINT
)-1);
808 return MessageBoxExW(hWnd
, lpText
, lpCaption
, uType
, LANG_NEUTRAL
);
824 MSGBOXPARAMSW msgboxW
;
825 UNICODE_STRING textW
, captionW
;
828 if (HIWORD((UINT
)lpText
))
829 RtlCreateUnicodeStringFromAsciiz(&textW
, (PCSZ
)lpText
);
831 textW
.Buffer
= (LPWSTR
)lpText
;
833 if (HIWORD((UINT
)lpCaption
))
834 RtlCreateUnicodeStringFromAsciiz(&captionW
, (PCSZ
)lpCaption
);
836 captionW
.Buffer
= (LPWSTR
)lpCaption
;
838 msgboxW
.cbSize
= sizeof(msgboxW
);
839 msgboxW
.hwndOwner
= hWnd
;
840 msgboxW
.hInstance
= 0;
841 msgboxW
.lpszText
= textW
.Buffer
;
842 msgboxW
.lpszCaption
= captionW
.Buffer
;
843 msgboxW
.dwStyle
= uType
;
844 msgboxW
.lpszIcon
= NULL
;
845 msgboxW
.dwContextHelpId
= 0;
846 msgboxW
.lpfnMsgBoxCallback
= NULL
;
847 msgboxW
.dwLanguageId
= wLanguageId
;
849 ret
= MessageBoxTimeoutIndirectW(&msgboxW
, (UINT
)dwTime
);
851 if (HIWORD(textW
.Buffer
))
852 RtlFreeUnicodeString(&textW
);
854 if (HIWORD(captionW
.Buffer
))
855 RtlFreeUnicodeString(&captionW
);
873 MSGBOXPARAMSW msgbox
;
875 msgbox
.cbSize
= sizeof(msgbox
);
876 msgbox
.hwndOwner
= hWnd
;
877 msgbox
.hInstance
= 0;
878 msgbox
.lpszText
= lpText
;
879 msgbox
.lpszCaption
= lpCaption
;
880 msgbox
.dwStyle
= uType
;
881 msgbox
.lpszIcon
= NULL
;
882 msgbox
.dwContextHelpId
= 0;
883 msgbox
.lpfnMsgBoxCallback
= NULL
;
884 msgbox
.dwLanguageId
= wLanguageId
;
886 return MessageBoxTimeoutIndirectW(&msgbox
, (UINT
)dwTime
);
895 SoftModalMessageBox(DWORD Unknown0
)
907 MessageBeep(UINT uType
)
915 if(waveOutGetNumDevs() == 0)
916 return Beep(500, 100); // Beep through speaker
919 EventName
= L
"SystemDefault";
921 case MB_ICONASTERISK
:
922 EventName
= L
"SystemAsterisk";
924 case MB_ICONEXCLAMATION
:
925 EventName
= L
"SystemExclamation";
928 EventName
= L
"SystemHand";
930 case MB_ICONQUESTION
:
931 EventName
= L
"SystemQuestion";
935 return PlaySoundW((LPCWSTR
)EventName
, NULL
, SND_ALIAS
| SND_NOWAIT
| SND_NOSTOP
| SND_ASYNC
);
937 return Beep(500, 100); // Beep through speaker