4 * Copyright 1995 Bernd Schmidt
7 #define NO_TRANSITION_TYPES /* This file is Win32-clean */
25 /**************************************************************************
28 * Dialog procedure for message boxes.
30 static LRESULT
MSGBOX_DlgProc( HWND32 hwnd
, UINT32 message
,
31 WPARAM32 wParam
, LPARAM lParam
)
34 RECT32 rect
, textrect
;
38 int i
, buttons
, bwidth
, bheight
, theight
, wwidth
, bpos
;
39 int borheight
, iheight
, tiheight
;
43 lpmb
= (LPMSGBOX
)lParam
;
44 if (lpmb
->title
) SetWindowText32A(hwnd
, lpmb
->title
);
45 SetWindowText32A(GetDlgItem32(hwnd
, 100), lpmb
->text
);
46 /* Hide not selected buttons */
47 switch(lpmb
->type
& MB_TYPEMASK
) {
49 ShowWindow32(GetDlgItem32(hwnd
, 2), SW_HIDE
);
52 ShowWindow32(GetDlgItem32(hwnd
, 3), SW_HIDE
);
53 ShowWindow32(GetDlgItem32(hwnd
, 4), SW_HIDE
);
54 ShowWindow32(GetDlgItem32(hwnd
, 5), SW_HIDE
);
55 ShowWindow32(GetDlgItem32(hwnd
, 6), SW_HIDE
);
56 ShowWindow32(GetDlgItem32(hwnd
, 7), SW_HIDE
);
58 case MB_ABORTRETRYIGNORE
:
59 ShowWindow32(GetDlgItem32(hwnd
, 1), SW_HIDE
);
60 ShowWindow32(GetDlgItem32(hwnd
, 2), SW_HIDE
);
61 ShowWindow32(GetDlgItem32(hwnd
, 6), SW_HIDE
);
62 ShowWindow32(GetDlgItem32(hwnd
, 7), SW_HIDE
);
65 ShowWindow32(GetDlgItem32(hwnd
, 2), SW_HIDE
);
68 ShowWindow32(GetDlgItem32(hwnd
, 1), SW_HIDE
);
69 ShowWindow32(GetDlgItem32(hwnd
, 3), SW_HIDE
);
70 ShowWindow32(GetDlgItem32(hwnd
, 4), SW_HIDE
);
71 ShowWindow32(GetDlgItem32(hwnd
, 5), SW_HIDE
);
75 switch(lpmb
->type
& MB_ICONMASK
) {
76 case MB_ICONEXCLAMATION
:
77 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
78 (WPARAM16
)LoadIcon16(0, IDI_EXCLAMATION
), 0);
81 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
82 (WPARAM16
)LoadIcon16(0, IDI_QUESTION
), 0);
85 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
86 (WPARAM16
)LoadIcon16(0, IDI_ASTERISK
), 0);
90 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
91 (WPARAM16
)LoadIcon16(0, IDI_HAND
), 0);
95 /* Position everything */
96 GetWindowRect32(hwnd
, &rect
);
97 borheight
= rect
.bottom
- rect
.top
;
98 wwidth
= rect
.right
- rect
.left
;
99 GetClientRect32(hwnd
, &rect
);
100 borheight
-= rect
.bottom
- rect
.top
;
102 /* Get the icon height */
103 GetWindowRect32(GetDlgItem32(hwnd
, 1088), &rect
);
104 iheight
= rect
.bottom
- rect
.top
;
106 /* Get the number of visible buttons and their width */
107 GetWindowRect32(GetDlgItem32(hwnd
, 2), &rect
);
108 bheight
= rect
.bottom
- rect
.top
;
110 GetWindowRect32(GetDlgItem32(hwnd
, 1), &rect
);
112 for (buttons
= 0, i
= 1; i
< 8; i
++)
114 hItem
= GetDlgItem32(hwnd
, i
);
115 if (GetWindowLong32A(hItem
, GWL_STYLE
) & WS_VISIBLE
) buttons
++;
118 /* Get the text size */
119 hItem
= GetDlgItem32(hwnd
, 100);
120 GetWindowRect32(hItem
, &textrect
);
121 MapWindowPoints32(0, hwnd
, (LPPOINT32
)&textrect
, 2);
123 GetClientRect32(hItem
, &rect
);
124 hdc
= GetDC32(hItem
);
125 lRet
= DrawText32A( hdc
, lpmb
->text
, -1, &rect
,
126 DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
| DT_CALCRECT
);
127 theight
= rect
.bottom
- rect
.top
;
128 tiheight
= 16 + MAX(iheight
, theight
);
129 ReleaseDC32(hItem
, hdc
);
131 /* Position the text */
132 SetWindowPos32(hItem
, 0, textrect
.left
, (tiheight
- theight
) / 2,
133 rect
.right
- rect
.left
, theight
,
134 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
136 /* Position the icon */
137 hItem
= GetDlgItem32(hwnd
, 1088);
138 GetWindowRect32(hItem
, &rect
);
139 MapWindowPoints32(0, hwnd
, (LPPOINT32
)&rect
, 2);
140 SetWindowPos32(hItem
, 0, rect
.left
, (tiheight
- iheight
) / 2, 0, 0,
141 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
143 /* Resize the window */
144 SetWindowPos32(hwnd
, 0, 0, 0, wwidth
, 8 + tiheight
+ bheight
+ borheight
,
145 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
147 /* Position the buttons */
148 bpos
= (wwidth
- bwidth
* buttons
) / 2;
149 GetWindowRect32(GetDlgItem32(hwnd
, 1), &rect
);
150 for (buttons
= i
= 0; i
< 7; i
++) {
151 /* some arithmetic to get the right order for YesNoCancel windows */
152 hItem
= GetDlgItem32(hwnd
, (i
+ 5) % 7 + 1);
153 if (GetWindowLong32A(hItem
, GWL_STYLE
) & WS_VISIBLE
) {
154 if (buttons
++ == ((lpmb
->type
& MB_DEFMASK
) >> 8)) {
156 SendMessage32A( hItem
, BM_SETSTYLE32
, BS_DEFPUSHBUTTON
, TRUE
);
158 SetWindowPos32(hItem
, 0, bpos
, tiheight
, 0, 0,
159 SWP_NOSIZE
|SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOREDRAW
);
176 EndDialog(hwnd
, wParam
);
185 /**************************************************************************
186 * MessageBox16 (USER.1)
188 INT16
MessageBox16( HWND16 hwnd
, LPCSTR text
, LPCSTR title
, UINT16 type
)
190 return MessageBox32A( hwnd
, text
, title
, type
);
194 /**************************************************************************
195 * MessageBox32A (USER32.390)
197 INT32
MessageBox32A( HWND32 hWnd
, LPCSTR text
, LPCSTR title
, UINT32 type
)
201 if (!text
) text
="<WINE-NULL>";
202 if (!title
) title
="<WINE-NULL>";
206 return DialogBoxIndirectParam32A( WIN_GetWindowInstance(hWnd
),
207 SYSRES_GetResPtr( SYSRES_DIALOG_MSGBOX
),
208 hWnd
, MSGBOX_DlgProc
, (LPARAM
)&mbox
);
212 /**************************************************************************
213 * MessageBox32W (USER32.395)
215 INT32
MessageBox32W( HWND32 hwnd
, LPCWSTR text
, LPCWSTR title
, UINT32 type
)
217 LPSTR titleA
= HEAP_strdupWtoA( GetProcessHeap(), 0, title
);
218 LPSTR textA
= HEAP_strdupWtoA( GetProcessHeap(), 0, text
);
219 INT32 ret
= MessageBox32A( hwnd
, textA
, titleA
, type
);
220 HeapFree( GetProcessHeap(), 0, titleA
);
221 HeapFree( GetProcessHeap(), 0, textA
);
226 /**************************************************************************
227 * MessageBoxEx32A (USER32.391)
230 MessageBoxEx32A(HWND32 hWnd
,LPCSTR text
,LPCSTR title
,UINT32 type
,WORD langid
) {
231 /* ignore language id for now */
232 return MessageBox32A(hWnd
,text
,title
,type
);
235 /**************************************************************************
236 * MessageBoxEx32W (USER32.392)
239 MessageBoxEx32W(HWND32 hWnd
,LPCWSTR text
,LPCWSTR title
,UINT32 type
,WORD langid
)
241 /* ignore language id for now */
242 return MessageBox32W(hWnd
,text
,title
,type
);
246 /**************************************************************************
247 * FatalAppExit16 (KERNEL.137)
249 void FatalAppExit16( UINT16 action
, LPCSTR str
)
251 FatalAppExit32A( action
, str
);
255 /**************************************************************************
256 * FatalAppExit32A (KERNEL32.108)
258 void FatalAppExit32A( UINT32 action
, LPCSTR str
)
260 MessageBox32A( 0, str
, NULL
, MB_SYSTEMMODAL
| MB_OK
);
261 TASK_KillCurrentTask(0);
265 /**************************************************************************
266 * FatalAppExit32W (KERNEL32.109)
268 void FatalAppExit32W( UINT32 action
, LPCWSTR str
)
270 MessageBox32W( 0, str
, NULL
, MB_SYSTEMMODAL
| MB_OK
);
271 TASK_KillCurrentTask(0);