7ea0b9016e24754d46c748f8bf7e8748e411df2f
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.
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 ******************************************************************/
36 #include <wine/debug.h>
38 WINE_DEFAULT_DEBUG_CHANNEL(user32
);
40 /* DEFINES *******************************************************************/
42 #define MSGBOX_IDICON (1088)
43 #define MSGBOX_IDTEXT (100)
45 #define IDI_HANDA MAKEINTRESOURCEA(32513)
46 #define IDI_HANDW MAKEINTRESOURCEW(32513)
47 #define IDI_QUESTIONA MAKEINTRESOURCEA(32514)
48 #define IDI_QUESTIONW MAKEINTRESOURCEW(32514)
49 #define IDI_EXCLAMATIONA MAKEINTRESOURCEA(32515)
50 #define IDI_EXCLAMATIONW MAKEINTRESOURCEW(32515)
51 #define IDI_ASTERISKA MAKEINTRESOURCEA(32516)
52 #define IDI_ASTERISKW MAKEINTRESOURCEW(32516)
53 #define IDI_WINLOGOA MAKEINTRESOURCEA(32517)
54 #define IDI_WINLOGOW MAKEINTRESOURCEW(32517)
59 #define MSGBOXEX_SPACING (16)
60 #define MSGBOXEX_BUTTONSPACING (6)
61 #define MSGBOXEX_MARGIN (12)
62 #define MSGBOXEX_MAXBTNSTR (32)
63 #define MSGBOXEX_MAXBTNS (4)
65 typedef struct _MSGBOXINFO
{
69 MSGBOXCALLBACK Callback
;
75 } MSGBOXINFO
, *PMSGBOXINFO
;
77 /* INTERNAL FUNCTIONS ********************************************************/
79 static INT_PTR CALLBACK
MessageBoxProc( HWND hwnd
, UINT message
,
80 WPARAM wParam
, LPARAM lParam
)
89 mbi
= (PMSGBOXINFO
)lParam
;
90 if(!GetPropW(hwnd
, L
"ROS_MSGBOX"))
92 SetPropW(hwnd
, L
"ROS_MSGBOX", (HANDLE
)lParam
);
94 SendDlgItemMessageW(hwnd
, MSGBOX_IDICON
, STM_SETICON
, (WPARAM
)mbi
->Icon
, 0);
95 SetWindowContextHelpId(hwnd
, mbi
->ContextHelpId
);
97 /* set control fonts */
98 SendDlgItemMessageW(hwnd
, MSGBOX_IDTEXT
, WM_SETFONT
, (WPARAM
)mbi
->Font
, 0);
99 for(i
= 0; i
< mbi
->nButtons
; i
++)
101 SendDlgItemMessageW(hwnd
, mbi
->Btns
[i
], WM_SETFONT
, (WPARAM
)mbi
->Font
, 0);
103 switch(mbi
->Style
& MB_TYPEMASK
)
105 case MB_ABORTRETRYIGNORE
:
107 RemoveMenu(GetSystemMenu(hwnd
, FALSE
), SC_CLOSE
, MF_BYCOMMAND
);
110 SetFocus(GetDlgItem(hwnd
, mbi
->DefBtn
));
111 if(mbi
->Timeout
&& (mbi
->Timeout
!= (UINT
)-1))
112 SetTimer(hwnd
, 0, mbi
->Timeout
, NULL
);
117 switch (LOWORD(wParam
))
128 EndDialog(hwnd
, wParam
);
131 /* send WM_HELP message to messagebox window */
132 hi
.cbSize
= sizeof(HELPINFO
);
133 hi
.iContextType
= HELPINFO_WINDOW
;
134 hi
.iCtrlId
= LOWORD(wParam
);
135 hi
.hItemHandle
= (HANDLE
)lParam
;
137 GetCursorPos(&hi
.MousePos
);
138 SendMessageW(hwnd
, WM_HELP
, 0, (LPARAM
)&hi
);
144 mbi
= (PMSGBOXINFO
)GetPropW(hwnd
, L
"ROS_MSGBOX");
147 memcpy(&hi
, (void *)lParam
, sizeof(hi
));
148 hi
.dwContextId
= GetWindowContextHelpId(hwnd
);
154 owner
= GetWindow(hwnd
, GW_OWNER
);
156 SendMessageW(GetWindow(hwnd
, GW_OWNER
), WM_HELP
, 0, (LPARAM
)&hi
);
161 mbi
= (PMSGBOXINFO
)GetPropW(hwnd
, L
"ROS_MSGBOX");
164 switch(mbi
->Style
& MB_TYPEMASK
)
166 case MB_ABORTRETRYIGNORE
:
170 EndDialog(hwnd
, IDCANCEL
);
176 EndDialog(hwnd
, 32000);
184 MessageBoxTimeoutIndirectW(
185 CONST MSGBOXPARAMSW
*lpMsgBoxParams
, UINT Timeout
)
188 DLGITEMTEMPLATE
*iico
, *itxt
;
189 NONCLIENTMETRICSW nclm
;
193 LPCWSTR caption
, text
;
197 int bufsize
, ret
, caplen
, textlen
, btnlen
, i
, btnleft
, btntop
, lmargin
, nButtons
= 0;
198 LONG Buttons
[MSGBOXEX_MAXBTNS
];
199 WCHAR ButtonText
[MSGBOXEX_MAXBTNS
][MSGBOXEX_MAXBTNSTR
];
200 DLGITEMTEMPLATE
*ibtn
[MSGBOXEX_MAXBTNS
];
201 RECT btnrect
, txtrect
, rc
;
205 DWORD units
= GetDialogBaseUnits();
207 if(!lpMsgBoxParams
->lpszCaption
|| !HIWORD((LPWSTR
)lpMsgBoxParams
->lpszCaption
))
209 LoadStringW(User32Instance
, IDS_ERROR
, &capbuf
[0], 32);
210 caption
= &capbuf
[0];
213 caption
= (LPWSTR
)lpMsgBoxParams
->lpszCaption
;
215 if(!lpMsgBoxParams
->lpszText
|| !HIWORD(lpMsgBoxParams
->lpszText
))
218 text
= lpMsgBoxParams
->lpszText
;
220 caplen
= strlenW(caption
);
221 textlen
= strlenW(text
);
223 /* Create selected buttons */
224 switch(lpMsgBoxParams
->dwStyle
& MB_TYPEMASK
)
228 Buttons
[1] = IDCANCEL
;
231 case MB_CANCELTRYCONTINUE
:
232 Buttons
[0] = IDCANCEL
;
233 Buttons
[1] = IDTRYAGAIN
;
234 Buttons
[2] = IDCONTINUE
;
237 case MB_ABORTRETRYIGNORE
:
238 Buttons
[0] = IDABORT
;
239 Buttons
[1] = IDRETRY
;
240 Buttons
[2] = IDIGNORE
;
251 Buttons
[2] = IDCANCEL
;
255 Buttons
[0] = IDRETRY
;
256 Buttons
[1] = IDCANCEL
;
266 /* Create Help button */
267 if(lpMsgBoxParams
->dwStyle
& MB_HELP
)
268 Buttons
[nButtons
++] = IDHELP
;
270 switch(lpMsgBoxParams
->dwStyle
& MB_ICONMASK
)
272 case MB_ICONEXCLAMATION
:
273 Icon
= LoadIconW(0, IDI_EXCLAMATIONW
);
274 MessageBeep(MB_ICONEXCLAMATION
);
276 case MB_ICONQUESTION
:
277 Icon
= LoadIconW(0, IDI_QUESTIONW
);
278 MessageBeep(MB_ICONQUESTION
);
280 case MB_ICONASTERISK
:
281 Icon
= LoadIconW(0, IDI_ASTERISKW
);
282 MessageBeep(MB_ICONASTERISK
);
285 Icon
= LoadIconW(0, IDI_HANDW
);
286 MessageBeep(MB_ICONHAND
);
289 Icon
= LoadIconW(lpMsgBoxParams
->hInstance
, lpMsgBoxParams
->lpszIcon
);
293 /* By default, Windows 95/98/NT does not associate an icon to message boxes.
294 * So ReactOS should do the same.
302 bufsize
= sizeof(DLGTEMPLATE
) +
303 2 * sizeof(WORD
) + /* menu and class */
304 (caplen
+ 1) * sizeof(WCHAR
); /* title */
309 bufsize
= (bufsize
+ 3) & ~3;
310 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
316 bufsize
= (bufsize
+ 3) & ~3;
317 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
319 (textlen
+ 1) * sizeof(WCHAR
);
322 for(i
= 0; i
< nButtons
; i
++)
327 LoadStringW(User32Instance
, IDS_OK
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
330 LoadStringW(User32Instance
, IDS_CANCEL
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
333 LoadStringW(User32Instance
, IDS_YES
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
336 LoadStringW(User32Instance
, IDS_NO
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
339 LoadStringW(User32Instance
, IDS_TRYAGAIN
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
342 LoadStringW(User32Instance
, IDS_CONTINUE
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
345 LoadStringW(User32Instance
, IDS_ABORT
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
348 LoadStringW(User32Instance
, IDS_RETRY
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
351 LoadStringW(User32Instance
, IDS_IGNORE
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
354 LoadStringW(User32Instance
, IDS_HELP
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
357 ButtonText
[i
][0] = (WCHAR
)0;
361 /* Space for buttons */
362 bufsize
= (bufsize
+ 3) & ~3;
363 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
365 (wcslen(ButtonText
[i
]) + 1) * sizeof(WCHAR
);
368 buf
= RtlAllocateHeap(GetProcessHeap(), 0, bufsize
);
375 hDC
= CreateCompatibleDC(0);
377 nclm
.cbSize
= sizeof(nclm
);
378 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, sizeof(nclm
), &nclm
, 0);
379 hFont
= CreateFontIndirectW (&nclm
.lfMessageFont
);
381 tpl
= (DLGTEMPLATE
*)buf
;
383 tpl
->style
= WS_CAPTION
| WS_POPUP
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_SYSMENU
| DS_CENTER
| DS_MODALFRAME
| DS_NOIDLEMSG
;
384 tpl
->dwExtendedStyle
= WS_EX_DLGMODALFRAME
| WS_EX_WINDOWEDGE
| WS_EX_CONTROLPARENT
;
385 if(lpMsgBoxParams
->dwStyle
& MB_TOPMOST
)
386 tpl
->dwExtendedStyle
|= WS_EX_TOPMOST
;
387 if(lpMsgBoxParams
->dwStyle
& MB_RIGHT
)
388 tpl
->dwExtendedStyle
|= WS_EX_RIGHT
;
391 tpl
->cdit
= nButtons
+ ((Icon
!= (HICON
)0) ? 1 : 0) + 1;
393 dest
= (BYTE
*)(tpl
+ 1);
395 *(WORD
*)dest
= 0; /* no menu */
396 *(((WORD
*)dest
) + 1) = 0; /* use default window class */
397 dest
+= 2 * sizeof(WORD
);
398 memcpy(dest
, caption
, caplen
* sizeof(WCHAR
));
399 dest
+= caplen
* sizeof(WCHAR
);
400 *(WCHAR
*)dest
= L
'\0';
401 dest
+= sizeof(WCHAR
);
406 dest
= (BYTE
*)(((ULONG_PTR
)dest
+ 3) & ~3);
407 iico
= (DLGITEMTEMPLATE
*)dest
;
408 iico
->style
= WS_CHILD
| WS_VISIBLE
| SS_ICON
;
409 iico
->dwExtendedStyle
= 0;
410 iico
->id
= MSGBOX_IDICON
;
412 dest
+= sizeof(DLGITEMTEMPLATE
);
413 *(WORD
*)dest
= 0xFFFF;
414 dest
+= sizeof(WORD
);
415 *(WORD
*)dest
= 0x0082; /* static control */
416 dest
+= sizeof(WORD
);
417 *(WORD
*)dest
= 0xFFFF;
418 dest
+= sizeof(WORD
);
420 dest
+= sizeof(WCHAR
);
422 dest
+= sizeof(WORD
);
425 /* create static for text */
426 dest
= (BYTE
*)(((UINT_PTR
)dest
+ 3) & ~3);
427 itxt
= (DLGITEMTEMPLATE
*)dest
;
428 itxt
->style
= WS_CHILD
| WS_VISIBLE
| SS_NOPREFIX
;
429 if(lpMsgBoxParams
->dwStyle
& MB_RIGHT
)
430 itxt
->style
|= SS_RIGHT
;
432 itxt
->style
|= SS_LEFT
;
433 itxt
->dwExtendedStyle
= 0;
434 itxt
->id
= MSGBOX_IDTEXT
;
435 dest
+= sizeof(DLGITEMTEMPLATE
);
436 *(WORD
*)dest
= 0xFFFF;
437 dest
+= sizeof(WORD
);
438 *(WORD
*)dest
= 0x0082; /* static control */
439 dest
+= sizeof(WORD
);
440 memcpy(dest
, text
, textlen
* sizeof(WCHAR
));
441 dest
+= textlen
* sizeof(WCHAR
);
443 dest
+= sizeof(WCHAR
);
445 dest
+= sizeof(WORD
);
450 btnrect
.left
= btnrect
.top
= 0;
451 for(i
= 0; i
< nButtons
; i
++)
453 dest
= (BYTE
*)(((UINT_PTR
)dest
+ 3) & ~3);
454 ibtn
[i
] = (DLGITEMTEMPLATE
*)dest
;
455 ibtn
[i
]->style
= WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
;
456 if(!defbtn
&& (i
== ((lpMsgBoxParams
->dwStyle
& MB_DEFMASK
) >> 8)))
458 ibtn
[i
]->style
|= BS_DEFPUSHBUTTON
;
459 mbi
.DefBtn
= Buttons
[i
];
463 ibtn
[i
]->style
|= BS_PUSHBUTTON
;
464 ibtn
[i
]->dwExtendedStyle
= 0;
465 ibtn
[i
]->id
= Buttons
[i
];
466 dest
+= sizeof(DLGITEMTEMPLATE
);
467 *(WORD
*)dest
= 0xFFFF;
468 dest
+= sizeof(WORD
);
469 *(WORD
*)dest
= 0x0080; /* button control */
470 dest
+= sizeof(WORD
);
471 btnlen
= strlenW(ButtonText
[i
]);
472 memcpy(dest
, ButtonText
[i
], btnlen
* sizeof(WCHAR
));
473 dest
+= btnlen
* sizeof(WCHAR
);
475 dest
+= sizeof(WORD
);
477 dest
+= sizeof(WORD
);
478 SelectObject(hDC
, hFont
);
479 DrawTextW(hDC
, ButtonText
[i
], btnlen
, &btnrect
, DT_LEFT
| DT_SINGLELINE
| DT_CALCRECT
);
480 btnsize
.cx
= max(btnsize
.cx
, btnrect
.right
);
481 btnsize
.cy
= max(btnsize
.cy
, btnrect
.bottom
);
484 /* make first button the default button if no other is */
487 ibtn
[0]->style
&= ~BS_PUSHBUTTON
;
488 ibtn
[0]->style
|= BS_DEFPUSHBUTTON
;
489 mbi
.DefBtn
= Buttons
[0];
492 /* calculate position and size of controls */
493 txtrect
.right
= GetSystemMetrics(SM_CXSCREEN
) / 5 * 4;
495 txtrect
.right
-= GetSystemMetrics(SM_CXICON
) + MSGBOXEX_SPACING
;
496 txtrect
.top
= txtrect
.left
= txtrect
.bottom
= 0;
497 SelectObject(hDC
, hFont
);
500 DrawTextW(hDC
, text
, textlen
, &txtrect
, DT_LEFT
| DT_NOPREFIX
| DT_WORDBREAK
| DT_CALCRECT
);
504 txtrect
.right
= txtrect
.left
+ 1;
505 txtrect
.bottom
= txtrect
.top
+ 1;
509 /* calculate position and size of the icon */
510 rc
.left
= rc
.bottom
= rc
.right
= 0;
515 rc
.right
= GetSystemMetrics(SM_CXICON
);
516 rc
.bottom
= GetSystemMetrics(SM_CYICON
);
517 #ifdef MSGBOX_ICONVCENTER
518 rc
.top
= MSGBOXEX_MARGIN
+ (max(txtrect
.bottom
, rc
.bottom
) / 2) - (GetSystemMetrics(SM_CYICON
) / 2);
519 rc
.top
= max(MSGBOXEX_SPACING
, rc
.top
);
521 rc
.top
= MSGBOXEX_MARGIN
;
523 btnleft
= (nButtons
* (btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
)) - MSGBOXEX_BUTTONSPACING
;
524 if(btnleft
> txtrect
.right
+ rc
.right
+ MSGBOXEX_SPACING
)
526 #ifdef MSGBOX_TEXTHCENTER
527 lmargin
= MSGBOXEX_MARGIN
+ ((btnleft
- txtrect
.right
- rc
.right
- MSGBOXEX_SPACING
) / 2);
529 lmargin
= MSGBOXEX_MARGIN
;
531 btnleft
= MSGBOXEX_MARGIN
;
535 lmargin
= MSGBOXEX_MARGIN
;
536 btnleft
= MSGBOXEX_MARGIN
+ ((txtrect
.right
+ rc
.right
+ MSGBOXEX_SPACING
) / 2) - (btnleft
/ 2);
539 iico
->x
= (rc
.left
* 4) / LOWORD(units
);
540 iico
->y
= (rc
.top
* 8) / HIWORD(units
);
541 iico
->cx
= (rc
.right
* 4) / LOWORD(units
);
542 iico
->cy
= (rc
.bottom
* 8) / HIWORD(units
);
543 btntop
= rc
.top
+ rc
.bottom
+ MSGBOXEX_SPACING
;
544 rc
.left
+= rc
.right
+ MSGBOXEX_SPACING
;
548 btnleft
= (nButtons
* (btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
)) - MSGBOXEX_BUTTONSPACING
;
549 if(btnleft
> txtrect
.right
)
551 #ifdef MSGBOX_TEXTHCENTER
552 lmargin
= MSGBOXEX_MARGIN
+ ((btnleft
- txtrect
.right
) / 2);
554 lmargin
= MSGBOXEX_MARGIN
;
556 btnleft
= MSGBOXEX_MARGIN
;
560 lmargin
= MSGBOXEX_MARGIN
;
561 btnleft
= MSGBOXEX_MARGIN
+ (txtrect
.right
/ 2) - (btnleft
/ 2);
565 /* calculate position of the text */
566 rc
.top
= MSGBOXEX_MARGIN
+ (rc
.bottom
/ 2) - (txtrect
.bottom
/ 2);
567 rc
.top
= max(rc
.top
, MSGBOXEX_MARGIN
);
568 /* calculate position of the buttons */
569 btntop
= max(rc
.top
+ txtrect
.bottom
+ MSGBOXEX_SPACING
, btntop
);
570 for(i
= 0; i
< nButtons
; i
++)
572 ibtn
[i
]->x
= (btnleft
* 4) / LOWORD(units
);
573 ibtn
[i
]->y
= (btntop
* 8) / HIWORD(units
);
574 ibtn
[i
]->cx
= (btnsize
.cx
* 4) / LOWORD(units
);
575 ibtn
[i
]->cy
= (btnsize
.cy
* 8) / HIWORD(units
);
576 btnleft
+= btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
;
578 /* calculate size and position of the messagebox window */
579 btnleft
= max(btnleft
- MSGBOXEX_BUTTONSPACING
, rc
.left
+ txtrect
.right
);
580 btnleft
+= MSGBOXEX_MARGIN
;
581 btntop
+= btnsize
.cy
+ MSGBOXEX_MARGIN
;
582 /* set size and position of the message static */
583 itxt
->x
= (rc
.left
* 4) / LOWORD(units
);
584 itxt
->y
= (rc
.top
* 8) / HIWORD(units
);
585 itxt
->cx
= (((btnleft
- rc
.left
- MSGBOXEX_MARGIN
) * 4) / LOWORD(units
));
586 itxt
->cy
= ((txtrect
.bottom
* 8) / HIWORD(units
));
587 /* set size of the window */
588 tpl
->cx
= (btnleft
* 4) / LOWORD(units
);
589 tpl
->cy
= (btntop
* 8) / HIWORD(units
);
591 /* finally show the messagebox */
594 mbi
.ContextHelpId
= lpMsgBoxParams
->dwContextHelpId
;
595 mbi
.Callback
= lpMsgBoxParams
->lpfnMsgBoxCallback
;
596 mbi
.Style
= lpMsgBoxParams
->dwStyle
;
597 mbi
.nButtons
= nButtons
;
598 mbi
.Btns
= &Buttons
[0];
599 mbi
.Timeout
= Timeout
;
604 ret
= DialogBoxIndirectParamW(lpMsgBoxParams
->hInstance
, tpl
, lpMsgBoxParams
->hwndOwner
,
605 MessageBoxProc
, (LPARAM
)&mbi
);
610 RtlFreeHeap(GetProcessHeap(), 0, buf
);
614 /* FUNCTIONS *****************************************************************/
628 return MessageBoxExA(hWnd
, lpText
, lpCaption
, uType
, LANG_NEUTRAL
);
644 MSGBOXPARAMSA msgbox
;
646 msgbox
.cbSize
= sizeof(msgbox
);
647 msgbox
.hwndOwner
= hWnd
;
648 msgbox
.hInstance
= 0;
649 msgbox
.lpszText
= lpText
;
650 msgbox
.lpszCaption
= lpCaption
;
651 msgbox
.dwStyle
= uType
;
652 msgbox
.lpszIcon
= NULL
;
653 msgbox
.dwContextHelpId
= 0;
654 msgbox
.lpfnMsgBoxCallback
= NULL
;
655 msgbox
.dwLanguageId
= wLanguageId
;
657 return MessageBoxIndirectA(&msgbox
);
673 MSGBOXPARAMSW msgbox
;
675 msgbox
.cbSize
= sizeof(msgbox
);
676 msgbox
.hwndOwner
= hWnd
;
677 msgbox
.hInstance
= 0;
678 msgbox
.lpszText
= lpText
;
679 msgbox
.lpszCaption
= lpCaption
;
680 msgbox
.dwStyle
= uType
;
681 msgbox
.lpszIcon
= NULL
;
682 msgbox
.dwContextHelpId
= 0;
683 msgbox
.lpfnMsgBoxCallback
= NULL
;
684 msgbox
.dwLanguageId
= wLanguageId
;
686 return MessageBoxTimeoutIndirectW(&msgbox
, (UINT
)-1);
696 CONST MSGBOXPARAMSA
*lpMsgBoxParams
)
698 MSGBOXPARAMSW msgboxW
;
699 UNICODE_STRING textW
, captionW
, iconW
;
702 if (HIWORD((UINT_PTR
)lpMsgBoxParams
->lpszText
))
704 RtlCreateUnicodeStringFromAsciiz(&textW
, (PCSZ
)lpMsgBoxParams
->lpszText
);
706 * UNICODE_STRING objects are always allocated with an extra byte so you
707 * can null-term if you want
709 textW
.Buffer
[textW
.Length
/ sizeof(WCHAR
)] = L
'\0';
712 textW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszText
;
714 if (HIWORD((UINT_PTR
)lpMsgBoxParams
->lpszCaption
))
716 RtlCreateUnicodeStringFromAsciiz(&captionW
, (PCSZ
)lpMsgBoxParams
->lpszCaption
);
718 * UNICODE_STRING objects are always allocated with an extra byte so you
719 * can null-term if you want
721 captionW
.Buffer
[captionW
.Length
/ sizeof(WCHAR
)] = L
'\0';
724 captionW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszCaption
;
726 if(lpMsgBoxParams
->dwStyle
& MB_USERICON
)
728 if (HIWORD((UINT_PTR
)lpMsgBoxParams
->lpszIcon
))
730 RtlCreateUnicodeStringFromAsciiz(&iconW
, (PCSZ
)lpMsgBoxParams
->lpszIcon
);
732 * UNICODE_STRING objects are always allocated with an extra byte so you
733 * can null-term if you want
735 iconW
.Buffer
[iconW
.Length
/ sizeof(WCHAR
)] = L
'\0';
738 iconW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszIcon
;
743 msgboxW
.cbSize
= sizeof(msgboxW
);
744 msgboxW
.hwndOwner
= lpMsgBoxParams
->hwndOwner
;
745 msgboxW
.hInstance
= lpMsgBoxParams
->hInstance
;
746 msgboxW
.lpszText
= textW
.Buffer
;
747 msgboxW
.lpszCaption
= captionW
.Buffer
;
748 msgboxW
.dwStyle
= lpMsgBoxParams
->dwStyle
;
749 msgboxW
.lpszIcon
= iconW
.Buffer
;
750 msgboxW
.dwContextHelpId
= lpMsgBoxParams
->dwContextHelpId
;
751 msgboxW
.lpfnMsgBoxCallback
= lpMsgBoxParams
->lpfnMsgBoxCallback
;
752 msgboxW
.dwLanguageId
= lpMsgBoxParams
->dwLanguageId
;
754 ret
= MessageBoxTimeoutIndirectW(&msgboxW
, (UINT
)-1);
756 if (HIWORD((UINT_PTR
)lpMsgBoxParams
->lpszText
))
757 RtlFreeUnicodeString(&textW
);
759 if (HIWORD((UINT_PTR
)lpMsgBoxParams
->lpszCaption
))
760 RtlFreeUnicodeString(&captionW
);
762 if ((lpMsgBoxParams
->dwStyle
& MB_USERICON
) && HIWORD((UINT_PTR
)iconW
.Buffer
))
763 RtlFreeUnicodeString(&iconW
);
775 CONST MSGBOXPARAMSW
*lpMsgBoxParams
)
777 return MessageBoxTimeoutIndirectW(lpMsgBoxParams
, (UINT
)-1);
792 return MessageBoxExW(hWnd
, lpText
, lpCaption
, uType
, LANG_NEUTRAL
);
808 MSGBOXPARAMSW msgboxW
;
809 UNICODE_STRING textW
, captionW
;
812 if (HIWORD((UINT_PTR
)lpText
))
813 RtlCreateUnicodeStringFromAsciiz(&textW
, (PCSZ
)lpText
);
815 textW
.Buffer
= (LPWSTR
)lpText
;
817 if (HIWORD((UINT_PTR
)lpCaption
))
818 RtlCreateUnicodeStringFromAsciiz(&captionW
, (PCSZ
)lpCaption
);
820 captionW
.Buffer
= (LPWSTR
)lpCaption
;
822 msgboxW
.cbSize
= sizeof(msgboxW
);
823 msgboxW
.hwndOwner
= hWnd
;
824 msgboxW
.hInstance
= 0;
825 msgboxW
.lpszText
= textW
.Buffer
;
826 msgboxW
.lpszCaption
= captionW
.Buffer
;
827 msgboxW
.dwStyle
= uType
;
828 msgboxW
.lpszIcon
= NULL
;
829 msgboxW
.dwContextHelpId
= 0;
830 msgboxW
.lpfnMsgBoxCallback
= NULL
;
831 msgboxW
.dwLanguageId
= wLanguageId
;
833 ret
= MessageBoxTimeoutIndirectW(&msgboxW
, (UINT
)dwTime
);
835 if (HIWORD(textW
.Buffer
))
836 RtlFreeUnicodeString(&textW
);
838 if (HIWORD(captionW
.Buffer
))
839 RtlFreeUnicodeString(&captionW
);
857 MSGBOXPARAMSW msgbox
;
859 msgbox
.cbSize
= sizeof(msgbox
);
860 msgbox
.hwndOwner
= hWnd
;
861 msgbox
.hInstance
= 0;
862 msgbox
.lpszText
= lpText
;
863 msgbox
.lpszCaption
= lpCaption
;
864 msgbox
.dwStyle
= uType
;
865 msgbox
.lpszIcon
= NULL
;
866 msgbox
.dwContextHelpId
= 0;
867 msgbox
.lpfnMsgBoxCallback
= NULL
;
868 msgbox
.dwLanguageId
= wLanguageId
;
870 return MessageBoxTimeoutIndirectW(&msgbox
, (UINT
)dwTime
);
879 SoftModalMessageBox(DWORD Unknown0
)
891 MessageBeep(UINT uType
)
899 if(waveOutGetNumDevs() == 0)
900 return Beep(500, 100); // Beep through speaker
903 EventName
= L
"SystemDefault";
905 case MB_ICONASTERISK
:
906 EventName
= L
"SystemAsterisk";
908 case MB_ICONEXCLAMATION
:
909 EventName
= L
"SystemExclamation";
912 EventName
= L
"SystemHand";
914 case MB_ICONQUESTION
:
915 EventName
= L
"SystemQuestion";
919 return PlaySoundW((LPCWSTR
)EventName
, NULL
, SND_ALIAS
| SND_NOWAIT
| SND_NOSTOP
| SND_ASYNC
);
921 return Beep(500, 100); // Beep through speaker
929 LPWSTR WINAPI
MB_GetString(DWORD string
)