4 * Copyright 1995 Bernd Schmidt
21 LRESULT
SystemMessageBoxProc(HWND hwnd
,UINT message
,WPARAM wParam
,LPARAM lParam
)
24 RECT16 rect
, textrect
;
28 int i
, buttons
, bwidth
, bheight
, theight
, wwidth
, bpos
;
29 int borheight
, iheight
, tiheight
;
33 lpmb
= (LPMSGBOX
)lParam
;
34 if (lpmb
->title
) SetWindowText32A(hwnd
, lpmb
->title
);
35 SetWindowText32A(GetDlgItem(hwnd
, 100), lpmb
->text
);
36 /* Hide not selected buttons */
37 switch(lpmb
->type
& MB_TYPEMASK
) {
39 ShowWindow(GetDlgItem(hwnd
, 2), SW_HIDE
);
42 ShowWindow(GetDlgItem(hwnd
, 3), SW_HIDE
);
43 ShowWindow(GetDlgItem(hwnd
, 4), SW_HIDE
);
44 ShowWindow(GetDlgItem(hwnd
, 5), SW_HIDE
);
45 ShowWindow(GetDlgItem(hwnd
, 6), SW_HIDE
);
46 ShowWindow(GetDlgItem(hwnd
, 7), SW_HIDE
);
48 case MB_ABORTRETRYIGNORE
:
49 ShowWindow(GetDlgItem(hwnd
, 1), SW_HIDE
);
50 ShowWindow(GetDlgItem(hwnd
, 2), SW_HIDE
);
51 ShowWindow(GetDlgItem(hwnd
, 6), SW_HIDE
);
52 ShowWindow(GetDlgItem(hwnd
, 7), SW_HIDE
);
55 ShowWindow(GetDlgItem(hwnd
, 2), SW_HIDE
);
58 ShowWindow(GetDlgItem(hwnd
, 1), SW_HIDE
);
59 ShowWindow(GetDlgItem(hwnd
, 3), SW_HIDE
);
60 ShowWindow(GetDlgItem(hwnd
, 4), SW_HIDE
);
61 ShowWindow(GetDlgItem(hwnd
, 5), SW_HIDE
);
65 switch(lpmb
->type
& MB_ICONMASK
) {
66 case MB_ICONEXCLAMATION
:
67 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
68 (WPARAM
)LoadIcon16(0, IDI_EXCLAMATION
), 0);
71 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
72 (WPARAM
)LoadIcon16(0, IDI_QUESTION
), 0);
75 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
76 (WPARAM
)LoadIcon16(0, IDI_ASTERISK
), 0);
80 SendDlgItemMessage16(hwnd
, stc1
, STM_SETICON
,
81 (WPARAM
)LoadIcon16(0, IDI_HAND
), 0);
85 /* Position everything */
86 GetWindowRect16(hwnd
, &rect
);
87 borheight
= rect
.bottom
- rect
.top
;
88 wwidth
= rect
.right
- rect
.left
;
89 GetClientRect16(hwnd
, &rect
);
90 borheight
-= rect
.bottom
- rect
.top
;
92 /* Get the icon height */
93 GetWindowRect16(GetDlgItem(hwnd
, 1088), &rect
);
94 iheight
= rect
.bottom
- rect
.top
;
96 /* Get the number of visible buttons and their width */
97 GetWindowRect16(GetDlgItem(hwnd
, 2), &rect
);
98 bheight
= rect
.bottom
- rect
.top
;
100 GetWindowRect16(GetDlgItem(hwnd
, 1), &rect
);
102 for (buttons
= 0, i
= 1; i
< 8; i
++)
104 hItem
= GetDlgItem(hwnd
, i
);
105 if (GetWindowLong32A(hItem
, GWL_STYLE
) & WS_VISIBLE
) buttons
++;
108 /* Get the text size */
109 hItem
= GetDlgItem(hwnd
, 100);
110 GetWindowRect16(hItem
, &textrect
);
111 MapWindowPoints16(0, hwnd
, (LPPOINT16
)&textrect
, 2);
113 GetClientRect16(hItem
, &rect
);
115 lRet
= DrawText16( hdc
, lpmb
->text
, -1, &rect
,
116 DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
| DT_CALCRECT
);
117 theight
= rect
.bottom
- rect
.top
;
118 tiheight
= 16 + MAX(iheight
, theight
);
119 ReleaseDC(hItem
, hdc
);
121 /* Position the text */
122 SetWindowPos(hItem
, 0, textrect
.left
, (tiheight
- theight
) / 2,
123 rect
.right
- rect
.left
, theight
,
124 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
126 /* Position the icon */
127 hItem
= GetDlgItem(hwnd
, 1088);
128 GetWindowRect16(hItem
, &rect
);
129 MapWindowPoints16(0, hwnd
, (LPPOINT16
)&rect
, 2);
130 SetWindowPos(hItem
, 0, rect
.left
, (tiheight
- iheight
) / 2, 0, 0,
131 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
133 /* Resize the window */
134 SetWindowPos(hwnd
, 0, 0, 0, wwidth
, 8 + tiheight
+ bheight
+ borheight
,
135 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
137 /* Position the buttons */
138 bpos
= (wwidth
- bwidth
* buttons
) / 2;
139 GetWindowRect16(GetDlgItem(hwnd
, 1), &rect
);
140 for (buttons
= i
= 0; i
< 7; i
++) {
141 /* some arithmetic to get the right order for YesNoCancel windows */
142 hItem
= GetDlgItem(hwnd
, (i
+ 5) % 7 + 1);
143 if (GetWindowLong32A(hItem
, GWL_STYLE
) & WS_VISIBLE
) {
144 if (buttons
++ == ((lpmb
->type
& MB_DEFMASK
) >> 8)) {
146 SendMessage32A( hItem
, BM_SETSTYLE32
, BS_DEFPUSHBUTTON
, TRUE
);
148 SetWindowPos(hItem
, 0, bpos
, tiheight
, 0, 0,
149 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
165 EndDialog(hwnd
, wParam
);
173 /**************************************************************************
174 * MessageBox [USER.1]
177 int MessageBox(HWND hWnd
, LPCSTR text
, LPCSTR title
, WORD type
)
187 handle
= SYSRES_LoadResource( SYSRES_DIALOG_MSGBOX
);
188 if (!handle
) return 0;
189 ret
= DialogBoxIndirectParam16( WIN_GetWindowInstance(hWnd
),
191 MODULE_GetWndProcEntry16("SystemMessageBoxProc"),
193 SYSRES_FreeResource( handle
);
197 /**************************************************************************
198 * FatalAppExit [USER.137]
201 void FatalAppExit(UINT fuAction
, LPCSTR str
)
203 MessageBox(0, str
, NULL
, MB_SYSTEMMODAL
| MB_OK
);
204 TASK_KillCurrentTask(0);