a98c2ded40f8a06ad6db8aab5995ad4e02abddf1
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 ******************************************************************/
38 /* DEFINES *******************************************************************/
40 #define MSGBOX_IDICON (1088)
41 #define MSGBOX_IDTEXT (100)
43 #define IDI_HANDA MAKEINTRESOURCEA(32513)
44 #define IDI_HANDW MAKEINTRESOURCEW(32513)
45 #define IDI_QUESTIONA MAKEINTRESOURCEA(32514)
46 #define IDI_QUESTIONW MAKEINTRESOURCEW(32514)
47 #define IDI_EXCLAMATIONA MAKEINTRESOURCEA(32515)
48 #define IDI_EXCLAMATIONW MAKEINTRESOURCEW(32515)
49 #define IDI_ASTERISKA MAKEINTRESOURCEA(32516)
50 #define IDI_ASTERISKW MAKEINTRESOURCEW(32516)
51 #define IDI_WINLOGOA MAKEINTRESOURCEA(32517)
52 #define IDI_WINLOGOW MAKEINTRESOURCEW(32517)
55 #define MB_TYPEMASK 0x0000000F
58 #define MB_ICONMASK 0x000000F0
61 #define MB_DEFMASK 0x00000F00
67 #define MSGBOXEX_SPACING (16)
68 #define MSGBOXEX_BUTTONSPACING (6)
69 #define MSGBOXEX_MARGIN (12)
70 #define MSGBOXEX_MAXBTNSTR (32)
71 #define MSGBOXEX_MAXBTNS (4)
73 typedef struct _MSGBOXINFO
{
77 MSGBOXCALLBACK Callback
;
83 } MSGBOXINFO
, *PMSGBOXINFO
;
85 /* INTERNAL FUNCTIONS ********************************************************/
87 static INT_PTR CALLBACK
MessageBoxProc( HWND hwnd
, UINT message
,
88 WPARAM wParam
, LPARAM lParam
)
97 mbi
= (PMSGBOXINFO
)lParam
;
98 if(!GetPropW(hwnd
, L
"ROS_MSGBOX"))
100 SetPropW(hwnd
, L
"ROS_MSGBOX", (HANDLE
)lParam
);
102 SendDlgItemMessageW(hwnd
, MSGBOX_IDICON
, STM_SETICON
, (WPARAM
)mbi
->Icon
, 0);
103 SetWindowContextHelpId(hwnd
, mbi
->ContextHelpId
);
105 /* set control fonts */
106 SendDlgItemMessageW(hwnd
, MSGBOX_IDTEXT
, WM_SETFONT
, (WPARAM
)mbi
->Font
, 0);
107 for(i
= 0; i
< mbi
->nButtons
; i
++)
109 SendDlgItemMessageW(hwnd
, mbi
->Btns
[i
], WM_SETFONT
, (WPARAM
)mbi
->Font
, 0);
111 switch(mbi
->Style
& MB_TYPEMASK
)
113 case MB_ABORTRETRYIGNORE
:
115 RemoveMenu(GetSystemMenu(hwnd
, FALSE
), SC_CLOSE
, MF_BYCOMMAND
);
118 SetFocus(GetDlgItem(hwnd
, mbi
->DefBtn
));
119 if(mbi
->Timeout
&& (mbi
->Timeout
!= (UINT
)-1))
120 SetTimer(hwnd
, 0, mbi
->Timeout
, NULL
);
125 switch (LOWORD(wParam
))
136 EndDialog(hwnd
, wParam
);
139 /* send WM_HELP message to messagebox window */
140 hi
.cbSize
= sizeof(HELPINFO
);
141 hi
.iContextType
= HELPINFO_WINDOW
;
142 hi
.iCtrlId
= LOWORD(wParam
);
143 hi
.hItemHandle
= (HANDLE
)lParam
;
145 GetCursorPos(&hi
.MousePos
);
146 SendMessageW(hwnd
, WM_HELP
, 0, (LPARAM
)&hi
);
152 mbi
= (PMSGBOXINFO
)GetPropW(hwnd
, L
"ROS_MSGBOX");
155 memcpy(&hi
, (void *)lParam
, sizeof(hi
));
156 hi
.dwContextId
= GetWindowContextHelpId(hwnd
);
162 owner
= GetWindow(hwnd
, GW_OWNER
);
164 SendMessageW(GetWindow(hwnd
, GW_OWNER
), WM_HELP
, 0, (LPARAM
)&hi
);
169 mbi
= (PMSGBOXINFO
)GetPropW(hwnd
, L
"ROS_MSGBOX");
172 switch(mbi
->Style
& MB_TYPEMASK
)
174 case MB_ABORTRETRYIGNORE
:
178 EndDialog(hwnd
, IDCANCEL
);
184 EndDialog(hwnd
, 32000);
192 MessageBoxTimeoutIndirectW(
193 CONST MSGBOXPARAMSW
*lpMsgBoxParams
, UINT Timeout
)
196 DLGITEMTEMPLATE
*iico
, *itxt
;
197 NONCLIENTMETRICSW nclm
;
202 LPCWSTR caption
, text
;
206 int bufsize
, ret
, caplen
, textlen
, btnlen
, i
, btnleft
, btntop
, lmargin
, nButtons
= 0;
207 LONG Buttons
[MSGBOXEX_MAXBTNS
];
208 WCHAR ButtonText
[MSGBOXEX_MAXBTNS
][MSGBOXEX_MAXBTNSTR
];
209 DLGITEMTEMPLATE
*ibtn
[MSGBOXEX_MAXBTNS
];
210 RECT btnrect
, txtrect
, rc
;
214 DWORD units
= GetDialogBaseUnits();
216 hUser32
= GetModuleHandleW(L
"USER32");
218 if(!lpMsgBoxParams
->lpszCaption
|| !HIWORD((LPWSTR
)lpMsgBoxParams
->lpszCaption
))
220 LoadStringW(hUser32
, IDS_ERROR
, &capbuf
[0], 32);
221 caption
= &capbuf
[0];
224 caption
= (LPWSTR
)lpMsgBoxParams
->lpszCaption
;
226 if(!lpMsgBoxParams
->lpszText
|| !HIWORD(lpMsgBoxParams
->lpszText
))
229 text
= lpMsgBoxParams
->lpszText
;
231 caplen
= strlenW(caption
);
232 textlen
= strlenW(text
);
234 /* Create selected buttons */
235 switch(lpMsgBoxParams
->dwStyle
& MB_TYPEMASK
)
239 Buttons
[1] = IDCANCEL
;
242 case MB_CANCELTRYCONTINUE
:
243 Buttons
[0] = IDCANCEL
;
244 Buttons
[1] = IDTRYAGAIN
;
245 Buttons
[2] = IDCONTINUE
;
248 case MB_ABORTRETRYIGNORE
:
249 Buttons
[0] = IDABORT
;
250 Buttons
[1] = IDRETRY
;
251 Buttons
[2] = IDIGNORE
;
262 Buttons
[2] = IDCANCEL
;
266 Buttons
[0] = IDRETRY
;
267 Buttons
[1] = IDCANCEL
;
277 /* Create Help button */
278 if(lpMsgBoxParams
->dwStyle
& MB_HELP
)
279 Buttons
[nButtons
++] = IDHELP
;
281 switch(lpMsgBoxParams
->dwStyle
& MB_ICONMASK
)
283 case MB_ICONEXCLAMATION
:
284 Icon
= LoadIconW(0, IDI_EXCLAMATIONW
);
285 MessageBeep(MB_ICONEXCLAMATION
);
287 case MB_ICONQUESTION
:
288 Icon
= LoadIconW(0, IDI_QUESTIONW
);
289 MessageBeep(MB_ICONQUESTION
);
291 case MB_ICONASTERISK
:
292 Icon
= LoadIconW(0, IDI_ASTERISKW
);
293 MessageBeep(MB_ICONASTERISK
);
296 Icon
= LoadIconW(0, IDI_HANDW
);
297 MessageBeep(MB_ICONHAND
);
300 Icon
= LoadIconW(lpMsgBoxParams
->hInstance
, lpMsgBoxParams
->lpszIcon
);
304 /* By default, Windows 95/98/NT does not associate an icon to message boxes.
305 * So ReactOS should do the same.
313 bufsize
= sizeof(DLGTEMPLATE
) +
314 2 * sizeof(WORD
) + /* menu and class */
315 (caplen
+ 1) * sizeof(WCHAR
); /* title */
320 bufsize
= (bufsize
+ 3) & ~3;
321 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
327 bufsize
= (bufsize
+ 3) & ~3;
328 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
330 (textlen
+ 1) * sizeof(WCHAR
);
333 for(i
= 0; i
< nButtons
; i
++)
338 LoadStringW(hUser32
, IDS_OK
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
341 LoadStringW(hUser32
, IDS_CANCEL
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
344 LoadStringW(hUser32
, IDS_YES
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
347 LoadStringW(hUser32
, IDS_NO
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
350 LoadStringW(hUser32
, IDS_TRYAGAIN
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
353 LoadStringW(hUser32
, IDS_CONTINUE
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
356 LoadStringW(hUser32
, IDS_ABORT
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
359 LoadStringW(hUser32
, IDS_RETRY
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
362 LoadStringW(hUser32
, IDS_IGNORE
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
365 LoadStringW(hUser32
, IDS_HELP
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
368 ButtonText
[i
][0] = (WCHAR
)0;
372 /* Space for buttons */
373 bufsize
= (bufsize
+ 3) & ~3;
374 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
376 (wcslen(ButtonText
[i
]) + 1) * sizeof(WCHAR
);
379 buf
= RtlAllocateHeap(GetProcessHeap(), 0, bufsize
);
386 hDC
= CreateCompatibleDC(0);
388 nclm
.cbSize
= sizeof(nclm
);
389 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, sizeof(nclm
), &nclm
, 0);
390 hFont
= CreateFontIndirectW (&nclm
.lfMessageFont
);
392 tpl
= (DLGTEMPLATE
*)buf
;
394 tpl
->style
= WS_CAPTION
| WS_POPUP
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_SYSMENU
| DS_CENTER
| DS_MODALFRAME
| DS_NOIDLEMSG
;
395 tpl
->dwExtendedStyle
= WS_EX_DLGMODALFRAME
| WS_EX_WINDOWEDGE
| WS_EX_CONTROLPARENT
;
396 if(lpMsgBoxParams
->dwStyle
& MB_TOPMOST
)
397 tpl
->dwExtendedStyle
|= WS_EX_TOPMOST
;
398 if(lpMsgBoxParams
->dwStyle
& MB_RIGHT
)
399 tpl
->dwExtendedStyle
|= WS_EX_RIGHT
;
402 tpl
->cdit
= nButtons
+ ((Icon
!= (HICON
)0) ? 1 : 0) + 1;
404 dest
= (BYTE
*)(tpl
+ 1);
406 *(WORD
*)dest
= 0; /* no menu */
407 *(((WORD
*)dest
) + 1) = 0; /* use default window class */
408 dest
+= 2 * sizeof(WORD
);
409 memcpy(dest
, caption
, caplen
* sizeof(WCHAR
));
410 dest
+= caplen
* sizeof(WCHAR
);
411 *(WCHAR
*)dest
= L
'\0';
412 dest
+= sizeof(WCHAR
);
417 dest
= (BYTE
*)(((ULONG_PTR
)dest
+ 3) & ~3);
418 iico
= (DLGITEMTEMPLATE
*)dest
;
419 iico
->style
= WS_CHILD
| WS_VISIBLE
| SS_ICON
;
420 iico
->dwExtendedStyle
= 0;
421 iico
->id
= MSGBOX_IDICON
;
423 dest
+= sizeof(DLGITEMTEMPLATE
);
424 *(WORD
*)dest
= 0xFFFF;
425 dest
+= sizeof(WORD
);
426 *(WORD
*)dest
= 0x0082; /* static control */
427 dest
+= sizeof(WORD
);
428 *(WORD
*)dest
= 0xFFFF;
429 dest
+= sizeof(WORD
);
431 dest
+= sizeof(WCHAR
);
433 dest
+= sizeof(WORD
);
436 /* create static for text */
437 dest
= (BYTE
*)(((DWORD
)dest
+ 3) & ~3);
438 itxt
= (DLGITEMTEMPLATE
*)dest
;
439 itxt
->style
= WS_CHILD
| WS_VISIBLE
| SS_NOPREFIX
;
440 if(lpMsgBoxParams
->dwStyle
& MB_RIGHT
)
441 itxt
->style
|= SS_RIGHT
;
443 itxt
->style
|= SS_LEFT
;
444 itxt
->dwExtendedStyle
= 0;
445 itxt
->id
= MSGBOX_IDTEXT
;
446 dest
+= sizeof(DLGITEMTEMPLATE
);
447 *(WORD
*)dest
= 0xFFFF;
448 dest
+= sizeof(WORD
);
449 *(WORD
*)dest
= 0x0082; /* static control */
450 dest
+= sizeof(WORD
);
451 memcpy(dest
, text
, textlen
* sizeof(WCHAR
));
452 dest
+= textlen
* sizeof(WCHAR
);
454 dest
+= sizeof(WCHAR
);
456 dest
+= sizeof(WORD
);
461 btnrect
.left
= btnrect
.top
= 0;
462 for(i
= 0; i
< nButtons
; i
++)
464 dest
= (BYTE
*)(((DWORD
)dest
+ 3) & ~3);
465 ibtn
[i
] = (DLGITEMTEMPLATE
*)dest
;
466 ibtn
[i
]->style
= WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
;
467 if(!defbtn
&& (i
== ((lpMsgBoxParams
->dwStyle
& MB_DEFMASK
) >> 8)))
469 ibtn
[i
]->style
|= BS_DEFPUSHBUTTON
;
470 mbi
.DefBtn
= Buttons
[i
];
474 ibtn
[i
]->style
|= BS_PUSHBUTTON
;
475 ibtn
[i
]->dwExtendedStyle
= 0;
476 ibtn
[i
]->id
= Buttons
[i
];
477 dest
+= sizeof(DLGITEMTEMPLATE
);
478 *(WORD
*)dest
= 0xFFFF;
479 dest
+= sizeof(WORD
);
480 *(WORD
*)dest
= 0x0080; /* button control */
481 dest
+= sizeof(WORD
);
482 btnlen
= strlenW(ButtonText
[i
]);
483 memcpy(dest
, ButtonText
[i
], btnlen
* sizeof(WCHAR
));
484 dest
+= btnlen
* sizeof(WCHAR
);
486 dest
+= sizeof(WORD
);
488 dest
+= sizeof(WORD
);
489 SelectObject(hDC
, hFont
);
490 DrawTextW(hDC
, ButtonText
[i
], btnlen
, &btnrect
, DT_LEFT
| DT_SINGLELINE
| DT_CALCRECT
);
491 btnsize
.cx
= max(btnsize
.cx
, btnrect
.right
);
492 btnsize
.cy
= max(btnsize
.cy
, btnrect
.bottom
);
495 /* make first button the default button if no other is */
498 ibtn
[0]->style
&= ~BS_PUSHBUTTON
;
499 ibtn
[0]->style
|= BS_DEFPUSHBUTTON
;
500 mbi
.DefBtn
= Buttons
[0];
503 /* calculate position and size of controls */
504 txtrect
.right
= GetSystemMetrics(SM_CXSCREEN
) / 5 * 4;
506 txtrect
.right
-= GetSystemMetrics(SM_CXICON
) + MSGBOXEX_SPACING
;
507 txtrect
.top
= txtrect
.left
= txtrect
.bottom
= 0;
508 SelectObject(hDC
, hFont
);
509 DrawTextW(hDC
, text
, textlen
, &txtrect
, DT_LEFT
| DT_NOPREFIX
| DT_WORDBREAK
| DT_CALCRECT
);
512 /* calculate position and size of the icon */
513 rc
.left
= rc
.bottom
= rc
.right
= 0;
518 rc
.right
= GetSystemMetrics(SM_CXICON
);
519 rc
.bottom
= GetSystemMetrics(SM_CYICON
);
520 #ifdef MSGBOX_ICONVCENTER
521 rc
.top
= MSGBOXEX_MARGIN
+ (max(txtrect
.bottom
, rc
.bottom
) / 2) - (GetSystemMetrics(SM_CYICON
) / 2);
522 rc
.top
= max(MSGBOXEX_SPACING
, rc
.top
);
524 rc
.top
= MSGBOXEX_MARGIN
;
526 btnleft
= (nButtons
* (btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
)) - MSGBOXEX_BUTTONSPACING
;
527 if(btnleft
> txtrect
.right
+ rc
.right
+ MSGBOXEX_SPACING
)
529 #ifdef MSGBOX_TEXTHCENTER
530 lmargin
= MSGBOXEX_MARGIN
+ ((btnleft
- txtrect
.right
- rc
.right
- MSGBOXEX_SPACING
) / 2);
532 lmargin
= MSGBOXEX_MARGIN
;
534 btnleft
= MSGBOXEX_MARGIN
;
538 lmargin
= MSGBOXEX_MARGIN
;
539 btnleft
= MSGBOXEX_MARGIN
+ ((txtrect
.right
+ rc
.right
+ MSGBOXEX_SPACING
) / 2) - (btnleft
/ 2);
542 iico
->x
= (rc
.left
* 4) / LOWORD(units
);
543 iico
->y
= (rc
.top
* 8) / HIWORD(units
);
544 iico
->cx
= (rc
.right
* 4) / LOWORD(units
);
545 iico
->cy
= (rc
.bottom
* 8) / HIWORD(units
);
546 btntop
= rc
.top
+ rc
.bottom
+ MSGBOXEX_SPACING
;
547 rc
.left
+= rc
.right
+ MSGBOXEX_SPACING
;
551 btnleft
= (nButtons
* (btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
)) - MSGBOXEX_BUTTONSPACING
;
552 if(btnleft
> txtrect
.right
)
554 #ifdef MSGBOX_TEXTHCENTER
555 lmargin
= MSGBOXEX_MARGIN
+ ((btnleft
- txtrect
.right
) / 2);
557 lmargin
= MSGBOXEX_MARGIN
;
559 btnleft
= MSGBOXEX_MARGIN
;
563 lmargin
= MSGBOXEX_MARGIN
;
564 btnleft
= MSGBOXEX_MARGIN
+ (txtrect
.right
/ 2) - (btnleft
/ 2);
568 /* calculate position of the text */
569 rc
.top
= MSGBOXEX_MARGIN
+ (rc
.bottom
/ 2) - (txtrect
.bottom
/ 2);
570 rc
.top
= max(rc
.top
, MSGBOXEX_MARGIN
);
571 /* calculate position of the buttons */
572 btntop
= max(rc
.top
+ txtrect
.bottom
+ MSGBOXEX_SPACING
, btntop
);
573 for(i
= 0; i
< nButtons
; i
++)
575 ibtn
[i
]->x
= (btnleft
* 4) / LOWORD(units
);
576 ibtn
[i
]->y
= (btntop
* 8) / HIWORD(units
);
577 ibtn
[i
]->cx
= (btnsize
.cx
* 4) / LOWORD(units
);
578 ibtn
[i
]->cy
= (btnsize
.cy
* 8) / HIWORD(units
);
579 btnleft
+= btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
;
581 /* calculate size and position of the messagebox window */
582 btnleft
= max(btnleft
- MSGBOXEX_BUTTONSPACING
, rc
.left
+ txtrect
.right
);
583 btnleft
+= MSGBOXEX_MARGIN
;
584 btntop
+= btnsize
.cy
+ MSGBOXEX_MARGIN
;
585 /* set size and position of the message static */
586 itxt
->x
= (rc
.left
* 4) / LOWORD(units
);
587 itxt
->y
= (rc
.top
* 8) / HIWORD(units
);
588 itxt
->cx
= (((btnleft
- rc
.left
- MSGBOXEX_MARGIN
) * 4) / LOWORD(units
));
589 itxt
->cy
= ((txtrect
.bottom
* 8) / HIWORD(units
));
590 /* set size of the window */
591 tpl
->cx
= (btnleft
* 4) / LOWORD(units
);
592 tpl
->cy
= (btntop
* 8) / HIWORD(units
);
594 /* finally show the messagebox */
597 mbi
.ContextHelpId
= lpMsgBoxParams
->dwContextHelpId
;
598 mbi
.Callback
= lpMsgBoxParams
->lpfnMsgBoxCallback
;
599 mbi
.Style
= lpMsgBoxParams
->dwStyle
;
600 mbi
.nButtons
= nButtons
;
601 mbi
.Btns
= &Buttons
[0];
602 mbi
.Timeout
= Timeout
;
607 ret
= DialogBoxIndirectParamW(lpMsgBoxParams
->hInstance
, tpl
, lpMsgBoxParams
->hwndOwner
,
608 MessageBoxProc
, (LPARAM
)&mbi
);
613 RtlFreeHeap(GetProcessHeap(), 0, buf
);
617 /* FUNCTIONS *****************************************************************/
631 return MessageBoxExA(hWnd
, lpText
, lpCaption
, uType
, LANG_NEUTRAL
);
647 MSGBOXPARAMSA msgbox
;
649 msgbox
.cbSize
= sizeof(msgbox
);
650 msgbox
.hwndOwner
= hWnd
;
651 msgbox
.hInstance
= 0;
652 msgbox
.lpszText
= lpText
;
653 msgbox
.lpszCaption
= lpCaption
;
654 msgbox
.dwStyle
= uType
;
655 msgbox
.lpszIcon
= NULL
;
656 msgbox
.dwContextHelpId
= 0;
657 msgbox
.lpfnMsgBoxCallback
= NULL
;
658 msgbox
.dwLanguageId
= wLanguageId
;
660 return MessageBoxIndirectA(&msgbox
);
676 MSGBOXPARAMSW msgbox
;
678 msgbox
.cbSize
= sizeof(msgbox
);
679 msgbox
.hwndOwner
= hWnd
;
680 msgbox
.hInstance
= 0;
681 msgbox
.lpszText
= lpText
;
682 msgbox
.lpszCaption
= lpCaption
;
683 msgbox
.dwStyle
= uType
;
684 msgbox
.lpszIcon
= NULL
;
685 msgbox
.dwContextHelpId
= 0;
686 msgbox
.lpfnMsgBoxCallback
= NULL
;
687 msgbox
.dwLanguageId
= wLanguageId
;
689 return MessageBoxTimeoutIndirectW(&msgbox
, (UINT
)-1);
699 CONST MSGBOXPARAMSA
*lpMsgBoxParams
)
701 MSGBOXPARAMSW msgboxW
;
702 UNICODE_STRING textW
, captionW
, iconW
;
705 if (HIWORD((UINT
)lpMsgBoxParams
->lpszText
))
707 RtlCreateUnicodeStringFromAsciiz(&textW
, (PCSZ
)lpMsgBoxParams
->lpszText
);
709 * UNICODE_STRING objects are always allocated with an extra byte so you
710 * can null-term if you want
712 textW
.Buffer
[textW
.Length
/ sizeof(WCHAR
)] = L
'\0';
715 textW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszText
;
717 if (HIWORD((UINT
)lpMsgBoxParams
->lpszCaption
))
719 RtlCreateUnicodeStringFromAsciiz(&captionW
, (PCSZ
)lpMsgBoxParams
->lpszCaption
);
721 * UNICODE_STRING objects are always allocated with an extra byte so you
722 * can null-term if you want
724 captionW
.Buffer
[captionW
.Length
/ sizeof(WCHAR
)] = L
'\0';
727 captionW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszCaption
;
729 if(lpMsgBoxParams
->dwStyle
& MB_USERICON
)
731 if (HIWORD((UINT
)lpMsgBoxParams
->lpszIcon
))
733 RtlCreateUnicodeStringFromAsciiz(&iconW
, (PCSZ
)lpMsgBoxParams
->lpszIcon
);
735 * UNICODE_STRING objects are always allocated with an extra byte so you
736 * can null-term if you want
738 iconW
.Buffer
[iconW
.Length
/ sizeof(WCHAR
)] = L
'\0';
741 iconW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszIcon
;
746 msgboxW
.cbSize
= sizeof(msgboxW
);
747 msgboxW
.hwndOwner
= lpMsgBoxParams
->hwndOwner
;
748 msgboxW
.hInstance
= lpMsgBoxParams
->hInstance
;
749 msgboxW
.lpszText
= textW
.Buffer
;
750 msgboxW
.lpszCaption
= captionW
.Buffer
;
751 msgboxW
.dwStyle
= lpMsgBoxParams
->dwStyle
;
752 msgboxW
.lpszIcon
= iconW
.Buffer
;
753 msgboxW
.dwContextHelpId
= lpMsgBoxParams
->dwContextHelpId
;
754 msgboxW
.lpfnMsgBoxCallback
= lpMsgBoxParams
->lpfnMsgBoxCallback
;
755 msgboxW
.dwLanguageId
= lpMsgBoxParams
->dwLanguageId
;
757 ret
= MessageBoxTimeoutIndirectW(&msgboxW
, (UINT
)-1);
759 if (HIWORD((UINT
)lpMsgBoxParams
->lpszText
))
760 RtlFreeUnicodeString(&textW
);
762 if (HIWORD((UINT
)lpMsgBoxParams
->lpszCaption
))
763 RtlFreeUnicodeString(&captionW
);
765 if ((lpMsgBoxParams
->dwStyle
& MB_USERICON
) && HIWORD((UINT
)iconW
.Buffer
))
766 RtlFreeUnicodeString(&iconW
);
778 CONST MSGBOXPARAMSW
*lpMsgBoxParams
)
780 return MessageBoxTimeoutIndirectW(lpMsgBoxParams
, (UINT
)-1);
795 return MessageBoxExW(hWnd
, lpText
, lpCaption
, uType
, LANG_NEUTRAL
);
811 MSGBOXPARAMSW msgboxW
;
812 UNICODE_STRING textW
, captionW
;
815 if (HIWORD((UINT
)lpText
))
816 RtlCreateUnicodeStringFromAsciiz(&textW
, (PCSZ
)lpText
);
818 textW
.Buffer
= (LPWSTR
)lpText
;
820 if (HIWORD((UINT
)lpCaption
))
821 RtlCreateUnicodeStringFromAsciiz(&captionW
, (PCSZ
)lpCaption
);
823 captionW
.Buffer
= (LPWSTR
)lpCaption
;
825 msgboxW
.cbSize
= sizeof(msgboxW
);
826 msgboxW
.hwndOwner
= hWnd
;
827 msgboxW
.hInstance
= 0;
828 msgboxW
.lpszText
= textW
.Buffer
;
829 msgboxW
.lpszCaption
= captionW
.Buffer
;
830 msgboxW
.dwStyle
= uType
;
831 msgboxW
.lpszIcon
= NULL
;
832 msgboxW
.dwContextHelpId
= 0;
833 msgboxW
.lpfnMsgBoxCallback
= NULL
;
834 msgboxW
.dwLanguageId
= wLanguageId
;
836 ret
= MessageBoxTimeoutIndirectW(&msgboxW
, (UINT
)dwTime
);
838 if (HIWORD(textW
.Buffer
))
839 RtlFreeUnicodeString(&textW
);
841 if (HIWORD(captionW
.Buffer
))
842 RtlFreeUnicodeString(&captionW
);
860 MSGBOXPARAMSW msgbox
;
862 msgbox
.cbSize
= sizeof(msgbox
);
863 msgbox
.hwndOwner
= hWnd
;
864 msgbox
.hInstance
= 0;
865 msgbox
.lpszText
= lpText
;
866 msgbox
.lpszCaption
= lpCaption
;
867 msgbox
.dwStyle
= uType
;
868 msgbox
.lpszIcon
= NULL
;
869 msgbox
.dwContextHelpId
= 0;
870 msgbox
.lpfnMsgBoxCallback
= NULL
;
871 msgbox
.dwLanguageId
= wLanguageId
;
873 return MessageBoxTimeoutIndirectW(&msgbox
, (UINT
)dwTime
);
882 SoftModalMessageBox(DWORD Unknown0
)
894 MessageBeep(UINT uType
)
902 if(waveOutGetNumDevs() == 0)
903 return Beep(500, 100); // Beep through speaker
906 EventName
= L
"SystemDefault";
908 case MB_ICONASTERISK
:
909 EventName
= L
"SystemAsterisk";
911 case MB_ICONEXCLAMATION
:
912 EventName
= L
"SystemExclamation";
915 EventName
= L
"SystemHand";
917 case MB_ICONQUESTION
:
918 EventName
= L
"SystemQuestion";
922 return PlaySoundW((LPCWSTR
)EventName
, NULL
, SND_ALIAS
| SND_NOWAIT
| SND_NOSTOP
| SND_ASYNC
);
924 return Beep(500, 100); // Beep through speaker