4 * Copyright 1995 Bernd Schmidt
24 /**************************************************************************
27 * Dialog procedure for message boxes.
29 static LRESULT
MSGBOX_DlgProc( HWND32 hwnd
, UINT32 message
,
30 WPARAM32 wParam
, LPARAM lParam
)
33 RECT32 rect
, textrect
;
37 int i
, buttons
, bwidth
, bheight
, theight
, wwidth
, bpos
;
38 int borheight
, iheight
, tiheight
;
42 lpmb
= (LPMSGBOX
)lParam
;
43 if (lpmb
->title
) SetWindowText32A(hwnd
, lpmb
->title
);
44 SetWindowText32A(GetDlgItem32(hwnd
, 100), lpmb
->text
);
45 /* Hide not selected buttons */
46 switch(lpmb
->type
& MB_TYPEMASK
) {
48 ShowWindow32(GetDlgItem32(hwnd
, 2), SW_HIDE
);
51 ShowWindow32(GetDlgItem32(hwnd
, 3), SW_HIDE
);
52 ShowWindow32(GetDlgItem32(hwnd
, 4), SW_HIDE
);
53 ShowWindow32(GetDlgItem32(hwnd
, 5), SW_HIDE
);
54 ShowWindow32(GetDlgItem32(hwnd
, 6), SW_HIDE
);
55 ShowWindow32(GetDlgItem32(hwnd
, 7), SW_HIDE
);
57 case MB_ABORTRETRYIGNORE
:
58 ShowWindow32(GetDlgItem32(hwnd
, 1), SW_HIDE
);
59 ShowWindow32(GetDlgItem32(hwnd
, 2), SW_HIDE
);
60 ShowWindow32(GetDlgItem32(hwnd
, 6), SW_HIDE
);
61 ShowWindow32(GetDlgItem32(hwnd
, 7), SW_HIDE
);
64 ShowWindow32(GetDlgItem32(hwnd
, 2), SW_HIDE
);
67 ShowWindow32(GetDlgItem32(hwnd
, 1), SW_HIDE
);
68 ShowWindow32(GetDlgItem32(hwnd
, 3), SW_HIDE
);
69 ShowWindow32(GetDlgItem32(hwnd
, 4), SW_HIDE
);
70 ShowWindow32(GetDlgItem32(hwnd
, 5), SW_HIDE
);
74 switch(lpmb
->type
& MB_ICONMASK
) {
75 case MB_ICONEXCLAMATION
:
76 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
77 (WPARAM16
)LoadIcon16(0, IDI_EXCLAMATION
), 0);
80 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
81 (WPARAM16
)LoadIcon16(0, IDI_QUESTION
), 0);
84 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
85 (WPARAM16
)LoadIcon16(0, IDI_ASTERISK
), 0);
89 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
90 (WPARAM16
)LoadIcon16(0, IDI_HAND
), 0);
94 /* Position everything */
95 GetWindowRect32(hwnd
, &rect
);
96 borheight
= rect
.bottom
- rect
.top
;
97 wwidth
= rect
.right
- rect
.left
;
98 GetClientRect32(hwnd
, &rect
);
99 borheight
-= rect
.bottom
- rect
.top
;
101 /* Get the icon height */
102 GetWindowRect32(GetDlgItem32(hwnd
, 1088), &rect
);
103 iheight
= rect
.bottom
- rect
.top
;
105 /* Get the number of visible buttons and their width */
106 GetWindowRect32(GetDlgItem32(hwnd
, 2), &rect
);
107 bheight
= rect
.bottom
- rect
.top
;
109 GetWindowRect32(GetDlgItem32(hwnd
, 1), &rect
);
111 for (buttons
= 0, i
= 1; i
< 8; i
++)
113 hItem
= GetDlgItem32(hwnd
, i
);
114 if (GetWindowLong32A(hItem
, GWL_STYLE
) & WS_VISIBLE
) buttons
++;
117 /* Get the text size */
118 hItem
= GetDlgItem32(hwnd
, 100);
119 GetWindowRect32(hItem
, &textrect
);
120 MapWindowPoints32(0, hwnd
, (LPPOINT32
)&textrect
, 2);
122 GetClientRect32(hItem
, &rect
);
123 hdc
= GetDC32(hItem
);
124 lRet
= DrawText32A( hdc
, lpmb
->text
, -1, &rect
,
125 DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
| DT_CALCRECT
);
126 theight
= rect
.bottom
- rect
.top
;
127 tiheight
= 16 + MAX(iheight
, theight
);
128 ReleaseDC32(hItem
, hdc
);
130 /* Position the text */
131 SetWindowPos32(hItem
, 0, textrect
.left
, (tiheight
- theight
) / 2,
132 rect
.right
- rect
.left
, theight
,
133 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
135 /* Position the icon */
136 hItem
= GetDlgItem32(hwnd
, 1088);
137 GetWindowRect32(hItem
, &rect
);
138 MapWindowPoints32(0, hwnd
, (LPPOINT32
)&rect
, 2);
139 SetWindowPos32(hItem
, 0, rect
.left
, (tiheight
- iheight
) / 2, 0, 0,
140 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
142 /* Resize the window */
143 SetWindowPos32(hwnd
, 0, 0, 0, wwidth
, 8 + tiheight
+ bheight
+ borheight
,
144 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
146 /* Position the buttons */
147 bpos
= (wwidth
- bwidth
* buttons
) / 2;
148 GetWindowRect32(GetDlgItem32(hwnd
, 1), &rect
);
149 for (buttons
= i
= 0; i
< 7; i
++) {
150 /* some arithmetic to get the right order for YesNoCancel windows */
151 hItem
= GetDlgItem32(hwnd
, (i
+ 5) % 7 + 1);
152 if (GetWindowLong32A(hItem
, GWL_STYLE
) & WS_VISIBLE
) {
153 if (buttons
++ == ((lpmb
->type
& MB_DEFMASK
) >> 8)) {
155 SendMessage32A( hItem
, BM_SETSTYLE32
, BS_DEFPUSHBUTTON
, TRUE
);
157 SetWindowPos32(hItem
, 0, bpos
, tiheight
, 0, 0,
158 SWP_NOSIZE
|SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOREDRAW
);
175 EndDialog32(hwnd
, wParam
);
184 /**************************************************************************
185 * MessageBox16 (USER.1)
187 INT16
MessageBox16( HWND16 hwnd
, LPCSTR text
, LPCSTR title
, UINT16 type
)
189 return MessageBox32A( hwnd
, text
, title
, type
);
193 /**************************************************************************
194 * MessageBox32A (USER32.390)
196 INT32
MessageBox32A( HWND32 hWnd
, LPCSTR text
, LPCSTR title
, UINT32 type
)
200 if (!text
) text
="<WINE-NULL>";
201 if (!title
) title
="<WINE-NULL>";
205 return DialogBoxIndirectParam32A( WIN_GetWindowInstance(hWnd
),
206 SYSRES_GetResPtr( SYSRES_DIALOG_MSGBOX
),
207 hWnd
, MSGBOX_DlgProc
, (LPARAM
)&mbox
);
211 /**************************************************************************
212 * MessageBox32W (USER32.395)
214 INT32
MessageBox32W( HWND32 hwnd
, LPCWSTR text
, LPCWSTR title
, UINT32 type
)
216 LPSTR titleA
= HEAP_strdupWtoA( GetProcessHeap(), 0, title
);
217 LPSTR textA
= HEAP_strdupWtoA( GetProcessHeap(), 0, text
);
218 INT32 ret
= MessageBox32A( hwnd
, textA
, titleA
, type
);
219 HeapFree( GetProcessHeap(), 0, titleA
);
220 HeapFree( GetProcessHeap(), 0, textA
);
225 /**************************************************************************
226 * MessageBoxEx32A (USER32.391)
229 MessageBoxEx32A(HWND32 hWnd
,LPCSTR text
,LPCSTR title
,UINT32 type
,WORD langid
) {
230 /* ignore language id for now */
231 return MessageBox32A(hWnd
,text
,title
,type
);
234 /**************************************************************************
235 * MessageBoxEx32W (USER32.392)
238 MessageBoxEx32W(HWND32 hWnd
,LPCWSTR text
,LPCWSTR title
,UINT32 type
,WORD langid
)
240 /* ignore language id for now */
241 return MessageBox32W(hWnd
,text
,title
,type
);
245 /**************************************************************************
246 * FatalAppExit16 (KERNEL.137)
248 void FatalAppExit16( UINT16 action
, LPCSTR str
)
250 FatalAppExit32A( action
, str
);
254 /**************************************************************************
255 * FatalAppExit32A (KERNEL32.108)
257 void FatalAppExit32A( UINT32 action
, LPCSTR str
)
259 MessageBox32A( 0, str
, NULL
, MB_SYSTEMMODAL
| MB_OK
);
260 TASK_KillCurrentTask(0);
264 /**************************************************************************
265 * FatalAppExit32W (KERNEL32.109)
267 void FatalAppExit32W( UINT32 action
, LPCWSTR str
)
269 MessageBox32W( 0, str
, NULL
, MB_SYSTEMMODAL
| MB_OK
);
270 TASK_KillCurrentTask(0);