Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Message boxes |
| 3 | * |
| 4 | * Copyright 1995 Bernd Schmidt |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
David Luyer | ee517e8 | 1999-02-28 12:27:56 +0000 | [diff] [blame] | 21 | #include <string.h> |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 22 | |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 23 | #include "windef.h" |
| 24 | #include "wingdi.h" |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 25 | #include "wine/winbase16.h" |
Michael Veksler | ca1bc86 | 1999-01-01 18:57:33 +0000 | [diff] [blame] | 26 | #include "wine/winuser16.h" |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 27 | #include "dlgs.h" |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 28 | #include "heap.h" |
Alexandre Julliard | a41b2cf | 2001-01-15 20:12:55 +0000 | [diff] [blame] | 29 | #include "user.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 30 | #include "wine/debug.h" |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 31 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 32 | WINE_DEFAULT_DEBUG_CHANNEL(dialog); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 33 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 34 | #define MSGBOX_IDICON 1088 |
| 35 | #define MSGBOX_IDTEXT 100 |
| 36 | |
| 37 | static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMSA lpmb) |
| 38 | { |
| 39 | static HFONT hFont = 0, hPrevFont = 0; |
| 40 | RECT rect; |
| 41 | HWND hItem; |
| 42 | HDC hdc; |
| 43 | int i, buttons; |
| 44 | int bspace, bw, bh, theight, tleft, wwidth, wheight, bpos; |
| 45 | int borheight, borwidth, iheight, ileft, iwidth, twidth, tiheight; |
Eric Pouech | cd168e7 | 1999-11-07 23:36:31 +0000 | [diff] [blame] | 46 | LPCSTR lpszText; |
| 47 | char buf[256]; |
| 48 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 49 | if (TWEAK_WineLook >= WIN95_LOOK) { |
| 50 | NONCLIENTMETRICSA nclm; |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 51 | nclm.cbSize = sizeof(NONCLIENTMETRICSA); |
| 52 | SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0); |
| 53 | hFont = CreateFontIndirectA (&nclm.lfMessageFont); |
| 54 | /* set button font */ |
| 55 | for (i=1; i < 8; i++) |
| 56 | SendDlgItemMessageA (hwnd, i, WM_SETFONT, (WPARAM)hFont, 0); |
| 57 | /* set text font */ |
| 58 | SendDlgItemMessageA (hwnd, MSGBOX_IDTEXT, WM_SETFONT, (WPARAM)hFont, 0); |
| 59 | } |
Eric Pouech | cd168e7 | 1999-11-07 23:36:31 +0000 | [diff] [blame] | 60 | if (HIWORD(lpmb->lpszCaption)) { |
| 61 | SetWindowTextA(hwnd, lpmb->lpszCaption); |
| 62 | } else { |
| 63 | if (LoadStringA(lpmb->hInstance, LOWORD(lpmb->lpszCaption), buf, sizeof(buf))) |
| 64 | SetWindowTextA(hwnd, buf); |
| 65 | } |
| 66 | if (HIWORD(lpmb->lpszText)) { |
| 67 | lpszText = lpmb->lpszText; |
| 68 | } else { |
| 69 | lpszText = buf; |
| 70 | if (!LoadStringA(lpmb->hInstance, LOWORD(lpmb->lpszText), buf, sizeof(buf))) |
| 71 | *buf = 0; /* FIXME ?? */ |
| 72 | } |
| 73 | SetWindowTextA(GetDlgItem(hwnd, MSGBOX_IDTEXT), lpszText); |
| 74 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 75 | /* Hide not selected buttons */ |
| 76 | switch(lpmb->dwStyle & MB_TYPEMASK) { |
| 77 | case MB_OK: |
| 78 | ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE); |
| 79 | /* fall through */ |
| 80 | case MB_OKCANCEL: |
| 81 | ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE); |
| 82 | ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE); |
| 83 | ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE); |
| 84 | ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE); |
| 85 | ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE); |
| 86 | break; |
| 87 | case MB_ABORTRETRYIGNORE: |
| 88 | ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE); |
| 89 | ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE); |
| 90 | ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE); |
| 91 | ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE); |
| 92 | break; |
| 93 | case MB_YESNO: |
| 94 | ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE); |
| 95 | /* fall through */ |
| 96 | case MB_YESNOCANCEL: |
| 97 | ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE); |
| 98 | ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE); |
| 99 | ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE); |
| 100 | ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE); |
| 101 | break; |
| 102 | case MB_RETRYCANCEL: |
| 103 | ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE); |
| 104 | ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE); |
| 105 | ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE); |
| 106 | ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE); |
| 107 | ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE); |
| 108 | break; |
| 109 | } |
| 110 | /* Set the icon */ |
| 111 | switch(lpmb->dwStyle & MB_ICONMASK) { |
| 112 | case MB_ICONEXCLAMATION: |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 113 | SendDlgItemMessageA(hwnd, stc1, STM_SETICON, LoadIconA(0, IDI_EXCLAMATIONA), 0); |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 114 | break; |
| 115 | case MB_ICONQUESTION: |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 116 | SendDlgItemMessageA(hwnd, stc1, STM_SETICON, LoadIconA(0, IDI_QUESTIONA), 0); |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 117 | break; |
| 118 | case MB_ICONASTERISK: |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 119 | SendDlgItemMessageA(hwnd, stc1, STM_SETICON, LoadIconA(0, IDI_ASTERISKA), 0); |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 120 | break; |
| 121 | case MB_ICONHAND: |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 122 | SendDlgItemMessageA(hwnd, stc1, STM_SETICON, LoadIconA(0, IDI_HANDA), 0); |
Haithem Hmida | fa861c2 | 2000-07-09 12:16:36 +0000 | [diff] [blame] | 123 | break; |
| 124 | default: |
| 125 | /* By default, Windows 95/98/NT do not associate an icon to message boxes. |
| 126 | * So wine should do the same. |
| 127 | */ |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 128 | break; |
| 129 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 130 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 131 | /* Position everything */ |
| 132 | GetWindowRect(hwnd, &rect); |
| 133 | borheight = rect.bottom - rect.top; |
| 134 | borwidth = rect.right - rect.left; |
| 135 | GetClientRect(hwnd, &rect); |
| 136 | borheight -= rect.bottom - rect.top; |
| 137 | borwidth -= rect.right - rect.left; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 138 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 139 | /* Get the icon height */ |
| 140 | GetWindowRect(GetDlgItem(hwnd, MSGBOX_IDICON), &rect); |
| 141 | MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2); |
| 142 | iheight = rect.bottom - rect.top; |
| 143 | ileft = rect.left; |
| 144 | iwidth = rect.right - ileft; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 145 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 146 | hdc = GetDC(hwnd); |
| 147 | if (hFont) |
| 148 | hPrevFont = SelectObject(hdc, hFont); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 149 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 150 | /* Get the number of visible buttons and their size */ |
| 151 | bh = bw = 1; /* Minimum button sizes */ |
| 152 | for (buttons = 0, i = 1; i < 8; i++) |
| 153 | { |
| 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 | } |
| 169 | } |
Francois Gouget | 6d77d3a | 2000-03-25 21:44:35 +0000 | [diff] [blame] | 170 | bw = max(bw, bh * 2); |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 171 | /* Button white space */ |
| 172 | bh = bh * 2; |
| 173 | bw = bw * 2; |
| 174 | bspace = bw/3; /* Space between buttons */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 175 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 176 | /* Get the text size */ |
| 177 | GetClientRect(GetDlgItem(hwnd, MSGBOX_IDTEXT), &rect); |
| 178 | rect.top = rect.left = rect.bottom = 0; |
Eric Pouech | cd168e7 | 1999-11-07 23:36:31 +0000 | [diff] [blame] | 179 | DrawTextA( hdc, lpszText, -1, &rect, |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 180 | DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT); |
| 181 | /* Min text width corresponds to space for the buttons */ |
| 182 | tleft = 2 * ileft + iwidth; |
Francois Gouget | 6d77d3a | 2000-03-25 21:44:35 +0000 | [diff] [blame] | 183 | twidth = max((bw + bspace) * buttons + bspace - tleft, rect.right); |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 184 | theight = rect.bottom; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 185 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 186 | if (hFont) |
| 187 | SelectObject(hdc, hPrevFont); |
| 188 | ReleaseDC(hItem, hdc); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 189 | |
Francois Gouget | 6d77d3a | 2000-03-25 21:44:35 +0000 | [diff] [blame] | 190 | tiheight = 16 + max(iheight, theight); |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 191 | wwidth = tleft + twidth + ileft + borwidth; |
| 192 | wheight = 8 + tiheight + bh + borheight; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 193 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 194 | /* Resize the window */ |
| 195 | SetWindowPos(hwnd, 0, 0, 0, wwidth, wheight, |
| 196 | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); |
Andreas Mohr | 577e229 | 2001-04-13 22:24:18 +0000 | [diff] [blame] | 197 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 198 | /* Position the icon */ |
| 199 | SetWindowPos(GetDlgItem(hwnd, MSGBOX_IDICON), 0, ileft, (tiheight - iheight) / 2, 0, 0, |
| 200 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 201 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 202 | /* Position the text */ |
| 203 | SetWindowPos(GetDlgItem(hwnd, MSGBOX_IDTEXT), 0, tleft, (tiheight - theight) / 2, twidth, theight, |
| 204 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 205 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 206 | /* Position the buttons */ |
| 207 | bpos = (wwidth - (bw + bspace) * buttons + bspace) / 2; |
| 208 | for (buttons = i = 0; i < 7; i++) { |
| 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 | } |
| 220 | } |
Andreas Mohr | 577e229 | 2001-04-13 22:24:18 +0000 | [diff] [blame] | 221 | |
| 222 | /* handle modal MessageBoxes */ |
| 223 | if (lpmb->dwStyle & (MB_TASKMODAL|MB_SYSTEMMODAL)) |
| 224 | { |
| 225 | FIXME("%s modal msgbox ! Not modal yet.\n", |
| 226 | lpmb->dwStyle & MB_TASKMODAL ? "task" : "system"); |
| 227 | /* Probably do EnumTaskWindows etc. here for TASKMODAL |
| 228 | * and work your way up to the top - I'm lazy (HWND_TOP) */ |
| 229 | SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, |
| 230 | SWP_NOSIZE | SWP_NOMOVE); |
| 231 | if (lpmb->dwStyle & MB_TASKMODAL) |
| 232 | /* at least MB_TASKMODAL seems to imply a ShowWindow */ |
| 233 | ShowWindow(hwnd, SW_SHOW); |
| 234 | } |
| 235 | if (lpmb->dwStyle & MB_APPLMODAL) |
| 236 | FIXME("app modal msgbox ! Not modal yet.\n"); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 237 | |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 238 | return hFont; |
| 239 | } |
| 240 | |
| 241 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 242 | /************************************************************************** |
| 243 | * MSGBOX_DlgProc |
| 244 | * |
| 245 | * Dialog procedure for message boxes. |
| 246 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 247 | static LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message, |
| 248 | WPARAM wParam, LPARAM lParam ) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 249 | { |
Alexandre Julliard | 04699cc | 1999-09-04 11:21:10 +0000 | [diff] [blame] | 250 | static HFONT hFont; |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 251 | switch(message) { |
| 252 | case WM_INITDIALOG: |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 253 | hFont = MSGBOX_OnInit(hwnd, (LPMSGBOXPARAMSA)lParam); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 254 | return 0; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 255 | |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 256 | case WM_COMMAND: |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 257 | switch (wParam) |
| 258 | { |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 259 | case IDOK: |
| 260 | case IDCANCEL: |
| 261 | case IDABORT: |
| 262 | case IDRETRY: |
| 263 | case IDIGNORE: |
| 264 | case IDYES: |
| 265 | case IDNO: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 266 | EndDialog(hwnd, wParam); |
Richard Cohen | d38bcea | 1999-09-03 16:38:03 +0000 | [diff] [blame] | 267 | if (hFont) |
| 268 | DeleteObject(hFont); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 269 | break; |
| 270 | } |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 271 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 272 | default: |
| 273 | /* Ok. Ignore all the other messages */ |
Andreas Mohr | 577e229 | 2001-04-13 22:24:18 +0000 | [diff] [blame] | 274 | TRACE("Message number 0x%04x is being ignored.\n", message); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 275 | break; |
| 276 | } |
| 277 | return 0; |
| 278 | } |
| 279 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 280 | |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 281 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 282 | * MessageBoxA (USER32.@) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 283 | * |
| 284 | * NOTES |
| 285 | * The WARN is here to help debug erroneous MessageBoxes |
| 286 | * Use: -debugmsg warn+dialog,+relay |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 287 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 288 | INT WINAPI MessageBoxA(HWND hWnd, LPCSTR text, LPCSTR title, UINT type) |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 289 | { |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 290 | LPVOID template; |
| 291 | HRSRC hRes; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 292 | MSGBOXPARAMSA mbox; |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 293 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 294 | WARN("Messagebox\n"); |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 295 | |
| 296 | if(!(hRes = FindResourceA(GetModuleHandleA("USER32"), "MSGBOX", RT_DIALOGA))) |
| 297 | return 0; |
| 298 | if(!(template = (LPVOID)LoadResource(GetModuleHandleA("USER32"), hRes))) |
| 299 | return 0; |
| 300 | |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 301 | if (!text) text="<WINE-NULL>"; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 302 | if (!title) |
| 303 | title="Error"; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 304 | mbox.lpszCaption = title; |
| 305 | mbox.lpszText = text; |
| 306 | mbox.dwStyle = type; |
Marcus Meissner | d7c565f | 1999-05-14 18:39:37 +0000 | [diff] [blame] | 307 | return DialogBoxIndirectParamA( GetWindowLongA(hWnd,GWL_HINSTANCE), template, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 308 | hWnd, (DLGPROC)MSGBOX_DlgProc, (LPARAM)&mbox ); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 309 | } |
| 310 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 311 | |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 312 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 313 | * MessageBoxW (USER32.@) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 314 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 315 | INT WINAPI MessageBoxW( HWND hwnd, LPCWSTR text, LPCWSTR title, |
| 316 | UINT type ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 317 | { |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 318 | LPSTR titleA = HEAP_strdupWtoA( GetProcessHeap(), 0, title ); |
| 319 | LPSTR textA = HEAP_strdupWtoA( GetProcessHeap(), 0, text ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 320 | INT ret; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 321 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 322 | WARN("Messagebox\n"); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 323 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 324 | ret = MessageBoxA( hwnd, textA, titleA, type ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 325 | HeapFree( GetProcessHeap(), 0, titleA ); |
| 326 | HeapFree( GetProcessHeap(), 0, textA ); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 327 | return ret; |
| 328 | } |
| 329 | |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 330 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 331 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 332 | * MessageBoxExA (USER32.@) |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 333 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 334 | INT WINAPI MessageBoxExA( HWND hWnd, LPCSTR text, LPCSTR title, |
| 335 | UINT type, WORD langid ) |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 336 | { |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 337 | WARN("Messagebox\n"); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 338 | /* ignore language id for now */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 339 | return MessageBoxA(hWnd,text,title,type); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 343 | * MessageBoxExW (USER32.@) |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 344 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 345 | INT WINAPI MessageBoxExW( HWND hWnd, LPCWSTR text, LPCWSTR title, |
| 346 | UINT type, WORD langid ) |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 347 | { |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 348 | WARN("Messagebox\n"); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 349 | /* ignore language id for now */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 350 | return MessageBoxW(hWnd,text,title,type); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 353 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 354 | * MessageBoxIndirectA (USER32.@) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 355 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 356 | INT WINAPI MessageBoxIndirectA( LPMSGBOXPARAMSA msgbox ) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 357 | { |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 358 | LPVOID template; |
| 359 | HRSRC hRes; |
| 360 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 361 | WARN("Messagebox\n"); |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 362 | |
| 363 | if(!(hRes = FindResourceA(GetModuleHandleA("USER32"), "MSGBOX", RT_DIALOGA))) |
| 364 | return 0; |
| 365 | if(!(template = (LPVOID)LoadResource(GetModuleHandleA("USER32"), hRes))) |
| 366 | return 0; |
| 367 | |
| 368 | return DialogBoxIndirectParamA( msgbox->hInstance, template, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 369 | msgbox->hwndOwner, (DLGPROC)MSGBOX_DlgProc, |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 370 | (LPARAM)msgbox ); |
| 371 | } |
| 372 | |
| 373 | /************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 374 | * MessageBoxIndirectW (USER32.@) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 375 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 376 | INT WINAPI MessageBoxIndirectW( LPMSGBOXPARAMSW msgbox ) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 377 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 378 | MSGBOXPARAMSA msgboxa; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 379 | memcpy(&msgboxa,msgbox,sizeof(msgboxa)); |
Alexandre Julliard | 24a62ab | 2000-11-28 22:40:56 +0000 | [diff] [blame] | 380 | msgboxa.lpszCaption = HEAP_strdupWtoA( GetProcessHeap(), 0, msgbox->lpszCaption ); |
| 381 | msgboxa.lpszText = HEAP_strdupWtoA( GetProcessHeap(), 0, msgbox->lpszText ); |
| 382 | msgboxa.lpszIcon = HEAP_strdupWtoA( GetProcessHeap(), 0, msgbox->lpszIcon ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 383 | return MessageBoxIndirectA(&msgboxa); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 384 | } |