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.27 2004/08/15 21:36:30 chorns 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);
204 #define SAFETY_MARGIN 32 /* Extra number of bytes to allocate in case we counted wrong */
206 MessageBoxTimeoutIndirectW(
207 CONST MSGBOXPARAMS
*lpMsgBoxParams
, UINT Timeout
)
210 DLGITEMTEMPLATE
*iico
, *itxt
;
211 NONCLIENTMETRICSW nclm
;
216 LPWSTR caption
, text
;
220 int bufsize
, ret
, caplen
, textlen
, btnlen
, i
, btnleft
, btntop
, lmargin
, nButtons
= 0;
221 LONG Buttons
[MSGBOXEX_MAXBTNS
];
222 WCHAR ButtonText
[MSGBOXEX_MAXBTNS
][MSGBOXEX_MAXBTNSTR
];
223 DLGITEMTEMPLATE
*ibtn
[MSGBOXEX_MAXBTNS
];
224 RECT btnrect
, txtrect
, rc
;
228 DWORD units
= GetDialogBaseUnits();
230 hUser32
= GetModuleHandleW(L
"USER32");
232 if(!lpMsgBoxParams
->lpszCaption
|| !HIWORD((LPWSTR
)lpMsgBoxParams
->lpszCaption
))
234 LoadStringW(hUser32
, IDS_ERROR
, &capbuf
[0], 32);
235 caption
= &capbuf
[0];
238 caption
= (LPWSTR
)lpMsgBoxParams
->lpszCaption
;
240 if(!lpMsgBoxParams
->lpszText
|| !HIWORD((LPWSTR
)lpMsgBoxParams
->lpszText
))
243 text
= (LPWSTR
)lpMsgBoxParams
->lpszText
;
245 caplen
= strlenW(caption
);
246 textlen
= strlenW(text
);
248 /* Create selected buttons */
249 switch(lpMsgBoxParams
->dwStyle
& MB_TYPEMASK
)
253 Buttons
[1] = IDCANCEL
;
256 case MB_CANCELTRYCONTINUE
:
257 Buttons
[0] = IDCANCEL
;
258 Buttons
[1] = IDTRYAGAIN
;
259 Buttons
[2] = IDCONTINUE
;
262 case MB_ABORTRETRYIGNORE
:
263 Buttons
[0] = IDABORT
;
264 Buttons
[1] = IDRETRY
;
265 Buttons
[2] = IDIGNORE
;
276 Buttons
[2] = IDCANCEL
;
280 Buttons
[0] = IDRETRY
;
281 Buttons
[1] = IDCANCEL
;
291 /* Create Help button */
292 if(lpMsgBoxParams
->dwStyle
& MB_HELP
)
293 Buttons
[nButtons
++] = IDHELP
;
295 switch(lpMsgBoxParams
->dwStyle
& MB_ICONMASK
)
297 case MB_ICONEXCLAMATION
:
298 Icon
= LoadIconW(0, IDI_EXCLAMATIONW
);
299 MessageBeep(MB_ICONEXCLAMATION
);
301 case MB_ICONQUESTION
:
302 Icon
= LoadIconW(0, IDI_QUESTIONW
);
303 MessageBeep(MB_ICONQUESTION
);
305 case MB_ICONASTERISK
:
306 Icon
= LoadIconW(0, IDI_ASTERISKW
);
307 MessageBeep(MB_ICONASTERISK
);
310 Icon
= LoadIconW(0, IDI_HANDW
);
311 MessageBeep(MB_ICONHAND
);
314 Icon
= LoadIconW(lpMsgBoxParams
->hInstance
, (LPCWSTR
)lpMsgBoxParams
->lpszIcon
);
318 /* By default, Windows 95/98/NT does not associate an icon to message boxes.
319 * So ReactOS should do the same.
327 bufsize
= sizeof(DLGTEMPLATE
) +
328 2 * sizeof(WORD
) + /* menu and class */
329 (caplen
+ 1) * sizeof(WCHAR
); /* title */
334 bufsize
= (bufsize
+ 3) & ~3;
335 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
341 bufsize
= (bufsize
+ 3) & ~3;
342 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
344 (textlen
+ 1) * sizeof(WCHAR
);
347 for(i
= 0; i
< nButtons
; i
++)
352 LoadStringW(hUser32
, IDS_OK
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
355 LoadStringW(hUser32
, IDS_CANCEL
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
358 LoadStringW(hUser32
, IDS_YES
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
361 LoadStringW(hUser32
, IDS_NO
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
364 LoadStringW(hUser32
, IDS_TRYAGAIN
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
367 LoadStringW(hUser32
, IDS_CONTINUE
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
370 LoadStringW(hUser32
, IDS_ABORT
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
373 LoadStringW(hUser32
, IDS_RETRY
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
376 LoadStringW(hUser32
, IDS_IGNORE
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
379 LoadStringW(hUser32
, IDS_HELP
, ButtonText
[i
], MSGBOXEX_MAXBTNSTR
- 1);
382 ButtonText
[i
][0] = (WCHAR
)0;
386 /* Space for buttons */
387 bufsize
= (bufsize
+ 3) & ~3;
388 bufsize
+= sizeof(DLGITEMTEMPLATE
) +
390 (wcslen(ButtonText
[i
]) + 1) * sizeof(WCHAR
);
393 buf
= RtlAllocateHeap(GetProcessHeap(), 0, bufsize
+ SAFETY_MARGIN
);
394 /* Just to be safe.... */
401 hDC
= CreateCompatibleDC(0);
403 nclm
.cbSize
= sizeof(nclm
);
404 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, sizeof(nclm
), &nclm
, 0);
405 hFont
= CreateFontIndirectW (&nclm
.lfMessageFont
);
407 tpl
= (DLGTEMPLATE
*)buf
;
409 tpl
->style
= WS_CAPTION
| WS_POPUP
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_SYSMENU
| DS_CENTER
| DS_MODALFRAME
| DS_NOIDLEMSG
;
410 tpl
->dwExtendedStyle
= WS_EX_DLGMODALFRAME
| WS_EX_WINDOWEDGE
| WS_EX_CONTROLPARENT
;
411 if(lpMsgBoxParams
->dwStyle
& MB_TOPMOST
)
412 tpl
->dwExtendedStyle
|= WS_EX_TOPMOST
;
413 if(lpMsgBoxParams
->dwStyle
& MB_RIGHT
)
414 tpl
->dwExtendedStyle
|= WS_EX_RIGHT
;
417 tpl
->cdit
= nButtons
+ (Icon
!= (HICON
)0) + 1;
419 dest
= (BYTE
*)(tpl
+ 1);
421 *(WORD
*)dest
= 0; /* no menu */
422 *(((WORD
*)dest
) + 1) = 0; /* use default window class */
423 dest
+= 2 * sizeof(WORD
);
424 memcpy(dest
, caption
, caplen
* sizeof(WCHAR
));
425 dest
+= caplen
* sizeof(WCHAR
);
426 *(WCHAR
*)dest
= L
'\0';
427 dest
+= sizeof(WCHAR
);
432 dest
= (BYTE
*)(((ULONG_PTR
)dest
+ 3) & ~3);
433 iico
= (DLGITEMTEMPLATE
*)dest
;
434 iico
->style
= WS_CHILD
| WS_VISIBLE
| SS_ICON
;
435 iico
->dwExtendedStyle
= 0;
436 iico
->id
= MSGBOX_IDICON
;
438 dest
+= sizeof(DLGITEMTEMPLATE
);
439 *(WORD
*)dest
= 0xFFFF;
440 dest
+= sizeof(WORD
);
441 *(WORD
*)dest
= 0x0082; /* static control */
442 dest
+= sizeof(WORD
);
443 *(WORD
*)dest
= 0xFFFF;
444 dest
+= sizeof(WORD
);
446 dest
+= sizeof(WCHAR
);
448 dest
+= sizeof(WORD
);
451 /* create static for text */
452 dest
= (BYTE
*)(((DWORD
)dest
+ 3) & ~3);
453 itxt
= (DLGITEMTEMPLATE
*)dest
;
454 itxt
->style
= WS_CHILD
| WS_VISIBLE
| SS_NOPREFIX
;
455 if(lpMsgBoxParams
->dwStyle
& MB_RIGHT
)
456 itxt
->style
|= SS_RIGHT
;
458 itxt
->style
|= SS_LEFT
;
459 itxt
->dwExtendedStyle
= 0;
460 itxt
->id
= MSGBOX_IDTEXT
;
461 dest
+= sizeof(DLGITEMTEMPLATE
);
462 *(WORD
*)dest
= 0xFFFF;
463 dest
+= sizeof(WORD
);
464 *(WORD
*)dest
= 0x0082; /* static control */
465 dest
+= sizeof(WORD
);
466 memcpy(dest
, text
, textlen
* sizeof(WCHAR
));
467 dest
+= textlen
* sizeof(WCHAR
);
469 dest
+= sizeof(WCHAR
);
471 dest
+= sizeof(WORD
);
476 btnrect
.left
= btnrect
.top
= 0;
477 for(i
= 0; i
< nButtons
; i
++)
479 dest
= (BYTE
*)(((DWORD
)dest
+ 3) & ~3);
480 ibtn
[i
] = (DLGITEMTEMPLATE
*)dest
;
481 ibtn
[i
]->style
= WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
;
482 if(!defbtn
&& (i
== ((lpMsgBoxParams
->dwStyle
& MB_DEFMASK
) >> 8)))
484 ibtn
[i
]->style
|= BS_DEFPUSHBUTTON
;
485 mbi
.DefBtn
= Buttons
[i
];
489 ibtn
[i
]->style
|= BS_PUSHBUTTON
;
490 ibtn
[i
]->dwExtendedStyle
= 0;
491 ibtn
[i
]->id
= Buttons
[i
];
492 dest
+= sizeof(DLGITEMTEMPLATE
);
493 *(WORD
*)dest
= 0xFFFF;
494 dest
+= sizeof(WORD
);
495 *(WORD
*)dest
= 0x0080; /* button control */
496 dest
+= sizeof(WORD
);
497 btnlen
= strlenW(ButtonText
[i
]);
498 memcpy(dest
, ButtonText
[i
], btnlen
* sizeof(WCHAR
));
499 dest
+= btnlen
* sizeof(WCHAR
);
501 dest
+= sizeof(WORD
);
503 dest
+= sizeof(WORD
);
504 SelectObject(hDC
, hFont
);
505 DrawTextW(hDC
, ButtonText
[i
], btnlen
, &btnrect
, DT_LEFT
| DT_SINGLELINE
| DT_CALCRECT
);
506 btnsize
.cx
= max(btnsize
.cx
, btnrect
.right
);
507 btnsize
.cy
= max(btnsize
.cy
, btnrect
.bottom
);
510 if ((ULONG_PTR
) dest
!= ((ULONG_PTR
) buf
+ (ULONG_PTR
) bufsize
))
512 DbgPrint("Tell GvG he can't count: bufsize is %lu, but should be %lu\n", bufsize
, (ULONG_PTR
) dest
- (ULONG_PTR
) buf
);
515 /* make first button the default button if no other is */
518 ibtn
[0]->style
&= ~BS_PUSHBUTTON
;
519 ibtn
[0]->style
|= BS_DEFPUSHBUTTON
;
520 mbi
.DefBtn
= Buttons
[0];
523 /* calculate position and size of controls */
524 txtrect
.right
= GetSystemMetrics(SM_CXSCREEN
) / 5 * 4;
526 txtrect
.right
-= GetSystemMetrics(SM_CXICON
) + MSGBOXEX_SPACING
;
527 txtrect
.top
= txtrect
.left
= txtrect
.bottom
= 0;
528 SelectObject(hDC
, hFont
);
529 DrawTextW(hDC
, text
, textlen
, &txtrect
, DT_LEFT
| DT_NOPREFIX
| DT_WORDBREAK
| DT_CALCRECT
);
532 /* calculate position and size of the icon */
533 rc
.left
= rc
.bottom
= rc
.right
= 0;
538 rc
.right
= GetSystemMetrics(SM_CXICON
);
539 rc
.bottom
= GetSystemMetrics(SM_CYICON
);
540 #ifdef MSGBOX_ICONVCENTER
541 rc
.top
= MSGBOXEX_MARGIN
+ (max(txtrect
.bottom
, rc
.bottom
) / 2) - (GetSystemMetrics(SM_CYICON
) / 2);
542 rc
.top
= max(MSGBOXEX_SPACING
, rc
.top
);
544 rc
.top
= MSGBOXEX_MARGIN
;
546 btnleft
= (nButtons
* (btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
)) - MSGBOXEX_BUTTONSPACING
;
547 if(btnleft
> txtrect
.right
+ rc
.right
+ MSGBOXEX_SPACING
)
549 #ifdef MSGBOX_TEXTHCENTER
550 lmargin
= MSGBOXEX_MARGIN
+ ((btnleft
- txtrect
.right
- rc
.right
- MSGBOXEX_SPACING
) / 2);
552 lmargin
= MSGBOXEX_MARGIN
;
554 btnleft
= MSGBOXEX_MARGIN
;
558 lmargin
= MSGBOXEX_MARGIN
;
559 btnleft
= MSGBOXEX_MARGIN
+ ((txtrect
.right
+ rc
.right
+ MSGBOXEX_SPACING
) / 2) - (btnleft
/ 2);
562 iico
->x
= (rc
.left
* 4) / LOWORD(units
);
563 iico
->y
= (rc
.top
* 8) / HIWORD(units
);
564 iico
->cx
= (rc
.right
* 4) / LOWORD(units
);
565 iico
->cy
= (rc
.bottom
* 8) / HIWORD(units
);
566 btntop
= rc
.top
+ rc
.bottom
+ MSGBOXEX_SPACING
;
567 rc
.left
+= rc
.right
+ MSGBOXEX_SPACING
;
571 btnleft
= (nButtons
* (btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
)) - MSGBOXEX_BUTTONSPACING
;
572 if(btnleft
> txtrect
.right
)
574 #ifdef MSGBOX_TEXTHCENTER
575 lmargin
= MSGBOXEX_MARGIN
+ ((btnleft
- txtrect
.right
) / 2);
577 lmargin
= MSGBOXEX_MARGIN
;
579 btnleft
= MSGBOXEX_MARGIN
;
583 lmargin
= MSGBOXEX_MARGIN
;
584 btnleft
= MSGBOXEX_MARGIN
+ (txtrect
.right
/ 2) - (btnleft
/ 2);
588 /* calculate position of the text */
589 rc
.top
= MSGBOXEX_MARGIN
+ (rc
.bottom
/ 2) - (txtrect
.bottom
/ 2);
590 rc
.top
= max(rc
.top
, MSGBOXEX_MARGIN
);
591 /* calculate position of the buttons */
592 btntop
= max(rc
.top
+ txtrect
.bottom
+ MSGBOXEX_SPACING
, btntop
);
593 for(i
= 0; i
< nButtons
; i
++)
595 ibtn
[i
]->x
= (btnleft
* 4) / LOWORD(units
);
596 ibtn
[i
]->y
= (btntop
* 8) / HIWORD(units
);
597 ibtn
[i
]->cx
= (btnsize
.cx
* 4) / LOWORD(units
);
598 ibtn
[i
]->cy
= (btnsize
.cy
* 8) / HIWORD(units
);
599 btnleft
+= btnsize
.cx
+ MSGBOXEX_BUTTONSPACING
;
601 /* calculate size and position of the messagebox window */
602 btnleft
= max(btnleft
- MSGBOXEX_BUTTONSPACING
, rc
.left
+ txtrect
.right
);
603 btnleft
+= MSGBOXEX_MARGIN
;
604 btntop
+= btnsize
.cy
+ MSGBOXEX_MARGIN
;
605 /* set size and position of the message static */
606 itxt
->x
= (rc
.left
* 4) / LOWORD(units
);
607 itxt
->y
= (rc
.top
* 8) / HIWORD(units
);
608 itxt
->cx
= (((btnleft
- rc
.left
- MSGBOXEX_MARGIN
) * 4) / LOWORD(units
));
609 itxt
->cy
= ((txtrect
.bottom
* 8) / HIWORD(units
));
610 /* set size of the window */
611 tpl
->cx
= (btnleft
* 4) / LOWORD(units
);
612 tpl
->cy
= (btntop
* 8) / HIWORD(units
);
614 /* finally show the messagebox */
617 mbi
.ContextHelpId
= lpMsgBoxParams
->dwContextHelpId
;
618 mbi
.Callback
= lpMsgBoxParams
->lpfnMsgBoxCallback
;
619 mbi
.Style
= lpMsgBoxParams
->dwStyle
;
620 mbi
.nButtons
= nButtons
;
621 mbi
.Btns
= &Buttons
[0];
622 mbi
.Timeout
= Timeout
;
627 ret
= DialogBoxIndirectParamW(lpMsgBoxParams
->hInstance
, tpl
, lpMsgBoxParams
->hwndOwner
,
628 MessageBoxProc
, (LPARAM
)&mbi
);
633 RtlFreeHeap(GetProcessHeap(), 0, buf
);
637 /* FUNCTIONS *****************************************************************/
651 return MessageBoxExA(hWnd
, lpText
, lpCaption
, uType
, LANG_NEUTRAL
);
667 MSGBOXPARAMSA msgbox
;
669 msgbox
.cbSize
= sizeof(msgbox
);
670 msgbox
.hwndOwner
= hWnd
;
671 msgbox
.hInstance
= 0;
672 msgbox
.lpszText
= lpText
;
673 msgbox
.lpszCaption
= lpCaption
;
674 msgbox
.dwStyle
= uType
;
675 msgbox
.lpszIcon
= NULL
;
676 msgbox
.dwContextHelpId
= 0;
677 msgbox
.lpfnMsgBoxCallback
= NULL
;
678 msgbox
.dwLanguageId
= wLanguageId
;
680 return MessageBoxIndirectA(&msgbox
);
696 MSGBOXPARAMSW msgbox
;
698 msgbox
.cbSize
= sizeof(msgbox
);
699 msgbox
.hwndOwner
= hWnd
;
700 msgbox
.hInstance
= 0;
701 msgbox
.lpszText
= lpText
;
702 msgbox
.lpszCaption
= lpCaption
;
703 msgbox
.dwStyle
= uType
;
704 msgbox
.lpszIcon
= NULL
;
705 msgbox
.dwContextHelpId
= 0;
706 msgbox
.lpfnMsgBoxCallback
= NULL
;
707 msgbox
.dwLanguageId
= wLanguageId
;
709 return MessageBoxTimeoutIndirectW(&msgbox
, (UINT
)-1);
719 CONST MSGBOXPARAMSA
*lpMsgBoxParams
)
721 MSGBOXPARAMSW msgboxW
;
722 UNICODE_STRING textW
, captionW
, iconW
;
725 if (HIWORD((UINT
)lpMsgBoxParams
->lpszText
))
727 RtlCreateUnicodeStringFromAsciiz(&textW
, (PCSZ
)lpMsgBoxParams
->lpszText
);
729 * UNICODE_STRING objects are always allocated with an extra byte so you
730 * can null-term if you want
732 textW
.Buffer
[textW
.Length
/ sizeof(WCHAR
)] = L
'\0';
735 textW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszText
;
737 if (HIWORD((UINT
)lpMsgBoxParams
->lpszCaption
))
739 RtlCreateUnicodeStringFromAsciiz(&captionW
, (PCSZ
)lpMsgBoxParams
->lpszCaption
);
741 * UNICODE_STRING objects are always allocated with an extra byte so you
742 * can null-term if you want
744 captionW
.Buffer
[captionW
.Length
/ sizeof(WCHAR
)] = L
'\0';
747 captionW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszCaption
;
749 if (HIWORD((UINT
)lpMsgBoxParams
->lpszIcon
))
751 RtlCreateUnicodeStringFromAsciiz(&iconW
, (PCSZ
)lpMsgBoxParams
->lpszIcon
);
753 * UNICODE_STRING objects are always allocated with an extra byte so you
754 * can null-term if you want
756 iconW
.Buffer
[iconW
.Length
/ sizeof(WCHAR
)] = L
'\0';
759 iconW
.Buffer
= (LPWSTR
)lpMsgBoxParams
->lpszIcon
;
761 msgboxW
.cbSize
= sizeof(msgboxW
);
762 msgboxW
.hwndOwner
= lpMsgBoxParams
->hwndOwner
;
763 msgboxW
.hInstance
= lpMsgBoxParams
->hInstance
;
764 msgboxW
.lpszText
= textW
.Buffer
;
765 msgboxW
.lpszCaption
= captionW
.Buffer
;
766 msgboxW
.dwStyle
= lpMsgBoxParams
->dwStyle
;
767 msgboxW
.lpszIcon
= iconW
.Buffer
;
768 msgboxW
.dwContextHelpId
= lpMsgBoxParams
->dwContextHelpId
;
769 msgboxW
.lpfnMsgBoxCallback
= lpMsgBoxParams
->lpfnMsgBoxCallback
;
770 msgboxW
.dwLanguageId
= lpMsgBoxParams
->dwLanguageId
;
772 ret
= MessageBoxTimeoutIndirectW(&msgboxW
, (UINT
)-1);
774 if (HIWORD((UINT
)lpMsgBoxParams
->lpszText
))
775 RtlFreeUnicodeString(&textW
);
777 if (HIWORD((UINT
)lpMsgBoxParams
->lpszCaption
))
778 RtlFreeUnicodeString(&captionW
);
780 if (HIWORD((UINT
)lpMsgBoxParams
->lpszIcon
))
781 RtlFreeUnicodeString(&iconW
);
793 CONST MSGBOXPARAMSW
*lpMsgBoxParams
)
795 return MessageBoxTimeoutIndirectW(lpMsgBoxParams
, (UINT
)-1);
810 return MessageBoxExW(hWnd
, lpText
, lpCaption
, uType
, LANG_NEUTRAL
);
826 MSGBOXPARAMSW msgboxW
;
827 UNICODE_STRING textW
, captionW
;
830 if (HIWORD((UINT
)lpText
))
831 RtlCreateUnicodeStringFromAsciiz(&textW
, (PCSZ
)lpText
);
833 textW
.Buffer
= (LPWSTR
)lpText
;
835 if (HIWORD((UINT
)lpCaption
))
836 RtlCreateUnicodeStringFromAsciiz(&captionW
, (PCSZ
)lpCaption
);
838 captionW
.Buffer
= (LPWSTR
)lpCaption
;
840 msgboxW
.cbSize
= sizeof(msgboxW
);
841 msgboxW
.hwndOwner
= hWnd
;
842 msgboxW
.hInstance
= 0;
843 msgboxW
.lpszText
= textW
.Buffer
;
844 msgboxW
.lpszCaption
= captionW
.Buffer
;
845 msgboxW
.dwStyle
= uType
;
846 msgboxW
.lpszIcon
= NULL
;
847 msgboxW
.dwContextHelpId
= 0;
848 msgboxW
.lpfnMsgBoxCallback
= NULL
;
849 msgboxW
.dwLanguageId
= wLanguageId
;
851 ret
= MessageBoxTimeoutIndirectW(&msgboxW
, (UINT
)dwTime
);
853 if (HIWORD(textW
.Buffer
))
854 RtlFreeUnicodeString(&textW
);
856 if (HIWORD(captionW
.Buffer
))
857 RtlFreeUnicodeString(&captionW
);
875 MSGBOXPARAMSW msgbox
;
877 msgbox
.cbSize
= sizeof(msgbox
);
878 msgbox
.hwndOwner
= hWnd
;
879 msgbox
.hInstance
= 0;
880 msgbox
.lpszText
= lpText
;
881 msgbox
.lpszCaption
= lpCaption
;
882 msgbox
.dwStyle
= uType
;
883 msgbox
.lpszIcon
= NULL
;
884 msgbox
.dwContextHelpId
= 0;
885 msgbox
.lpfnMsgBoxCallback
= NULL
;
886 msgbox
.dwLanguageId
= wLanguageId
;
888 return MessageBoxTimeoutIndirectW(&msgbox
, (UINT
)dwTime
);
897 SoftModalMessageBox(DWORD Unknown0
)
909 MessageBeep(UINT uType
)
917 if(waveOutGetNumDevs() == 0)
918 return Beep(500, 100); // Beep through speaker
921 EventName
= L
"SystemDefault";
923 case MB_ICONASTERISK
:
924 EventName
= L
"SystemAsterisk";
926 case MB_ICONEXCLAMATION
:
927 EventName
= L
"SystemExclamation";
930 EventName
= L
"SystemHand";
932 case MB_ICONQUESTION
:
933 EventName
= L
"SystemQuestion";
937 return PlaySoundW((LPCWSTR
)EventName
, NULL
, SND_ALIAS
| SND_NOWAIT
| SND_NOSTOP
| SND_ASYNC
);
939 return Beep(500, 100); // Beep through speaker