Changeset 3153 for trunk/src/user32/msgbox.c
- Timestamp:
- Mar 18, 2000, 5:13:41 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/msgbox.c
r2804 r3153 1 /* $Id: msgbox.c,v 1. 2 2000-02-16 14:34:24 sandervlExp $ */1 /* $Id: msgbox.c,v 1.3 2000-03-18 16:13:37 cbratschi Exp $ */ 2 2 /* 3 3 * Message boxes (based on Wine code) … … 5 5 * Copyright 1995 Bernd Schmidt 6 6 * 7 * Corel WINE version: 20000317 7 8 * 8 9 */ … … 14 15 #include <heapstring.h> 15 16 16 #define DBG_LOCALLOG 17 #define DBG_LOCALLOG DBG_msgbox 17 18 #include "dbglocal.h" 18 19 … … 31 32 LPCSTR lpszText; 32 33 char buf[256]; 33 34 //// if (TWEAK_WineLook >= WIN95_LOOK) { 35 NONCLIENTMETRICSA nclm; 36 //// INT i; 37 nclm.cbSize = sizeof(NONCLIENTMETRICSA); 38 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0); 39 hFont = CreateFontIndirectA (&nclm.lfMessageFont); 40 /* set button font */ 41 for (i=1; i < 8; i++) 42 SendDlgItemMessageA (hwnd, i, WM_SETFONT, (WPARAM)hFont, 0); 43 /* set text font */ 44 SendDlgItemMessageA (hwnd, MSGBOX_IDTEXT, WM_SETFONT, (WPARAM)hFont, 0); 45 //// } 34 NONCLIENTMETRICSA nclm; 35 BOOL hasIcon = TRUE; 36 37 nclm.cbSize = sizeof(NONCLIENTMETRICSA); 38 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0); 39 hFont = CreateFontIndirectA (&nclm.lfMessageFont); 40 /* set button font */ 41 for (i=1; i < 8; i++) 42 SendDlgItemMessageA (hwnd, i, WM_SETFONT, (WPARAM)hFont, 0); 43 /* set text font */ 44 SendDlgItemMessageA (hwnd, MSGBOX_IDTEXT, WM_SETFONT, (WPARAM)hFont, 0); 45 46 46 if (HIWORD(lpmb->lpszCaption)) { 47 47 SetWindowTextA(hwnd, lpmb->lpszCaption); 48 48 } else { 49 49 if (LoadStringA(lpmb->hInstance, LOWORD(lpmb->lpszCaption), buf, sizeof(buf))) 50 50 SetWindowTextA(hwnd, buf); 51 51 } 52 52 if (HIWORD(lpmb->lpszText)) { … … 55 55 lpszText = buf; 56 56 if (!LoadStringA(lpmb->hInstance, LOWORD(lpmb->lpszText), buf, sizeof(buf))) 57 *buf = 0;/* FIXME ?? */57 *buf = 0; /* FIXME ?? */ 58 58 } 59 59 SetWindowTextA(GetDlgItem(hwnd, MSGBOX_IDTEXT), lpszText); … … 62 62 switch(lpmb->dwStyle & MB_TYPEMASK) { 63 63 case MB_OK: 64 65 64 ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE); 65 /* fall through */ 66 66 case MB_OKCANCEL: 67 68 69 70 71 72 67 ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE); 68 ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE); 69 ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE); 70 ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE); 71 ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE); 72 break; 73 73 case MB_ABORTRETRYIGNORE: 74 75 76 77 78 74 ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE); 75 ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE); 76 ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE); 77 ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE); 78 break; 79 79 case MB_YESNO: 80 81 80 ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE); 81 /* fall through */ 82 82 case MB_YESNOCANCEL: 83 84 85 86 87 83 ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE); 84 ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE); 85 ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE); 86 ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE); 87 break; 88 88 case MB_RETRYCANCEL: 89 90 91 92 93 94 89 ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE); 90 ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE); 91 ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE); 92 ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE); 93 ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE); 94 break; 95 95 } 96 96 /* Set the icon */ 97 97 switch(lpmb->dwStyle & MB_ICONMASK) { 98 98 case MB_ICONEXCLAMATION: 99 100 101 99 SendDlgItemMessageA(hwnd, stc1, STM_SETICON, 100 (WPARAM)LoadIconA(0, IDI_EXCLAMATIONA), 0); 101 break; 102 102 case MB_ICONQUESTION: 103 104 105 103 SendDlgItemMessageA(hwnd, stc1, STM_SETICON, 104 (WPARAM)LoadIconA(0, IDI_QUESTIONA), 0); 105 break; 106 106 case MB_ICONASTERISK: 107 108 109 107 SendDlgItemMessageA(hwnd, stc1, STM_SETICON, 108 (WPARAM)LoadIconA(0, IDI_ASTERISKA), 0); 109 break; 110 110 case MB_ICONHAND: 111 SendDlgItemMessageA(hwnd, stc1, STM_SETICON, 112 (WPARAM)LoadIconA(0, IDI_HANDA), 0); 113 break; 111 114 default: 112 SendDlgItemMessageA(hwnd, stc1, STM_SETICON, 113 (WPARAM)LoadIconA(0, IDI_HANDA), 0); 114 break; 115 } 116 115 /* By default, Windows 95/98/NT do not associate an icon to message boxes. 116 * So wine should do the same. 117 */ 118 hasIcon = FALSE; 119 ShowWindow(GetDlgItem(hwnd,stc1),SW_HIDE); 120 break; 121 } 122 117 123 /* Position everything */ 118 124 GetWindowRect(hwnd, &rect); … … 122 128 borheight -= rect.bottom - rect.top; 123 129 borwidth -= rect.right - rect.left; 124 130 125 131 /* Get the icon height */ 126 GetWindowRect(GetDlgItem(hwnd, MSGBOX_IDICON), &rect); 127 MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2); 128 iheight = rect.bottom - rect.top; 129 ileft = rect.left; 130 iwidth = rect.right - ileft; 131 132 if (hasIcon) 133 { 134 GetWindowRect(GetDlgItem(hwnd, MSGBOX_IDICON), &rect); 135 MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2); 136 iheight = rect.bottom - rect.top; 137 ileft = rect.left; 138 iwidth = rect.right - ileft; 139 } else 140 { 141 iheight = 0; 142 ileft = 0; 143 iwidth = 0; 144 } 145 132 146 hdc = GetDC(hwnd); 133 147 if (hFont) 134 135 148 hPrevFont = SelectObject(hdc, hFont); 149 136 150 /* Get the number of visible buttons and their size */ 137 151 bh = bw = 1; /* Minimum button sizes */ 138 152 for (buttons = 0, i = 1; i < 8; i++) 139 153 { 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 154 hItem = GetDlgItem(hwnd, i); 155 if (GetWindowLongA(hItem, GWL_STYLE) & WS_VISIBLE) 156 { 157 char buttonText[1024]; 158 int w, h; 159 buttons++; 160 if (GetWindowTextA(hItem, buttonText, sizeof buttonText)) 161 { 162 DrawTextA( hdc, buttonText, -1, &rect, DT_LEFT | DT_EXPANDTABS | DT_CALCRECT); 163 h = rect.bottom - rect.top; 164 w = rect.right - rect.left; 165 if (h > bh) bh = h; 166 if (w > bw) bw = w ; 167 } 168 } 155 169 } 156 170 bw = MAX(bw, bh * 2); … … 159 173 bw = bw * 2; 160 174 bspace = bw/3; /* Space between buttons */ 161 175 162 176 /* Get the text size */ 163 177 GetClientRect(GetDlgItem(hwnd, MSGBOX_IDTEXT), &rect); 164 178 rect.top = rect.left = rect.bottom = 0; 165 179 DrawTextA( hdc, lpszText, -1, &rect, 166 180 DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT); 167 181 /* Min text width corresponds to space for the buttons */ 168 182 tleft = 2 * ileft + iwidth; 169 183 twidth = MAX((bw + bspace) * buttons + bspace - tleft, rect.right); 170 184 theight = rect.bottom; 171 185 172 186 if (hFont) 173 187 SelectObject(hdc, hPrevFont); 174 188 ReleaseDC(hItem, hdc); 175 189 176 190 tiheight = 16 + MAX(iheight, theight); 177 191 wwidth = tleft + twidth + ileft + borwidth; 178 192 wheight = 8 + tiheight + bh + borheight; 179 193 180 194 /* Resize the window */ 181 195 SetWindowPos(hwnd, 0, 0, 0, wwidth, wheight, 182 183 196 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); 197 184 198 /* Position the icon */ 185 199 SetWindowPos(GetDlgItem(hwnd, MSGBOX_IDICON), 0, ileft, (tiheight - iheight) / 2, 0, 0, 186 187 200 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); 201 188 202 /* Position the text */ 189 203 SetWindowPos(GetDlgItem(hwnd, MSGBOX_IDTEXT), 0, tleft, (tiheight - theight) / 2, twidth, theight, 190 191 204 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); 205 192 206 /* Position the buttons */ 193 207 bpos = (wwidth - (bw + bspace) * buttons + bspace) / 2; 194 208 for (buttons = i = 0; i < 7; i++) { 195 196 197 198 199 200 201 202 203 204 205 209 /* some arithmetic to get the right order for YesNoCancel windows */ 210 hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1); 211 if (GetWindowLongA(hItem, GWL_STYLE) & WS_VISIBLE) { 212 if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8)) { 213 SetFocus(hItem); 214 SendMessageA( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE ); 215 } 216 SetWindowPos(hItem, 0, bpos, tiheight, bw, bh, 217 SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW); 218 bpos += bw + bspace; 219 } 206 220 } 207 221 return hFont; … … 216 230 static LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message, 217 231 WPARAM wParam, LPARAM lParam ) 218 { 232 { 219 233 static HFONT hFont; 220 234 switch(message) { … … 222 236 hFont = MSGBOX_OnInit(hwnd, (LPMSGBOXPARAMSA)lParam); 223 237 return 0; 224 238 225 239 case WM_COMMAND: 226 240 switch (wParam) … … 235 249 EndDialog(hwnd, wParam); 236 250 if (hFont) 237 251 DeleteObject(hFont); 238 252 break; 239 253 } … … 287 301 LPSTR textA = HEAP_strdupWtoA( GetProcessHeap(), 0, text ); 288 302 INT ret; 289 303 290 304 ret = MessageBoxA( hwnd, textA, titleA, type ); 291 305 HeapFree( GetProcessHeap(), 0, titleA ); … … 333 347 return DialogBoxIndirectParamA( msgbox->hInstance, lpTemplate, 334 348 msgbox->hwndOwner, (DLGPROC)MSGBOX_DlgProc, 335 349 (LPARAM)msgbox ); 336 350 } 337 351 … … 341 355 INT WINAPI MessageBoxIndirectW( LPMSGBOXPARAMSW msgbox ) 342 356 { 343 MSGBOXPARAMSA 357 MSGBOXPARAMSA msgboxa; 344 358 345 359 memcpy(&msgboxa,msgbox,sizeof(msgboxa)); 346 if (msgbox->lpszCaption) 360 if (msgbox->lpszCaption) 347 361 lstrcpyWtoA((LPSTR)msgboxa.lpszCaption,msgbox->lpszCaption); 348 if (msgbox->lpszText) 362 if (msgbox->lpszText) 349 363 lstrcpyWtoA((LPSTR)msgboxa.lpszText,msgbox->lpszText); 350 364 351 365 return MessageBoxIndirectA(&msgboxa); 366 } 367 368 /************************************************************************** 369 * FatalAppExit32A (KERNEL32.108) 370 */ 371 void WINAPI FatalAppExitA( UINT action, LPCSTR str ) 372 { 373 //WARN("AppExit\n"); 374 MessageBoxA( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); 375 ExitProcess(0); 376 } 377 378 379 /************************************************************************** 380 * FatalAppExit32W (KERNEL32.109) 381 */ 382 void WINAPI FatalAppExitW( UINT action, LPCWSTR str ) 383 { 384 //WARN("AppExit\n"); 385 MessageBoxW( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); 386 ExitProcess(0); 352 387 } 353 388
Note:
See TracChangeset
for help on using the changeset viewer.