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);
78 SendDlgItemMessage(hwnd
, stc1
, STM_SETICON
, LoadIcon(0, IDI_HAND
), 0);
82 /* Position everything */
83 GetWindowRect(hwnd
, &rect
);
84 borheight
= rect
.bottom
- rect
.top
;
85 wwidth
= rect
.right
- rect
.left
;
86 GetClientRect(hwnd
, &rect
);
87 borheight
-= rect
.bottom
- rect
.top
;
89 /* Get the icon height */
90 GetWindowRect(GetDlgItem(hwnd
, 1088), &rect
);
91 iheight
= rect
.bottom
- rect
.top
;
93 /* Get the number of visible buttons and their width */
94 GetWindowRect(GetDlgItem(hwnd
, 2), &rect
);
95 bheight
= rect
.bottom
- rect
.top
;
97 GetWindowRect(GetDlgItem(hwnd
, 1), &rect
);
99 for (buttons
= 0, i
= 1; i
< 8; i
++) {
100 hItem
= GetDlgItem(hwnd
, i
);
101 if (GetWindowLong(hItem
, GWL_STYLE
) & WS_VISIBLE
) {
106 /* Get the text size */
107 hItem
= GetDlgItem(hwnd
, 100);
108 GetWindowRect(hItem
, &textrect
);
109 MapWindowPoints(0, hwnd
, (LPPOINT
)&textrect
, 2);
111 GetClientRect(hItem
, &rect
);
113 lRet
= DrawText(hdc
, lpmb
->text
, -1, &rect
,
114 DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
| DT_CALCRECT
);
115 theight
= rect
.bottom
- rect
.top
;
116 tiheight
= 16 + max(iheight
, theight
);
117 ReleaseDC(hItem
, hdc
);
119 /* Position the text */
120 SetWindowPos(hItem
, 0, textrect
.left
, (tiheight
- theight
) / 2,
121 rect
.right
- rect
.left
, theight
,
122 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
124 /* Position the icon */
125 hItem
= GetDlgItem(hwnd
, 1088);
126 GetWindowRect(hItem
, &rect
);
127 MapWindowPoints(0, hwnd
, (LPPOINT
)&rect
, 2);
128 SetWindowPos(hItem
, 0, rect
.left
, (tiheight
- iheight
) / 2, 0, 0,
129 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
131 /* Resize the window */
132 SetWindowPos(hwnd
, 0, 0, 0, wwidth
, 8 + tiheight
+ bheight
+ borheight
,
133 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
135 /* Position the buttons */
136 bpos
= (wwidth
- bwidth
* buttons
) / 2;
137 GetWindowRect(GetDlgItem(hwnd
, 1), &rect
);
138 for (buttons
= i
= 0; i
< 7; i
++) {
139 /* some arithmetic to get the right order for YesNoCancel windows */
140 hItem
= GetDlgItem(hwnd
, (i
+ 5) % 7 + 1);
141 if (GetWindowLong(hItem
, GWL_STYLE
) & WS_VISIBLE
) {
142 if (buttons
++ == ((lpmb
->type
& MB_DEFMASK
) >> 8)) {
144 SendMessage(hItem
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
146 SetWindowPos(hItem
, 0, bpos
, tiheight
, 0, 0,
147 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
163 EndDialog(hwnd
, wParam
);
171 /**************************************************************************
172 * MessageBox [USER.1]
175 int MessageBox(HWND hWnd
, LPSTR text
, LPSTR title
, WORD type
)
182 return DialogBoxIndirectParamPtr(GetWindowWord(hWnd
, GWW_HINSTANCE
),
183 sysres_DIALOG_MSGBOX
, hWnd
,
184 GetWndProcEntry16("SystemMessageBoxProc"),
188 /**************************************************************************
189 * FatalAppExit [USER.137]
192 void FatalAppExit(WORD wAction
, LPSTR str
)
194 MessageBox(0, str
, NULL
, MB_SYSTEMMODAL
| MB_OK
);
195 TASK_KillCurrentTask(0);