Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Message boxes |
| 3 | * |
| 4 | * Copyright 1995 Bernd Schmidt |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
David Luyer | ee517e8 | 1999-02-28 12:27:56 +0000 | [diff] [blame] | 7 | #include <string.h> |
Michael Veksler | ca1bc86 | 1999-01-01 18:57:33 +0000 | [diff] [blame] | 8 | #include "wine/winuser16.h" |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 9 | #include "dlgs.h" |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 10 | #include "heap.h" |
Marcus Meissner | d7c565f | 1999-05-14 18:39:37 +0000 | [diff] [blame^] | 11 | #include "ldt.h" |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 12 | #include "debug.h" |
| 13 | #include "debugstr.h" |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 14 | #include "tweak.h" |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 15 | |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 16 | DEFAULT_DEBUG_CHANNEL(dialog) |
| 17 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 18 | /************************************************************************** |
| 19 | * MSGBOX_DlgProc |
| 20 | * |
| 21 | * Dialog procedure for message boxes. |
| 22 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 23 | static LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message, |
| 24 | WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 25 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 26 | static HFONT hFont = 0; |
| 27 | LPMSGBOXPARAMSA lpmb; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 28 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 29 | RECT rect, textrect; |
| 30 | HWND hItem; |
| 31 | HDC hdc; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 32 | LRESULT lRet; |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 33 | int i, buttons, bwidth, bheight, theight, wwidth, bpos; |
| 34 | int borheight, iheight, tiheight; |
| 35 | |
| 36 | switch(message) { |
| 37 | case WM_INITDIALOG: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 38 | lpmb = (LPMSGBOXPARAMSA)lParam; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 39 | if (TWEAK_WineLook >= WIN95_LOOK) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 40 | NONCLIENTMETRICSA nclm; |
| 41 | INT i; |
| 42 | nclm.cbSize = sizeof(NONCLIENTMETRICSA); |
| 43 | SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0); |
| 44 | hFont = CreateFontIndirectA (&nclm.lfMessageFont); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 45 | /* set button font */ |
| 46 | for (i=1; i < 8; i++) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 47 | SendDlgItemMessageA (hwnd, i, WM_SETFONT, (WPARAM)hFont, 0); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 48 | /* set text font */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 49 | SendDlgItemMessageA (hwnd, 100, WM_SETFONT, (WPARAM)hFont, 0); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 50 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 51 | if (lpmb->lpszCaption) SetWindowTextA(hwnd, lpmb->lpszCaption); |
| 52 | SetWindowTextA(GetDlgItem(hwnd, 100), lpmb->lpszText); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 53 | /* Hide not selected buttons */ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 54 | switch(lpmb->dwStyle & MB_TYPEMASK) { |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 55 | case MB_OK: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 56 | ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 57 | /* fall through */ |
| 58 | case MB_OKCANCEL: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 59 | ShowWindow(GetDlgItem(hwnd, 3), SW_HIDE); |
| 60 | ShowWindow(GetDlgItem(hwnd, 4), SW_HIDE); |
| 61 | ShowWindow(GetDlgItem(hwnd, 5), SW_HIDE); |
| 62 | ShowWindow(GetDlgItem(hwnd, 6), SW_HIDE); |
| 63 | ShowWindow(GetDlgItem(hwnd, 7), SW_HIDE); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 64 | break; |
| 65 | case MB_ABORTRETRYIGNORE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 66 | ShowWindow(GetDlgItem(hwnd, 1), SW_HIDE); |
| 67 | ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE); |
| 68 | ShowWindow(GetDlgItem(hwnd, 6), SW_HIDE); |
| 69 | ShowWindow(GetDlgItem(hwnd, 7), SW_HIDE); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 70 | break; |
| 71 | case MB_YESNO: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 72 | ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 73 | /* fall through */ |
| 74 | case MB_YESNOCANCEL: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 75 | ShowWindow(GetDlgItem(hwnd, 1), SW_HIDE); |
| 76 | ShowWindow(GetDlgItem(hwnd, 3), SW_HIDE); |
| 77 | ShowWindow(GetDlgItem(hwnd, 4), SW_HIDE); |
| 78 | ShowWindow(GetDlgItem(hwnd, 5), SW_HIDE); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 79 | break; |
| 80 | } |
| 81 | /* Set the icon */ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 82 | switch(lpmb->dwStyle & MB_ICONMASK) { |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 83 | case MB_ICONEXCLAMATION: |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 84 | SendDlgItemMessage16(hwnd, stc1, STM_SETICON16, |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 85 | (WPARAM16)LoadIcon16(0, IDI_EXCLAMATION16), 0); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 86 | break; |
| 87 | case MB_ICONQUESTION: |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 88 | SendDlgItemMessage16(hwnd, stc1, STM_SETICON16, |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 89 | (WPARAM16)LoadIcon16(0, IDI_QUESTION16), 0); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 90 | break; |
| 91 | case MB_ICONASTERISK: |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 92 | SendDlgItemMessage16(hwnd, stc1, STM_SETICON16, |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 93 | (WPARAM16)LoadIcon16(0, IDI_ASTERISK16), 0); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 94 | break; |
| 95 | case MB_ICONHAND: |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 96 | default: |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 97 | SendDlgItemMessage16(hwnd, stc1, STM_SETICON16, |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 98 | (WPARAM16)LoadIcon16(0, IDI_HAND16), 0); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 99 | break; |
| 100 | } |
| 101 | |
| 102 | /* Position everything */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 103 | GetWindowRect(hwnd, &rect); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 104 | borheight = rect.bottom - rect.top; |
| 105 | wwidth = rect.right - rect.left; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 106 | GetClientRect(hwnd, &rect); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 107 | borheight -= rect.bottom - rect.top; |
| 108 | |
| 109 | /* Get the icon height */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 110 | GetWindowRect(GetDlgItem(hwnd, 1088), &rect); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 111 | iheight = rect.bottom - rect.top; |
| 112 | |
| 113 | /* Get the number of visible buttons and their width */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 114 | GetWindowRect(GetDlgItem(hwnd, 2), &rect); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 115 | bheight = rect.bottom - rect.top; |
| 116 | bwidth = rect.left; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 117 | GetWindowRect(GetDlgItem(hwnd, 1), &rect); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 118 | bwidth -= rect.left; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 119 | for (buttons = 0, i = 1; i < 8; i++) |
| 120 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 121 | hItem = GetDlgItem(hwnd, i); |
| 122 | if (GetWindowLongA(hItem, GWL_STYLE) & WS_VISIBLE) buttons++; |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | /* Get the text size */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 126 | hItem = GetDlgItem(hwnd, 100); |
| 127 | GetWindowRect(hItem, &textrect); |
| 128 | MapWindowPoints(0, hwnd, (LPPOINT)&textrect, 2); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 129 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 130 | GetClientRect(hItem, &rect); |
| 131 | hdc = GetDC(hItem); |
| 132 | lRet = DrawTextA( hdc, lpmb->lpszText, -1, &rect, |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 133 | DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 134 | theight = rect.bottom - rect.top; |
Alexandre Julliard | 902da69 | 1995-11-05 14:39:02 +0000 | [diff] [blame] | 135 | tiheight = 16 + MAX(iheight, theight); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 136 | ReleaseDC(hItem, hdc); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 137 | |
| 138 | /* Position the text */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 139 | SetWindowPos(hItem, 0, textrect.left, (tiheight - theight) / 2, |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 140 | rect.right - rect.left, theight, |
| 141 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 142 | |
| 143 | /* Position the icon */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 144 | hItem = GetDlgItem(hwnd, 1088); |
| 145 | GetWindowRect(hItem, &rect); |
| 146 | MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2); |
| 147 | SetWindowPos(hItem, 0, rect.left, (tiheight - iheight) / 2, 0, 0, |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 148 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 149 | |
| 150 | /* Resize the window */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 151 | SetWindowPos(hwnd, 0, 0, 0, wwidth, 8 + tiheight + bheight + borheight, |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 152 | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 153 | |
| 154 | /* Position the buttons */ |
| 155 | bpos = (wwidth - bwidth * buttons) / 2; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 156 | GetWindowRect(GetDlgItem(hwnd, 1), &rect); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 157 | for (buttons = i = 0; i < 7; i++) { |
| 158 | /* some arithmetic to get the right order for YesNoCancel windows */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 159 | hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1); |
| 160 | if (GetWindowLongA(hItem, GWL_STYLE) & WS_VISIBLE) { |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 161 | if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8)) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 162 | SetFocus(hItem); |
| 163 | SendMessageA( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE ); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 164 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 165 | SetWindowPos(hItem, 0, bpos, tiheight, 0, 0, |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 166 | SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 167 | bpos += bwidth; |
| 168 | } |
| 169 | } |
| 170 | return 0; |
| 171 | break; |
| 172 | |
| 173 | case WM_COMMAND: |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 174 | switch (wParam) |
| 175 | { |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 176 | case IDOK: |
| 177 | case IDCANCEL: |
| 178 | case IDABORT: |
| 179 | case IDRETRY: |
| 180 | case IDIGNORE: |
| 181 | case IDYES: |
| 182 | case IDNO: |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 183 | if ((TWEAK_WineLook > WIN31_LOOK) && hFont) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 184 | DeleteObject (hFont); |
| 185 | EndDialog(hwnd, wParam); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 186 | break; |
| 187 | } |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 188 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 189 | default: |
| 190 | /* Ok. Ignore all the other messages */ |
| 191 | TRACE (dialog, "Message number %i is being ignored.\n", message); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 192 | break; |
| 193 | } |
| 194 | return 0; |
| 195 | } |
| 196 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 197 | |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 198 | /************************************************************************** |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 199 | * MessageBox16 (USER.1) |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 200 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 201 | INT16 WINAPI MessageBox16( HWND16 hwnd, LPCSTR text, LPCSTR title, UINT16 type) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 202 | { |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 203 | WARN(dialog,"Messagebox\n"); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 204 | return MessageBoxA( hwnd, text, title, type ); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 205 | } |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 206 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 207 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 208 | /************************************************************************** |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 209 | * MessageBox32A (USER32.391) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 210 | * |
| 211 | * NOTES |
| 212 | * The WARN is here to help debug erroneous MessageBoxes |
| 213 | * Use: -debugmsg warn+dialog,+relay |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 214 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 215 | INT WINAPI MessageBoxA(HWND hWnd, LPCSTR text, LPCSTR title, UINT type) |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 216 | { |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 217 | LPVOID template; |
| 218 | HRSRC hRes; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 219 | MSGBOXPARAMSA mbox; |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 220 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 221 | WARN(dialog,"Messagebox\n"); |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 222 | |
| 223 | if(!(hRes = FindResourceA(GetModuleHandleA("USER32"), "MSGBOX", RT_DIALOGA))) |
| 224 | return 0; |
| 225 | if(!(template = (LPVOID)LoadResource(GetModuleHandleA("USER32"), hRes))) |
| 226 | return 0; |
| 227 | |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 228 | if (!text) text="<WINE-NULL>"; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 229 | if (!title) |
| 230 | title="Error"; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 231 | mbox.lpszCaption = title; |
| 232 | mbox.lpszText = text; |
| 233 | mbox.dwStyle = type; |
Marcus Meissner | d7c565f | 1999-05-14 18:39:37 +0000 | [diff] [blame^] | 234 | return DialogBoxIndirectParamA( GetWindowLongA(hWnd,GWL_HINSTANCE), template, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 235 | hWnd, (DLGPROC)MSGBOX_DlgProc, (LPARAM)&mbox ); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 238 | |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 239 | /************************************************************************** |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 240 | * MessageBox32W (USER32.396) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 241 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 242 | INT WINAPI MessageBoxW( HWND hwnd, LPCWSTR text, LPCWSTR title, |
| 243 | UINT type ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 244 | { |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 245 | LPSTR titleA = HEAP_strdupWtoA( GetProcessHeap(), 0, title ); |
| 246 | LPSTR textA = HEAP_strdupWtoA( GetProcessHeap(), 0, text ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 247 | INT ret; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 248 | |
| 249 | WARN(dialog,"Messagebox\n"); |
| 250 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 251 | ret = MessageBoxA( hwnd, textA, titleA, type ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 252 | HeapFree( GetProcessHeap(), 0, titleA ); |
| 253 | HeapFree( GetProcessHeap(), 0, textA ); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 254 | return ret; |
| 255 | } |
| 256 | |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 257 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 258 | /************************************************************************** |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 259 | * MessageBoxEx32A (USER32.392) |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 260 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 261 | INT WINAPI MessageBoxExA( HWND hWnd, LPCSTR text, LPCSTR title, |
| 262 | UINT type, WORD langid ) |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 263 | { |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 264 | WARN(dialog,"Messagebox\n"); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 265 | /* ignore language id for now */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 266 | return MessageBoxA(hWnd,text,title,type); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | /************************************************************************** |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 270 | * MessageBoxEx32W (USER32.393) |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 271 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 272 | INT WINAPI MessageBoxExW( HWND hWnd, LPCWSTR text, LPCWSTR title, |
| 273 | UINT type, WORD langid ) |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 274 | { |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 275 | WARN(dialog,"Messagebox\n"); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 276 | /* ignore language id for now */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 277 | return MessageBoxW(hWnd,text,title,type); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 278 | } |
| 279 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 280 | /************************************************************************** |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 281 | * MessageBoxIndirect16 (USER.827) |
| 282 | */ |
| 283 | INT16 WINAPI MessageBoxIndirect16( LPMSGBOXPARAMS16 msgbox ) |
| 284 | { |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 285 | LPVOID template; |
| 286 | HRSRC hRes; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 287 | MSGBOXPARAMSA msgbox32; |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 288 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 289 | WARN(dialog,"Messagebox\n"); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 290 | |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 291 | if(!(hRes = FindResourceA(GetModuleHandleA("USER32"), "MSGBOX", RT_DIALOGA))) |
| 292 | return 0; |
| 293 | if(!(template = (LPVOID)LoadResource(GetModuleHandleA("USER32"), hRes))) |
| 294 | return 0; |
| 295 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 296 | msgbox32.cbSize = msgbox->cbSize; |
| 297 | msgbox32.hwndOwner = msgbox->hwndOwner; |
| 298 | msgbox32.hInstance = msgbox->hInstance; |
| 299 | msgbox32.lpszText = PTR_SEG_TO_LIN(msgbox->lpszText); |
| 300 | msgbox32.lpszCaption = PTR_SEG_TO_LIN(msgbox->lpszCaption); |
| 301 | msgbox32.dwStyle = msgbox->dwStyle; |
| 302 | msgbox32.lpszIcon = PTR_SEG_TO_LIN(msgbox->lpszIcon); |
| 303 | msgbox32.dwContextHelpId = msgbox->dwContextHelpId; |
| 304 | msgbox32.lpfnMsgBoxCallback = msgbox->lpfnMsgBoxCallback; |
| 305 | msgbox32.dwLanguageId = msgbox->dwLanguageId; |
| 306 | |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 307 | return DialogBoxIndirectParamA( msgbox32.hInstance, template, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 308 | msgbox32.hwndOwner, (DLGPROC)MSGBOX_DlgProc, |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 309 | (LPARAM)&msgbox32 ); |
| 310 | } |
| 311 | |
| 312 | /************************************************************************** |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 313 | * MessageBoxIndirect32A (USER32.394) |
| 314 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 315 | INT WINAPI MessageBoxIndirectA( LPMSGBOXPARAMSA msgbox ) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 316 | { |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 317 | LPVOID template; |
| 318 | HRSRC hRes; |
| 319 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 320 | WARN(dialog,"Messagebox\n"); |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 321 | |
| 322 | if(!(hRes = FindResourceA(GetModuleHandleA("USER32"), "MSGBOX", RT_DIALOGA))) |
| 323 | return 0; |
| 324 | if(!(template = (LPVOID)LoadResource(GetModuleHandleA("USER32"), hRes))) |
| 325 | return 0; |
| 326 | |
| 327 | return DialogBoxIndirectParamA( msgbox->hInstance, template, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 328 | msgbox->hwndOwner, (DLGPROC)MSGBOX_DlgProc, |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 329 | (LPARAM)msgbox ); |
| 330 | } |
| 331 | |
| 332 | /************************************************************************** |
| 333 | * MessageBoxIndirect32W (USER32.395) |
| 334 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 335 | INT WINAPI MessageBoxIndirectW( LPMSGBOXPARAMSW msgbox ) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 336 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 337 | MSGBOXPARAMSA msgboxa; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 338 | WARN(dialog,"Messagebox\n"); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 339 | |
| 340 | memcpy(&msgboxa,msgbox,sizeof(msgboxa)); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 341 | if (msgbox->lpszCaption) |
Andreas Mohr | 7a6228d | 1998-12-11 09:16:48 +0000 | [diff] [blame] | 342 | lstrcpyWtoA((LPSTR)msgboxa.lpszCaption,msgbox->lpszCaption); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 343 | if (msgbox->lpszText) |
Andreas Mohr | 7a6228d | 1998-12-11 09:16:48 +0000 | [diff] [blame] | 344 | lstrcpyWtoA((LPSTR)msgboxa.lpszText,msgbox->lpszText); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 345 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 346 | return MessageBoxIndirectA(&msgboxa); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 347 | } |
| 348 | |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 349 | |
| 350 | /************************************************************************** |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 351 | * FatalAppExit16 (KERNEL.137) |
| 352 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 353 | void WINAPI FatalAppExit16( UINT16 action, LPCSTR str ) |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 354 | { |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 355 | WARN(dialog,"AppExit\n"); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 356 | FatalAppExitA( action, str ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | |
| 360 | /************************************************************************** |
| 361 | * FatalAppExit32A (KERNEL32.108) |
| 362 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 363 | void WINAPI FatalAppExitA( UINT action, LPCSTR str ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 364 | { |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 365 | WARN(dialog,"AppExit\n"); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 366 | MessageBoxA( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 367 | ExitProcess(0); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | |
| 371 | /************************************************************************** |
| 372 | * FatalAppExit32W (KERNEL32.109) |
| 373 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 374 | void WINAPI FatalAppExitW( UINT action, LPCWSTR str ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 375 | { |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 376 | WARN(dialog,"AppExit\n"); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 377 | MessageBoxW( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 378 | ExitProcess(0); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 379 | } |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 380 | |
| 381 | |