4 * Copyright 1995 Bernd Schmidt
11 #include "selectors.h"
14 #include "../rc/sysres.h"
23 LONG
SystemMessageBoxProc(HWND hwnd
, WORD message
, WORD wParam
, LONG lParam
)
30 int i
, buttons
, bwidth
, bheight
, theight
, wwidth
, bpos
;
31 int borheight
, iheight
, tiheight
;
35 lpmb
= (LPMSGBOX
)lParam
;
36 if (lpmb
->title
!= NULL
) {
37 SetWindowText(hwnd
, lpmb
->title
);
39 SetWindowText(GetDlgItem(hwnd
, 100), lpmb
->text
);
40 /* Hide not selected buttons */
41 switch(lpmb
->type
& MB_TYPEMASK
) {
43 ShowWindow(GetDlgItem(hwnd
, 2), SW_HIDE
);
46 ShowWindow(GetDlgItem(hwnd
, 3), SW_HIDE
);
47 ShowWindow(GetDlgItem(hwnd
, 4), SW_HIDE
);
48 ShowWindow(GetDlgItem(hwnd
, 5), SW_HIDE
);
49 ShowWindow(GetDlgItem(hwnd
, 6), SW_HIDE
);
50 ShowWindow(GetDlgItem(hwnd
, 7), SW_HIDE
);
52 case MB_ABORTRETRYIGNORE
:
53 ShowWindow(GetDlgItem(hwnd
, 1), SW_HIDE
);
54 ShowWindow(GetDlgItem(hwnd
, 2), SW_HIDE
);
55 ShowWindow(GetDlgItem(hwnd
, 6), SW_HIDE
);
56 ShowWindow(GetDlgItem(hwnd
, 7), SW_HIDE
);
59 ShowWindow(GetDlgItem(hwnd
, 2), SW_HIDE
);
62 ShowWindow(GetDlgItem(hwnd
, 1), SW_HIDE
);
63 ShowWindow(GetDlgItem(hwnd
, 3), SW_HIDE
);
64 ShowWindow(GetDlgItem(hwnd
, 4), SW_HIDE
);
65 ShowWindow(GetDlgItem(hwnd
, 5), SW_HIDE
);
69 switch(lpmb
->type
& MB_ICONMASK
) {
70 case MB_ICONEXCLAMATION
:
71 SendDlgItemMessage(hwnd
, stc1
, STM_SETICON
, LoadIcon(0, IDI_EXCLAMATION
), 0);
74 SendDlgItemMessage(hwnd
, stc1
, STM_SETICON
, LoadIcon(0, IDI_QUESTION
), 0);
77 SendDlgItemMessage(hwnd
, stc1
, STM_SETICON
, LoadIcon(0, IDI_ASTERISK
), 0);
81 SendDlgItemMessage(hwnd
, stc1
, STM_SETICON
, LoadIcon(0, IDI_HAND
), 0);
85 /* Position everything */
86 GetWindowRect(hwnd
, &rect
);
87 borheight
= rect
.bottom
- rect
.top
;
88 wwidth
= rect
.right
- rect
.left
;
89 GetClientRect(hwnd
, &rect
);
90 borheight
-= rect
.bottom
- rect
.top
;
92 /* Get the icon height */
93 GetWindowRect(GetDlgItem(hwnd
, 1088), &rect
);
94 iheight
= rect
.bottom
- rect
.top
;
96 /* Get the number of visible buttons and their width */
97 GetWindowRect(GetDlgItem(hwnd
, 2), &rect
);
98 bheight
= rect
.bottom
- rect
.top
;
100 GetWindowRect(GetDlgItem(hwnd
, 1), &rect
);
102 for (buttons
= 0, i
= 1; i
< 8; i
++) {
103 hItem
= GetDlgItem(hwnd
, i
);
104 if (GetWindowLong(hItem
, GWL_STYLE
) & WS_VISIBLE
) {
109 /* Get the text size */
110 hItem
= GetDlgItem(hwnd
, 100);
111 GetWindowRect(hItem
, &textrect
);
112 MapWindowPoints(0, hwnd
, (LPPOINT
)&textrect
, 2);
114 GetClientRect(hItem
, &rect
);
116 lRet
= DrawText(hdc
, lpmb
->text
, -1, &rect
,
117 DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
| DT_CALCRECT
);
118 theight
= rect
.bottom
- rect
.top
;
119 tiheight
= 16 + max(iheight
, theight
);
120 ReleaseDC(hItem
, hdc
);
122 /* Position the text */
123 SetWindowPos(hItem
, 0, textrect
.left
, (tiheight
- theight
) / 2,
124 rect
.right
- rect
.left
, theight
,
125 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
127 /* Position the icon */
128 hItem
= GetDlgItem(hwnd
, 1088);
129 GetWindowRect(hItem
, &rect
);
130 MapWindowPoints(0, hwnd
, (LPPOINT
)&rect
, 2);
131 SetWindowPos(hItem
, 0, rect
.left
, (tiheight
- iheight
) / 2, 0, 0,
132 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
134 /* Resize the window */
135 SetWindowPos(hwnd
, 0, 0, 0, wwidth
, 8 + tiheight
+ bheight
+ borheight
,
136 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
138 /* Position the buttons */
139 bpos
= (wwidth
- bwidth
* buttons
) / 2;
140 GetWindowRect(GetDlgItem(hwnd
, 1), &rect
);
141 for (buttons
= i
= 0; i
< 7; i
++) {
142 /* some arithmetic to get the right order for YesNoCancel windows */
143 hItem
= GetDlgItem(hwnd
, (i
+ 5) % 7 + 1);
144 if (GetWindowLong(hItem
, GWL_STYLE
) & WS_VISIBLE
) {
145 if (buttons
++ == ((lpmb
->type
& MB_DEFMASK
) >> 8)) {
147 SendMessage(hItem
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
149 SetWindowPos(hItem
, 0, bpos
, tiheight
, 0, 0,
150 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOREDRAW
);
166 EndDialog(hwnd
, wParam
);
174 /**************************************************************************
175 * MessageBox [USER.1]
178 int MessageBox(HWND hWnd
, LPSTR text
, LPSTR title
, WORD type
)
183 DWORD WineProc
,Win16Proc
,Win32Proc
;
184 static int initialized
= 0;
192 WineProc
=(DWORD
)SystemMessageBoxProc
;
193 Win16Proc
=(DWORD
)GetWndProcEntry16("SystemMessageBoxProc");
194 Win32Proc
=(DWORD
)RELAY32_GetEntryPoint("WINPROCS32","SystemMessageBoxProc",0);
195 ALIAS_RegisterAlias(WineProc
,Win16Proc
,Win32Proc
);
199 handle
= GLOBAL_CreateBlock( GMEM_FIXED
, sysres_DIALOG_MSGBOX
.bytes
,
200 sysres_DIALOG_MSGBOX
.size
, GetCurrentPDB(),
201 FALSE
, FALSE
, TRUE
, NULL
);
202 if (!handle
) return 0;
203 ret
= DialogBoxIndirectParam( GetWindowWord(hWnd
, GWW_HINSTANCE
),
205 GetWndProcEntry16("SystemMessageBoxProc"),
207 GLOBAL_FreeBlock( handle
);
211 /**************************************************************************
212 * FatalAppExit [USER.137]
215 void FatalAppExit(WORD wAction
, LPSTR str
)
217 MessageBox(0, str
, NULL
, MB_SYSTEMMODAL
| MB_OK
);
218 TASK_KillCurrentTask(0);