4 * Copyright 1995 Bernd Schmidt
11 #include "selectors.h"
12 #include "../rc/sysres.h"
21 LONG
SystemMessageBoxProc(HWND hwnd
, WORD message
, WORD wParam
, LONG lParam
)
28 int i
, buttons
, bwidth
, bheight
, theight
, wwidth
, bpos
;
29 int borheight
, iheight
, tiheight
;
33 lpmb
= (LPMSGBOX
)lParam
;
34 if (lpmb
->title
!= NULL
) {
35 SetWindowText(hwnd
, lpmb
->title
);
37 SetWindowText(GetDlgItem(hwnd
, 100), lpmb
->text
);
38 /* Hide not selected buttons */
39 switch(lpmb
->type
& MB_TYPEMASK
) {
41 ShowWindow(GetDlgItem(hwnd
, 2), SW_HIDE
);
44 ShowWindow(GetDlgItem(hwnd
, 3), SW_HIDE
);
45 ShowWindow(GetDlgItem(hwnd
, 4), SW_HIDE
);
46 ShowWindow(GetDlgItem(hwnd
, 5), SW_HIDE
);
47 ShowWindow(GetDlgItem(hwnd
, 6), SW_HIDE
);
48 ShowWindow(GetDlgItem(hwnd
, 7), SW_HIDE
);
50 case MB_ABORTRETRYIGNORE
:
51 ShowWindow(GetDlgItem(hwnd
, 1), SW_HIDE
);
52 ShowWindow(GetDlgItem(hwnd
, 2), SW_HIDE
);
53 ShowWindow(GetDlgItem(hwnd
, 6), SW_HIDE
);
54 ShowWindow(GetDlgItem(hwnd
, 7), SW_HIDE
);
57 ShowWindow(GetDlgItem(hwnd
, 2), SW_HIDE
);
60 ShowWindow(GetDlgItem(hwnd
, 1), SW_HIDE
);
61 ShowWindow(GetDlgItem(hwnd
, 3), SW_HIDE
);
62 ShowWindow(GetDlgItem(hwnd
, 4), SW_HIDE
);
63 ShowWindow(GetDlgItem(hwnd
, 5), SW_HIDE
);
67 switch(lpmb
->type
& MB_ICONMASK
) {
68 case MB_ICONEXCLAMATION
:
69 SendDlgItemMessage(hwnd
, stc1
, STM_SETICON
, LoadIcon(0, IDI_EXCLAMATION
), 0);
72 SendDlgItemMessage(hwnd
, stc1
, STM_SETICON
, LoadIcon(0, IDI_QUESTION
), 0);
75 SendDlgItemMessage(hwnd
, stc1
, STM_SETICON
, LoadIcon(0, IDI_ASTERISK
), 0);
79 SendDlgItemMessage(hwnd
, stc1
, STM_SETICON
, LoadIcon(0, IDI_HAND
), 0);
83 /* Position everything */
84 GetWindowRect(hwnd
, &rect
);
85 borheight
= rect
.bottom
- rect
.top
;
86 wwidth
= rect
.right
- rect
.left
;
87 GetClientRect(hwnd
, &rect
);
88 borheight
-= rect
.bottom
- rect
.top
;
90 /* Get the icon height */
91 GetWindowRect(GetDlgItem(hwnd
, 1088), &rect
);
92 iheight
= rect
.bottom
- rect
.top
;
94 /* Get the number of visible buttons and their width */
95 GetWindowRect(GetDlgItem(hwnd
, 2), &rect
);
96 bheight
= rect
.bottom
- rect
.top
;
98 GetWindowRect(GetDlgItem(hwnd
, 1), &rect
);
100 for (buttons
= 0, i
= 1; i
< 8; i
++) {
101 hItem
= GetDlgItem(hwnd
, i
);
102 if (GetWindowLong(hItem
, GWL_STYLE
) & WS_VISIBLE
) {
107 /* Get the text size */
108 hItem
= GetDlgItem(hwnd
, 100);
109 GetWindowRect(hItem
, &textrect
);
110 MapWindowPoints(0, hwnd
, (LPPOINT
)&textrect
, 2);
112 GetClientRect(hItem
, &rect
);
114 lRet
= DrawText(hdc
, lpmb
->text
, -1, &rect
,
115 DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
| DT_CALCRECT
);
116 theight
= rect
.bottom
- rect
.top
;
117 tiheight
= 16 + max(iheight
, theight
);
118 ReleaseDC(hItem
, hdc
);
120 /* Position the text */
121 SetWindowPos(hItem
, 0, textrect
.left
, (tiheight
- theight
) / 2,
122 rect
.right
- rect
.left
, theight
,
123 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
125 /* Position the icon */
126 hItem
= GetDlgItem(hwnd
, 1088);
127 GetWindowRect(hItem
, &rect
);
128 MapWindowPoints(0, hwnd
, (LPPOINT
)&rect
, 2);
129 SetWindowPos(hItem
, 0, rect
.left
, (tiheight
- iheight
) / 2, 0, 0,
130 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
132 /* Resize the window */
133 SetWindowPos(hwnd
, 0, 0, 0, wwidth
, 8 + tiheight
+ bheight
+ borheight
,
134 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
136 /* Position the buttons */
137 bpos
= (wwidth
- bwidth
* buttons
) / 2;
138 GetWindowRect(GetDlgItem(hwnd
, 1), &rect
);
139 for (buttons
= i
= 0; i
< 7; i
++) {
140 /* some arithmetic to get the right order for YesNoCancel windows */
141 hItem
= GetDlgItem(hwnd
, (i
+ 5) % 7 + 1);
142 if (GetWindowLong(hItem
, GWL_STYLE
) & WS_VISIBLE
) {
143 if (buttons
++ == ((lpmb
->type
& MB_DEFMASK
) >> 8)) {
145 SendMessage(hItem
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
147 SetWindowPos(hItem
, 0, bpos
, tiheight
, 0, 0,
148 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
164 EndDialog(hwnd
, wParam
);
172 /**************************************************************************
173 * MessageBox [USER.1]
176 int MessageBox(HWND hWnd
, LPSTR text
, LPSTR title
, WORD type
)
183 return DialogBoxIndirectParamPtr(GetWindowWord(hWnd
, GWW_HINSTANCE
),
184 sysres_DIALOG_MSGBOX
, hWnd
,
185 GetWndProcEntry16("SystemMessageBoxProc"),
189 /**************************************************************************
190 * FatalAppExit [USER.137]
193 void FatalAppExit(WORD wAction
, LPSTR str
)
195 MessageBox(0, str
, NULL
, MB_SYSTEMMODAL
| MB_OK
);
196 TASK_KillCurrentTask(0);