blob: 7db5fc367b16cba21b20c6747bde4a400c0f1f20 [file] [log] [blame]
Alexandre Julliard2787be81995-05-22 18:23:01 +00001/*
2 * Message boxes
3 *
4 * Copyright 1995 Bernd Schmidt
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00005 *
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 Julliard2787be81995-05-22 18:23:01 +000019 */
20
David Luyeree517e81999-02-28 12:27:56 +000021#include <string.h>
Patrik Stridvall1ed4ecf1999-06-26 14:58:24 +000022
Jeremy Whited3e22d92000-02-10 19:03:02 +000023#include "windef.h"
24#include "wingdi.h"
Patrik Stridvall1ed4ecf1999-06-26 14:58:24 +000025#include "wine/winbase16.h"
Michael Vekslerca1bc861999-01-01 18:57:33 +000026#include "wine/winuser16.h"
Alexandre Julliard2787be81995-05-22 18:23:01 +000027#include "dlgs.h"
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000028#include "heap.h"
Alexandre Julliarda41b2cf2001-01-15 20:12:55 +000029#include "user.h"
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000030#include "wine/debug.h"
Alexandre Julliard2787be81995-05-22 18:23:01 +000031
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000032WINE_DEFAULT_DEBUG_CHANNEL(dialog);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000033
Richard Cohend38bcea1999-09-03 16:38:03 +000034#define MSGBOX_IDICON 1088
35#define MSGBOX_IDTEXT 100
36
37static 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 Pouechcd168e71999-11-07 23:36:31 +000046 LPCSTR lpszText;
47 char buf[256];
48
Richard Cohend38bcea1999-09-03 16:38:03 +000049 if (TWEAK_WineLook >= WIN95_LOOK) {
50 NONCLIENTMETRICSA nclm;
Richard Cohend38bcea1999-09-03 16:38:03 +000051 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 Pouechcd168e71999-11-07 23:36:31 +000060 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 Cohend38bcea1999-09-03 16:38:03 +000075 /* 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 Julliard2682bc22000-11-27 22:03:23 +0000113 SendDlgItemMessageA(hwnd, stc1, STM_SETICON, LoadIconA(0, IDI_EXCLAMATIONA), 0);
Richard Cohend38bcea1999-09-03 16:38:03 +0000114 break;
115 case MB_ICONQUESTION:
Alexandre Julliard2682bc22000-11-27 22:03:23 +0000116 SendDlgItemMessageA(hwnd, stc1, STM_SETICON, LoadIconA(0, IDI_QUESTIONA), 0);
Richard Cohend38bcea1999-09-03 16:38:03 +0000117 break;
118 case MB_ICONASTERISK:
Alexandre Julliard2682bc22000-11-27 22:03:23 +0000119 SendDlgItemMessageA(hwnd, stc1, STM_SETICON, LoadIconA(0, IDI_ASTERISKA), 0);
Richard Cohend38bcea1999-09-03 16:38:03 +0000120 break;
121 case MB_ICONHAND:
Alexandre Julliard2682bc22000-11-27 22:03:23 +0000122 SendDlgItemMessageA(hwnd, stc1, STM_SETICON, LoadIconA(0, IDI_HANDA), 0);
Haithem Hmidafa861c22000-07-09 12:16:36 +0000123 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 Cohend38bcea1999-09-03 16:38:03 +0000128 break;
129 }
Vincent Béron9a624912002-05-31 23:06:46 +0000130
Richard Cohend38bcea1999-09-03 16:38:03 +0000131 /* 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éron9a624912002-05-31 23:06:46 +0000138
Richard Cohend38bcea1999-09-03 16:38:03 +0000139 /* 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éron9a624912002-05-31 23:06:46 +0000145
Richard Cohend38bcea1999-09-03 16:38:03 +0000146 hdc = GetDC(hwnd);
147 if (hFont)
148 hPrevFont = SelectObject(hdc, hFont);
Vincent Béron9a624912002-05-31 23:06:46 +0000149
Richard Cohend38bcea1999-09-03 16:38:03 +0000150 /* 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 Gouget6d77d3a2000-03-25 21:44:35 +0000170 bw = max(bw, bh * 2);
Richard Cohend38bcea1999-09-03 16:38:03 +0000171 /* Button white space */
172 bh = bh * 2;
173 bw = bw * 2;
174 bspace = bw/3; /* Space between buttons */
Vincent Béron9a624912002-05-31 23:06:46 +0000175
Richard Cohend38bcea1999-09-03 16:38:03 +0000176 /* Get the text size */
177 GetClientRect(GetDlgItem(hwnd, MSGBOX_IDTEXT), &rect);
178 rect.top = rect.left = rect.bottom = 0;
Eric Pouechcd168e71999-11-07 23:36:31 +0000179 DrawTextA( hdc, lpszText, -1, &rect,
Richard Cohend38bcea1999-09-03 16:38:03 +0000180 DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
181 /* Min text width corresponds to space for the buttons */
182 tleft = 2 * ileft + iwidth;
Francois Gouget6d77d3a2000-03-25 21:44:35 +0000183 twidth = max((bw + bspace) * buttons + bspace - tleft, rect.right);
Richard Cohend38bcea1999-09-03 16:38:03 +0000184 theight = rect.bottom;
Vincent Béron9a624912002-05-31 23:06:46 +0000185
Richard Cohend38bcea1999-09-03 16:38:03 +0000186 if (hFont)
187 SelectObject(hdc, hPrevFont);
188 ReleaseDC(hItem, hdc);
Vincent Béron9a624912002-05-31 23:06:46 +0000189
Francois Gouget6d77d3a2000-03-25 21:44:35 +0000190 tiheight = 16 + max(iheight, theight);
Richard Cohend38bcea1999-09-03 16:38:03 +0000191 wwidth = tleft + twidth + ileft + borwidth;
192 wheight = 8 + tiheight + bh + borheight;
Vincent Béron9a624912002-05-31 23:06:46 +0000193
Richard Cohend38bcea1999-09-03 16:38:03 +0000194 /* Resize the window */
195 SetWindowPos(hwnd, 0, 0, 0, wwidth, wheight,
196 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
Andreas Mohr577e2292001-04-13 22:24:18 +0000197
Richard Cohend38bcea1999-09-03 16:38:03 +0000198 /* 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éron9a624912002-05-31 23:06:46 +0000201
Richard Cohend38bcea1999-09-03 16:38:03 +0000202 /* 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éron9a624912002-05-31 23:06:46 +0000205
Richard Cohend38bcea1999-09-03 16:38:03 +0000206 /* 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 Mohr577e2292001-04-13 22:24:18 +0000221
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éron9a624912002-05-31 23:06:46 +0000237
Richard Cohend38bcea1999-09-03 16:38:03 +0000238 return hFont;
239}
240
241
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000242/**************************************************************************
243 * MSGBOX_DlgProc
244 *
245 * Dialog procedure for message boxes.
246 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000247static LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message,
248 WPARAM wParam, LPARAM lParam )
Vincent Béron9a624912002-05-31 23:06:46 +0000249{
Alexandre Julliard04699cc1999-09-04 11:21:10 +0000250 static HFONT hFont;
Alexandre Julliard2787be81995-05-22 18:23:01 +0000251 switch(message) {
252 case WM_INITDIALOG:
Richard Cohend38bcea1999-09-03 16:38:03 +0000253 hFont = MSGBOX_OnInit(hwnd, (LPMSGBOXPARAMSA)lParam);
Alexandre Julliard2787be81995-05-22 18:23:01 +0000254 return 0;
Vincent Béron9a624912002-05-31 23:06:46 +0000255
Alexandre Julliard2787be81995-05-22 18:23:01 +0000256 case WM_COMMAND:
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000257 switch (wParam)
258 {
Alexandre Julliard2787be81995-05-22 18:23:01 +0000259 case IDOK:
260 case IDCANCEL:
261 case IDABORT:
262 case IDRETRY:
263 case IDIGNORE:
264 case IDYES:
265 case IDNO:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000266 EndDialog(hwnd, wParam);
Richard Cohend38bcea1999-09-03 16:38:03 +0000267 if (hFont)
268 DeleteObject(hFont);
Alexandre Julliard2787be81995-05-22 18:23:01 +0000269 break;
270 }
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000271
Alexandre Julliard54c27111998-03-29 19:44:57 +0000272 default:
273 /* Ok. Ignore all the other messages */
Andreas Mohr577e2292001-04-13 22:24:18 +0000274 TRACE("Message number 0x%04x is being ignored.\n", message);
Alexandre Julliard2787be81995-05-22 18:23:01 +0000275 break;
276 }
277 return 0;
278}
279
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000280
Alexandre Julliard2787be81995-05-22 18:23:01 +0000281/**************************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000282 * MessageBoxA (USER32.@)
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000283 *
284 * NOTES
285 * The WARN is here to help debug erroneous MessageBoxes
286 * Use: -debugmsg warn+dialog,+relay
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000287 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000288INT WINAPI MessageBoxA(HWND hWnd, LPCSTR text, LPCSTR title, UINT type)
Alexandre Julliard2787be81995-05-22 18:23:01 +0000289{
Bertho Stultiensd1895a71999-04-25 18:31:35 +0000290 LPVOID template;
291 HRSRC hRes;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000292 MSGBOXPARAMSA mbox;
Bertho Stultiensd1895a71999-04-25 18:31:35 +0000293
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000294 WARN("Messagebox\n");
Bertho Stultiensd1895a71999-04-25 18:31:35 +0000295
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 Julliard349a9531997-02-02 19:01:52 +0000301 if (!text) text="<WINE-NULL>";
Alexandre Julliard54c27111998-03-29 19:44:57 +0000302 if (!title)
303 title="Error";
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000304 mbox.lpszCaption = title;
305 mbox.lpszText = text;
306 mbox.dwStyle = type;
Marcus Meissnerd7c565f1999-05-14 18:39:37 +0000307 return DialogBoxIndirectParamA( GetWindowLongA(hWnd,GWL_HINSTANCE), template,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000308 hWnd, (DLGPROC)MSGBOX_DlgProc, (LPARAM)&mbox );
Alexandre Julliard2787be81995-05-22 18:23:01 +0000309}
310
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000311
Alexandre Julliard2787be81995-05-22 18:23:01 +0000312/**************************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000313 * MessageBoxW (USER32.@)
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000314 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000315INT WINAPI MessageBoxW( HWND hwnd, LPCWSTR text, LPCWSTR title,
316 UINT type )
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000317{
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000318 LPSTR titleA = HEAP_strdupWtoA( GetProcessHeap(), 0, title );
319 LPSTR textA = HEAP_strdupWtoA( GetProcessHeap(), 0, text );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000320 INT ret;
Vincent Béron9a624912002-05-31 23:06:46 +0000321
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000322 WARN("Messagebox\n");
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000323
Alexandre Julliarda3960291999-02-26 11:11:13 +0000324 ret = MessageBoxA( hwnd, textA, titleA, type );
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000325 HeapFree( GetProcessHeap(), 0, titleA );
326 HeapFree( GetProcessHeap(), 0, textA );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000327 return ret;
328}
329
Alexandre Julliard2787be81995-05-22 18:23:01 +0000330
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000331/**************************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000332 * MessageBoxExA (USER32.@)
Alexandre Julliard349a9531997-02-02 19:01:52 +0000333 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000334INT WINAPI MessageBoxExA( HWND hWnd, LPCSTR text, LPCSTR title,
335 UINT type, WORD langid )
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000336{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000337 WARN("Messagebox\n");
Alexandre Julliard349a9531997-02-02 19:01:52 +0000338 /* ignore language id for now */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000339 return MessageBoxA(hWnd,text,title,type);
Alexandre Julliard349a9531997-02-02 19:01:52 +0000340}
341
342/**************************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000343 * MessageBoxExW (USER32.@)
Alexandre Julliard349a9531997-02-02 19:01:52 +0000344 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000345INT WINAPI MessageBoxExW( HWND hWnd, LPCWSTR text, LPCWSTR title,
346 UINT type, WORD langid )
Alexandre Julliard349a9531997-02-02 19:01:52 +0000347{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000348 WARN("Messagebox\n");
Alexandre Julliard349a9531997-02-02 19:01:52 +0000349 /* ignore language id for now */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000350 return MessageBoxW(hWnd,text,title,type);
Alexandre Julliard349a9531997-02-02 19:01:52 +0000351}
352
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000353/**************************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000354 * MessageBoxIndirectA (USER32.@)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000355 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000356INT WINAPI MessageBoxIndirectA( LPMSGBOXPARAMSA msgbox )
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000357{
Bertho Stultiensd1895a71999-04-25 18:31:35 +0000358 LPVOID template;
359 HRSRC hRes;
360
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000361 WARN("Messagebox\n");
Bertho Stultiensd1895a71999-04-25 18:31:35 +0000362
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 Julliarda3960291999-02-26 11:11:13 +0000369 msgbox->hwndOwner, (DLGPROC)MSGBOX_DlgProc,
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000370 (LPARAM)msgbox );
371}
372
373/**************************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000374 * MessageBoxIndirectW (USER32.@)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000375 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000376INT WINAPI MessageBoxIndirectW( LPMSGBOXPARAMSW msgbox )
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000377{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000378 MSGBOXPARAMSA msgboxa;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000379 memcpy(&msgboxa,msgbox,sizeof(msgboxa));
Alexandre Julliard24a62ab2000-11-28 22:40:56 +0000380 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 Julliarda3960291999-02-26 11:11:13 +0000383 return MessageBoxIndirectA(&msgboxa);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000384}