blob: 54882967dd3bb6c02ea90d04d143ae73e30ba671 [file] [log] [blame]
Alexandre Julliard0e607781993-11-03 19:23:37 +00001/*
2 * Dialog functions
3 *
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00004 * Copyright 1993, 1994, 1996 Alexandre Julliard
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 Julliard59730ae1996-03-24 16:20:51 +000019 */
Alexandre Julliard0e607781993-11-03 19:23:37 +000020
François Gouget14259412001-11-06 20:57:11 +000021#include "config.h"
Francois Gouget386cf6e2001-10-14 16:25:47 +000022#include "wine/port.h"
23
Alexandre Julliardda0cfb31996-12-01 17:17:47 +000024#include <ctype.h>
Patrik Stridvall1e1cf481998-10-17 12:56:00 +000025#include <errno.h>
Alexandre Julliard01d63461997-01-20 19:43:45 +000026#include <limits.h>
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000027#include <stdlib.h>
Jeremy Whited3e22d92000-02-10 19:03:02 +000028#include <stdio.h>
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000029#include <string.h>
François Gouget44a18222000-12-19 04:53:20 +000030
Jeremy Whited3e22d92000-02-10 19:03:02 +000031#include "windef.h"
Alexandre Julliard24a62ab2000-11-28 22:40:56 +000032#include "winnls.h"
François Gouget44a18222000-12-19 04:53:20 +000033#include "winbase.h"
Jeremy Whited3e22d92000-02-10 19:03:02 +000034#include "wingdi.h"
Marcus Meissner61afa331999-02-22 10:16:00 +000035#include "winuser.h"
Slava Monich3a170a11999-06-06 09:03:08 +000036#include "windowsx.h"
Marcus Meissner61afa331999-02-22 10:16:00 +000037#include "wine/winuser16.h"
38#include "wine/winbase16.h"
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +000039#include "wine/unicode.h"
Alexandre Julliard91222da2000-12-10 23:01:33 +000040#include "controls.h"
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000041#include "heap.h"
Alexandre Julliard0e607781993-11-03 19:23:37 +000042#include "win.h"
Alexandre Julliarddba420a1994-02-02 06:48:31 +000043#include "user.h"
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000044#include "wine/debug.h"
Alexandre Julliard0e607781993-11-03 19:23:37 +000045
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000046WINE_DEFAULT_DEBUG_CHANNEL(dialog);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000047
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000048
49 /* Dialog control information */
50typedef struct
51{
52 DWORD style;
53 DWORD exStyle;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000054 DWORD helpId;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000055 INT16 x;
56 INT16 y;
57 INT16 cx;
58 INT16 cy;
Alexandre Julliardd7b76822001-12-20 00:19:40 +000059 UINT id;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000060 LPCSTR className;
61 LPCSTR windowName;
Alexandre Julliardd7b76822001-12-20 00:19:40 +000062 LPCVOID data;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000063} DLG_CONTROL_INFO;
64
65 /* Dialog template */
66typedef struct
67{
68 DWORD style;
69 DWORD exStyle;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000070 DWORD helpId;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000071 UINT16 nbItems;
72 INT16 x;
73 INT16 y;
74 INT16 cx;
75 INT16 cy;
76 LPCSTR menuName;
77 LPCSTR className;
78 LPCSTR caption;
79 WORD pointSize;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000080 WORD weight;
Alexandre Julliarda3960291999-02-26 11:11:13 +000081 BOOL italic;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000082 LPCSTR faceName;
Alexandre Julliarda3960291999-02-26 11:11:13 +000083 BOOL dialogEx;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000084} DLG_TEMPLATE;
85
Luc Tourangeau8e238d01999-05-29 14:19:42 +000086 /* Radio button group */
87typedef struct
88{
89 UINT firstID;
90 UINT lastID;
91 UINT checkID;
92} RADIOGROUP;
93
Alexandre Julliard0e607781993-11-03 19:23:37 +000094 /* Dialog base units */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000095static WORD xBaseUnit = 0, yBaseUnit = 0;
Alexandre Julliard0e607781993-11-03 19:23:37 +000096
Gerard Patelf314e5e2000-08-21 03:31:39 +000097
Alexandre Julliard91222da2000-12-10 23:01:33 +000098/*********************************************************************
99 * dialog class descriptor
100 */
101const struct builtin_class_descr DIALOG_builtin_class =
102{
103 DIALOG_CLASS_ATOM, /* name */
104 CS_GLOBALCLASS | CS_SAVEBITS, /* style */
105 DefDlgProcA, /* procA */
106 DefDlgProcW, /* procW */
107 DLGWINDOWEXTRA, /* extra */
108 IDC_ARROWA, /* cursor */
109 0 /* brush */
110};
111
112
Gerard Patelf314e5e2000-08-21 03:31:39 +0000113/***********************************************************************
114 * DIALOG_EnableOwner
115 *
116 * Helper function for modal dialogs to enable again the
117 * owner of the dialog box.
118 */
Alexandre Julliard0801ffc2001-08-24 00:26:59 +0000119void DIALOG_EnableOwner( HWND hOwner )
Gerard Patelf314e5e2000-08-21 03:31:39 +0000120{
121 /* Owner must be a top-level window */
122 if (hOwner)
Alexandre Julliard0801ffc2001-08-24 00:26:59 +0000123 hOwner = GetAncestor( hOwner, GA_ROOT );
Gerard Patelf314e5e2000-08-21 03:31:39 +0000124 if (!hOwner) return;
Alexandre Julliard0801ffc2001-08-24 00:26:59 +0000125 EnableWindow( hOwner, TRUE );
Gerard Patelf314e5e2000-08-21 03:31:39 +0000126}
127
128
129/***********************************************************************
130 * DIALOG_DisableOwner
131 *
132 * Helper function for modal dialogs to disable the
133 * owner of the dialog box. Returns TRUE if owner was enabled.
134 */
135BOOL DIALOG_DisableOwner( HWND hOwner )
136{
137 /* Owner must be a top-level window */
138 if (hOwner)
Alexandre Julliard0801ffc2001-08-24 00:26:59 +0000139 hOwner = GetAncestor( hOwner, GA_ROOT );
Gerard Patelf314e5e2000-08-21 03:31:39 +0000140 if (!hOwner) return FALSE;
141 if (IsWindowEnabled( hOwner ))
142 {
143 EnableWindow( hOwner, FALSE );
144 return TRUE;
145 }
146 else
147 return FALSE;
148}
149
Alexandre Julliard0e607781993-11-03 19:23:37 +0000150/***********************************************************************
Slava Monich3a170a11999-06-06 09:03:08 +0000151 * DIALOG_GetCharSizeFromDC
152 *
Huw D M Davies79fdd842002-04-03 20:06:04 +0000153 * Despite most of MSDN insisting that the horizontal base unit is
154 * tmAveCharWidth it isn't. Knowledge base article Q145994
155 * "HOWTO: Calculate Dialog Units When Not Using the System Font",
156 * says that we should take the average of the 52 English upper and lower
157 * case characters.
Slava Monich3a170a11999-06-06 09:03:08 +0000158 */
159static BOOL DIALOG_GetCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize )
160{
Slava Monich3a170a11999-06-06 09:03:08 +0000161 HFONT hFontPrev = 0;
Huw D M Davies79fdd842002-04-03 20:06:04 +0000162 char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
163 SIZE sz;
164 TEXTMETRICA tm;
165
Slava Monich3a170a11999-06-06 09:03:08 +0000166 pSize->cx = xBaseUnit;
167 pSize->cy = yBaseUnit;
Huw D M Davies79fdd842002-04-03 20:06:04 +0000168
169 if(!hDC) return FALSE;
170
171 if(hFont) hFontPrev = SelectFont(hDC, hFont);
172 if(!GetTextMetricsA(hDC, &tm)) return FALSE;
173 if(!GetTextExtentPointA(hDC, alphabet, 52, &sz)) return FALSE;
174
175 pSize->cy = tm.tmHeight;
176 pSize->cx = (sz.cx / 26 + 1) / 2;
177
178 if (hFontPrev) SelectFont(hDC, hFontPrev);
179
180 TRACE("dlg base units: %ld x %ld\n", pSize->cx, pSize->cy);
181 return TRUE;
Slava Monich3a170a11999-06-06 09:03:08 +0000182}
183
Slava Monich3a170a11999-06-06 09:03:08 +0000184/***********************************************************************
185 * DIALOG_GetCharSize
186 *
Slava Monich3a170a11999-06-06 09:03:08 +0000187 * A convenient variant of DIALOG_GetCharSizeFromDC.
188 */
189static BOOL DIALOG_GetCharSize( HFONT hFont, SIZE * pSize )
190{
191 HDC hDC = GetDC(0);
192 BOOL Success = DIALOG_GetCharSizeFromDC( hDC, hFont, pSize );
193 ReleaseDC(0, hDC);
194 return Success;
195}
196
Slava Monich3a170a11999-06-06 09:03:08 +0000197/***********************************************************************
Alexandre Julliard0e607781993-11-03 19:23:37 +0000198 * DIALOG_Init
199 *
200 * Initialisation of the dialog manager.
201 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000202BOOL DIALOG_Init(void)
Alexandre Julliard0e607781993-11-03 19:23:37 +0000203{
Alexandre Julliardb0efe282000-08-04 04:18:04 +0000204 HDC hdc;
Slava Monich3a170a11999-06-06 09:03:08 +0000205 SIZE size;
206
Alexandre Julliard0e607781993-11-03 19:23:37 +0000207 /* Calculate the dialog base units */
208
Dmitry Timoshkov75b25be2000-10-31 01:01:41 +0000209 if (!(hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL )))
210 {
211 ERR("Could not create Display DC\n");
212 return FALSE;
213 }
214
215 if (!DIALOG_GetCharSizeFromDC( hdc, 0, &size ))
216 {
217 DeleteDC( hdc );
218 ERR("Could not initialize base dialog units\n");
219 return FALSE;
220 }
221
Alexandre Julliarda3960291999-02-26 11:11:13 +0000222 DeleteDC( hdc );
Slava Monich3a170a11999-06-06 09:03:08 +0000223 xBaseUnit = size.cx;
224 yBaseUnit = size.cy;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +0000225
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000226 TRACE("base units = %d,%d\n", xBaseUnit, yBaseUnit );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000227 return TRUE;
228}
229
230
231/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000232 * DIALOG_GetControl16
Alexandre Julliard0e607781993-11-03 19:23:37 +0000233 *
234 * Return the class and text of the control pointed to by ptr,
Alexandre Julliard329f0681996-04-14 13:21:20 +0000235 * fill the header structure and return a pointer to the next control.
Alexandre Julliard0e607781993-11-03 19:23:37 +0000236 */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000237static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000238{
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000239 static char buffer[10];
Alexandre Julliard03468f71998-02-15 19:40:49 +0000240 int int_id;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000241
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000242 info->x = GET_WORD(p); p += sizeof(WORD);
243 info->y = GET_WORD(p); p += sizeof(WORD);
244 info->cx = GET_WORD(p); p += sizeof(WORD);
245 info->cy = GET_WORD(p); p += sizeof(WORD);
246 info->id = GET_WORD(p); p += sizeof(WORD);
247 info->style = GET_DWORD(p); p += sizeof(DWORD);
248 info->exStyle = 0;
Alexandre Julliard7e50df31994-08-06 11:22:41 +0000249
Alexandre Julliard0e607781993-11-03 19:23:37 +0000250 if (*p & 0x80)
251 {
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000252 switch((BYTE)*p)
253 {
254 case 0x80: strcpy( buffer, "BUTTON" ); break;
255 case 0x81: strcpy( buffer, "EDIT" ); break;
256 case 0x82: strcpy( buffer, "STATIC" ); break;
257 case 0x83: strcpy( buffer, "LISTBOX" ); break;
258 case 0x84: strcpy( buffer, "SCROLLBAR" ); break;
259 case 0x85: strcpy( buffer, "COMBOBOX" ); break;
260 default: buffer[0] = '\0'; break;
261 }
262 info->className = buffer;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000263 p++;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000264 }
265 else
266 {
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000267 info->className = p;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000268 p += strlen(p) + 1;
269 }
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000270
Alexandre Julliard03468f71998-02-15 19:40:49 +0000271 int_id = ((BYTE)*p == 0xff);
272 if (int_id)
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000273 {
274 /* Integer id, not documented (?). Only works for SS_ICON controls */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000275 info->windowName = (LPCSTR)(UINT)GET_WORD(p+1);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000276 p += 3;
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000277 }
278 else
279 {
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000280 info->windowName = p;
281 p += strlen(p) + 1;
Alexandre Julliard7e50df31994-08-06 11:22:41 +0000282 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000283
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000284 if (*p) info->data = p + 1;
Bernd Herd5b60bf02000-05-11 00:05:22 +0000285 else info->data = NULL;
286
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000287 p += *p + 1;
288
Alexandre Julliard03468f71998-02-15 19:40:49 +0000289 if(int_id)
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000290 TRACE(" %s %04x %d, %d, %d, %d, %d, %08lx, %p\n",
Alexandre Julliard03468f71998-02-15 19:40:49 +0000291 info->className, LOWORD(info->windowName),
292 info->id, info->x, info->y, info->cx, info->cy,
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000293 info->style, info->data );
Alexandre Julliard03468f71998-02-15 19:40:49 +0000294 else
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000295 TRACE(" %s '%s' %d, %d, %d, %d, %d, %08lx, %p\n",
Alexandre Julliard03468f71998-02-15 19:40:49 +0000296 info->className, info->windowName,
297 info->id, info->x, info->y, info->cx, info->cy,
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000298 info->style, info->data );
Alexandre Julliard03468f71998-02-15 19:40:49 +0000299
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000300 return p;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000301}
302
303
304/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000305 * DIALOG_GetControl32
Alexandre Julliard0e607781993-11-03 19:23:37 +0000306 *
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000307 * Return the class and text of the control pointed to by ptr,
308 * fill the header structure and return a pointer to the next control.
Alexandre Julliard0e607781993-11-03 19:23:37 +0000309 */
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000310static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000311 BOOL dialogEx )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000312{
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000313 if (dialogEx)
314 {
315 info->helpId = GET_DWORD(p); p += 2;
316 info->exStyle = GET_DWORD(p); p += 2;
317 info->style = GET_DWORD(p); p += 2;
318 }
319 else
320 {
321 info->helpId = 0;
322 info->style = GET_DWORD(p); p += 2;
323 info->exStyle = GET_DWORD(p); p += 2;
324 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000325 info->x = GET_WORD(p); p++;
326 info->y = GET_WORD(p); p++;
327 info->cx = GET_WORD(p); p++;
328 info->cy = GET_WORD(p); p++;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000329
330 if (dialogEx)
331 {
332 /* id is a DWORD for DIALOGEX */
333 info->id = GET_DWORD(p);
334 p += 2;
335 }
336 else
337 {
338 info->id = GET_WORD(p);
339 p++;
340 }
Alexandre Julliard0e607781993-11-03 19:23:37 +0000341
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000342 if (GET_WORD(p) == 0xffff)
Alexandre Julliard0e607781993-11-03 19:23:37 +0000343 {
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000344 static const WCHAR class_names[6][10] =
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000345 {
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000346 { 'B','u','t','t','o','n', }, /* 0x80 */
347 { 'E','d','i','t', }, /* 0x81 */
348 { 'S','t','a','t','i','c', }, /* 0x82 */
349 { 'L','i','s','t','B','o','x', }, /* 0x83 */
350 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
351 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
352 };
353 WORD id = GET_WORD(p+1);
354 if ((id >= 0x80) && (id <= 0x85))
355 info->className = (LPCSTR)class_names[id - 0x80];
356 else
357 {
358 info->className = NULL;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000359 ERR("Unknown built-in class id %04x\n", id );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000360 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000361 p += 2;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000362 }
363 else
364 {
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000365 info->className = (LPCSTR)p;
Alexandre Julliardc7e7df82000-08-14 14:41:19 +0000366 p += strlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000367 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000368
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000369 if (GET_WORD(p) == 0xffff) /* Is it an integer id? */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000370 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000371 info->windowName = (LPCSTR)(UINT)GET_WORD(p + 1);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000372 p += 2;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000373 }
374 else
375 {
376 info->windowName = (LPCSTR)p;
Alexandre Julliardc7e7df82000-08-14 14:41:19 +0000377 p += strlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000378 }
379
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000380 TRACE(" %s %s %d, %d, %d, %d, %d, %08lx, %08lx, %08lx\n",
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000381 debugstr_w( (LPCWSTR)info->className ),
382 debugres_w( (LPCWSTR)info->windowName ),
383 info->id, info->x, info->y, info->cx, info->cy,
384 info->style, info->exStyle, info->helpId );
385
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000386 if (GET_WORD(p))
387 {
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000388 if (TRACE_ON(dialog))
389 {
390 WORD i, count = GET_WORD(p) / sizeof(WORD);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000391 TRACE(" BEGIN\n");
392 TRACE(" ");
393 for (i = 0; i < count; i++) DPRINTF( "%04x,", GET_WORD(p+i+1) );
394 DPRINTF("\n");
395 TRACE(" END\n" );
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000396 }
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000397 info->data = p + 1;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000398 p += GET_WORD(p) / sizeof(WORD);
399 }
400 else info->data = NULL;
401 p++;
402
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000403 /* Next control is on dword boundary */
404 return (const WORD *)((((int)p) + 3) & ~3);
405}
406
407
408/***********************************************************************
409 * DIALOG_CreateControls
410 *
411 * Create the control windows for a dialog.
412 */
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000413static BOOL DIALOG_CreateControls( HWND hwnd, LPCSTR template, const DLG_TEMPLATE *dlgTemplate,
414 HINSTANCE hInst, BOOL win32 )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000415{
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000416 DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000417 DLG_CONTROL_INFO info;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000418 HWND hwndCtrl, hwndDefButton = 0;
419 INT items = dlgTemplate->nbItems;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000420
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000421 TRACE(" BEGIN\n" );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000422 while (items--)
423 {
424 if (!win32)
425 {
426 HINSTANCE16 instance;
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000427 SEGPTR segptr;
428
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000429 template = DIALOG_GetControl16( template, &info );
430 if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000431 !(GetWindowLongW( hwnd, GWL_STYLE ) & DS_LOCALEDIT))
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000432 {
433 if (!dlgInfo->hDialogHeap)
434 {
435 dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000);
436 if (!dlgInfo->hDialogHeap)
437 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000438 ERR("Insufficient memory to create heap for edit control\n" );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000439 continue;
440 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000441 LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000442 }
443 instance = dlgInfo->hDialogHeap;
444 }
445 else instance = (HINSTANCE16)hInst;
446
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000447 segptr = MapLS( info.data );
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000448 hwndCtrl = WIN_Handle32( CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY,
449 info.className, info.windowName,
450 info.style | WS_CHILD,
451 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
452 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
453 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
454 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
455 WIN_Handle16(hwnd), (HMENU16)info.id,
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000456 instance, (LPVOID)segptr ));
457 UnMapLS( segptr );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000458 }
459 else
460 {
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000461 template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info,
462 dlgTemplate->dialogEx );
Bill Medland137420a2001-07-11 17:26:33 +0000463 /* Is this it? */
464 if (info.style & WS_BORDER)
465 {
466 info.style &= ~WS_BORDER;
467 info.exStyle |= WS_EX_CLIENTEDGE;
468 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000469 hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000470 (LPCWSTR)info.className,
471 (LPCWSTR)info.windowName,
472 info.style | WS_CHILD,
Francis Beaudeteb13dd41999-09-03 15:14:27 +0000473 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
474 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
475 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
476 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000477 hwnd, (HMENU)info.id,
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000478 hInst, (LPVOID)info.data );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000479 }
480 if (!hwndCtrl) return FALSE;
481
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000482 /* Send initialisation messages to the control */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000483 if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT,
484 (WPARAM)dlgInfo->hUserFont, 0 );
485 if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000486 {
487 /* If there's already a default push-button, set it back */
488 /* to normal and use this one instead. */
489 if (hwndDefButton)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000490 SendMessageA( hwndDefButton, BM_SETSTYLE,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000491 BS_PUSHBUTTON,FALSE );
492 hwndDefButton = hwndCtrl;
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000493 dlgInfo->idResult = GetWindowLongA( hwndCtrl, GWL_ID );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000494 }
495 }
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000496 TRACE(" END\n" );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000497 return TRUE;
498}
499
500
501/***********************************************************************
502 * DIALOG_ParseTemplate16
503 *
504 * Fill a DLG_TEMPLATE structure from the dialog template, and return
505 * a pointer to the first control.
506 */
507static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result )
508{
509 result->style = GET_DWORD(p); p += sizeof(DWORD);
510 result->exStyle = 0;
Pavel Roskin4b5f8761999-06-12 08:11:32 +0000511 result->nbItems = (unsigned char) *p++;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000512 result->x = GET_WORD(p); p += sizeof(WORD);
513 result->y = GET_WORD(p); p += sizeof(WORD);
514 result->cx = GET_WORD(p); p += sizeof(WORD);
515 result->cy = GET_WORD(p); p += sizeof(WORD);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000516 TRACE("DIALOG %d, %d, %d, %d\n",
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000517 result->x, result->y, result->cx, result->cy );
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000518 TRACE(" STYLE %08lx\n", result->style );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000519
520 /* Get the menu name */
521
522 switch( (BYTE)*p )
523 {
524 case 0:
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000525 result->menuName = 0;
526 p++;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000527 break;
528 case 0xff:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000529 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000530 p += 3;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000531 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000532 break;
533 default:
534 result->menuName = p;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000535 TRACE(" MENU '%s'\n", p );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000536 p += strlen(p) + 1;
537 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000538 }
Alexandre Julliard0e607781993-11-03 19:23:37 +0000539
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000540 /* Get the class name */
541
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000542 if (*p)
543 {
544 result->className = p;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000545 TRACE(" CLASS '%s'\n", result->className );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000546 }
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000547 else result->className = DIALOG_CLASS_ATOM;
548 p += strlen(p) + 1;
549
550 /* Get the window caption */
551
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000552 result->caption = p;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000553 p += strlen(p) + 1;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000554 TRACE(" CAPTION '%s'\n", result->caption );
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000555
556 /* Get the font name */
557
Alexandre Julliard329f0681996-04-14 13:21:20 +0000558 if (result->style & DS_SETFONT)
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000559 {
Alexandre Julliard329f0681996-04-14 13:21:20 +0000560 result->pointSize = GET_WORD(p);
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000561 p += sizeof(WORD);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000562 result->faceName = p;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000563 p += strlen(p) + 1;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000564 TRACE(" FONT %d,'%s'\n",
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000565 result->pointSize, result->faceName );
566 }
567 return p;
568}
569
570
571/***********************************************************************
572 * DIALOG_ParseTemplate32
573 *
574 * Fill a DLG_TEMPLATE structure from the dialog template, and return
575 * a pointer to the first control.
576 */
577static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result )
578{
579 const WORD *p = (const WORD *)template;
580
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000581 result->style = GET_DWORD(p); p += 2;
582 if (result->style == 0xffff0001) /* DIALOGEX resource */
583 {
584 result->dialogEx = TRUE;
585 result->helpId = GET_DWORD(p); p += 2;
586 result->exStyle = GET_DWORD(p); p += 2;
587 result->style = GET_DWORD(p); p += 2;
588 }
589 else
590 {
591 result->dialogEx = FALSE;
592 result->helpId = 0;
593 result->exStyle = GET_DWORD(p); p += 2;
594 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000595 result->nbItems = GET_WORD(p); p++;
596 result->x = GET_WORD(p); p++;
597 result->y = GET_WORD(p); p++;
598 result->cx = GET_WORD(p); p++;
599 result->cy = GET_WORD(p); p++;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000600 TRACE("DIALOG%s %d, %d, %d, %d, %ld\n",
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000601 result->dialogEx ? "EX" : "", result->x, result->y,
602 result->cx, result->cy, result->helpId );
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000603 TRACE(" STYLE 0x%08lx\n", result->style );
604 TRACE(" EXSTYLE 0x%08lx\n", result->exStyle );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000605
606 /* Get the menu name */
607
608 switch(GET_WORD(p))
609 {
610 case 0x0000:
611 result->menuName = NULL;
612 p++;
613 break;
614 case 0xffff:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000615 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000616 p += 2;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000617 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000618 break;
619 default:
620 result->menuName = (LPCSTR)p;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000621 TRACE(" MENU %s\n", debugstr_w( (LPCWSTR)p ));
Alexandre Julliardc7e7df82000-08-14 14:41:19 +0000622 p += strlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000623 break;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000624 }
625
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000626 /* Get the class name */
Alexandre Julliard0e607781993-11-03 19:23:37 +0000627
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000628 switch(GET_WORD(p))
629 {
630 case 0x0000:
631 result->className = DIALOG_CLASS_ATOM;
632 p++;
633 break;
634 case 0xffff:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000635 result->className = (LPCSTR)(UINT)GET_WORD( p + 1 );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000636 p += 2;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000637 TRACE(" CLASS %04x\n", LOWORD(result->className) );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000638 break;
639 default:
640 result->className = (LPCSTR)p;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000641 TRACE(" CLASS %s\n", debugstr_w( (LPCWSTR)p ));
Alexandre Julliardc7e7df82000-08-14 14:41:19 +0000642 p += strlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000643 break;
644 }
Alexandre Julliard0e607781993-11-03 19:23:37 +0000645
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000646 /* Get the window caption */
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000647
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000648 result->caption = (LPCSTR)p;
Alexandre Julliardc7e7df82000-08-14 14:41:19 +0000649 p += strlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000650 TRACE(" CAPTION %s\n", debugstr_w( (LPCWSTR)result->caption ) );
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000651
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000652 /* Get the font name */
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000653
Alexandre Julliard329f0681996-04-14 13:21:20 +0000654 if (result->style & DS_SETFONT)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000655 {
656 result->pointSize = GET_WORD(p);
657 p++;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000658 if (result->dialogEx)
659 {
660 result->weight = GET_WORD(p); p++;
661 result->italic = LOBYTE(GET_WORD(p)); p++;
662 }
663 else
664 {
665 result->weight = FW_DONTCARE;
666 result->italic = FALSE;
667 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000668 result->faceName = (LPCSTR)p;
Alexandre Julliardc7e7df82000-08-14 14:41:19 +0000669 p += strlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000670 TRACE(" FONT %d, %s, %d, %s\n",
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000671 result->pointSize, debugstr_w( (LPCWSTR)result->faceName ),
672 result->weight, result->italic ? "TRUE" : "FALSE" );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000673 }
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000674
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000675 /* First control is on dword boundary */
676 return (LPCSTR)((((int)p) + 3) & ~3);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000677}
Alexandre Julliard0e607781993-11-03 19:23:37 +0000678
679
680/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000681 * DIALOG_CreateIndirect
Gerard Patelf314e5e2000-08-21 03:31:39 +0000682 * Creates a dialog box window
683 *
684 * modal = TRUE if we are called from a modal dialog box.
685 * (it's more compatible to do it here, as under Windows the owner
686 * is never disabled if the dialog fails because of an invalid template)
Alexandre Julliard0e607781993-11-03 19:23:37 +0000687 */
Gerard Patele3bd8d02000-08-18 23:05:44 +0000688static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000689 HWND owner, DLGPROC dlgProc, LPARAM param,
Gerard Patelf314e5e2000-08-21 03:31:39 +0000690 WINDOWPROCTYPE procType, BOOL modal )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000691{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000692 HWND hwnd;
693 RECT rect;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000694 WND * wndPtr;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000695 DLG_TEMPLATE template;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000696 DIALOGINFO * dlgInfo;
Gerard Patelf314e5e2000-08-21 03:31:39 +0000697 BOOL ownerEnabled = TRUE;
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000698 BOOL win32Template = (procType != WIN_PROC_16);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000699
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000700 /* Parse dialog template */
701
702 if (!dlgTemplate) return 0;
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000703 if (win32Template)
Alexandre Julliard3051b641996-07-05 17:14:13 +0000704 dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template );
705 else
706 dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000707
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000708 /* Initialise dialog extra data */
709
710 if (!(dlgInfo = HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo) ))) return 0;
711 dlgInfo->hwndFocus = 0;
712 dlgInfo->hUserFont = 0;
713 dlgInfo->hMenu = 0;
714 dlgInfo->xBaseUnit = xBaseUnit;
715 dlgInfo->yBaseUnit = yBaseUnit;
716 dlgInfo->idResult = 0;
717 dlgInfo->flags = 0;
718 dlgInfo->hDialogHeap = 0;
719
Alexandre Julliard0e607781993-11-03 19:23:37 +0000720 /* Load menu */
721
Alexandre Julliard491502b1997-11-01 19:08:16 +0000722 if (template.menuName)
723 {
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000724 if (!win32Template) dlgInfo->hMenu = LoadMenu16( hInst, template.menuName );
725 else dlgInfo->hMenu = LoadMenuW( hInst, (LPCWSTR)template.menuName );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000726 }
Alexandre Julliard0e607781993-11-03 19:23:37 +0000727
728 /* Create custom font if needed */
729
Alexandre Julliard329f0681996-04-14 13:21:20 +0000730 if (template.style & DS_SETFONT)
Alexandre Julliard0e607781993-11-03 19:23:37 +0000731 {
Huw D M Davies79fdd842002-04-03 20:06:04 +0000732 /* We convert the size to pixels and then make it -ve. This works
733 * for both +ve and -ve template.pointSize */
Gerard Patel6e8519b2000-12-18 03:11:10 +0000734 HDC dc;
735 int pixels;
Huw D M Davies79fdd842002-04-03 20:06:04 +0000736 dc = GetDC(0);
737 pixels = MulDiv(template.pointSize, GetDeviceCaps(dc , LOGPIXELSY), 72);
738 ReleaseDC(0, dc);
Alexandre Julliard3db94ef1997-09-28 17:43:24 +0000739 if (win32Template)
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000740 dlgInfo->hUserFont = CreateFontW( -pixels, 0, 0, 0, template.weight,
741 template.italic, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
742 PROOF_QUALITY, FF_DONTCARE,
743 (LPCWSTR)template.faceName );
Alexandre Julliard3db94ef1997-09-28 17:43:24 +0000744 else
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000745 dlgInfo->hUserFont = CreateFontA( -pixels, 0, 0, 0, FW_DONTCARE,
746 FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
747 PROOF_QUALITY, FF_DONTCARE, template.faceName );
748 if (dlgInfo->hUserFont)
Slava Monich3a170a11999-06-06 09:03:08 +0000749 {
750 SIZE charSize;
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000751 if (DIALOG_GetCharSize( dlgInfo->hUserFont, &charSize ))
Slava Moniche6dd5d12000-07-08 18:27:24 +0000752 {
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000753 dlgInfo->xBaseUnit = charSize.cx;
754 dlgInfo->yBaseUnit = charSize.cy;
Slava Moniche6dd5d12000-07-08 18:27:24 +0000755 }
Slava Monich3a170a11999-06-06 09:03:08 +0000756 }
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000757 TRACE("units = %d,%d\n", dlgInfo->xBaseUnit, dlgInfo->yBaseUnit );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000758 }
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000759
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000760 /* Create dialog main window */
Alexandre Julliard0e607781993-11-03 19:23:37 +0000761
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000762 rect.left = rect.top = 0;
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000763 rect.right = MulDiv(template.cx, dlgInfo->xBaseUnit, 4);
764 rect.bottom = MulDiv(template.cy, dlgInfo->yBaseUnit, 8);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000765 if (template.style & DS_MODALFRAME)
766 template.exStyle |= WS_EX_DLGMODALFRAME;
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000767 AdjustWindowRectEx( &rect, template.style, (dlgInfo->hMenu != 0), template.exStyle );
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000768 rect.right -= rect.left;
769 rect.bottom -= rect.top;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000770
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000771 if ((INT16)template.x == CW_USEDEFAULT16)
Alexandre Julliardca22b331996-07-12 19:02:39 +0000772 {
Ulrich Weigandf03c9361999-07-10 13:08:50 +0000773 rect.left = rect.top = win32Template? CW_USEDEFAULT : CW_USEDEFAULT16;
Alexandre Julliardca22b331996-07-12 19:02:39 +0000774 }
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000775 else
776 {
Dave Picklesfcc9d131998-10-10 15:52:46 +0000777 if (template.style & DS_CENTER)
778 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000779 rect.left = (GetSystemMetrics(SM_CXSCREEN) - rect.right) / 2;
780 rect.top = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / 2;
Dave Picklesfcc9d131998-10-10 15:52:46 +0000781 }
782 else
783 {
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000784 rect.left += MulDiv(template.x, dlgInfo->xBaseUnit, 4);
785 rect.top += MulDiv(template.y, dlgInfo->yBaseUnit, 8);
Dave Picklesfcc9d131998-10-10 15:52:46 +0000786 }
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000787 if ( !(template.style & WS_CHILD) )
788 {
789 INT16 dX, dY;
790
791 if( !(template.style & DS_ABSALIGN) )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000792 ClientToScreen( owner, (POINT *)&rect );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000793
794 /* try to fit it into the desktop */
795
Marcus Meissnerddca3151999-05-22 11:33:23 +0000796 if( (dX = rect.left + rect.right + GetSystemMetrics(SM_CXDLGFRAME)
797 - GetSystemMetrics(SM_CXSCREEN)) > 0 ) rect.left -= dX;
798 if( (dY = rect.top + rect.bottom + GetSystemMetrics(SM_CYDLGFRAME)
799 - GetSystemMetrics(SM_CYSCREEN)) > 0 ) rect.top -= dY;
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000800 if( rect.left < 0 ) rect.left = 0;
801 if( rect.top < 0 ) rect.top = 0;
802 }
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000803 }
804
Gerard Patelf314e5e2000-08-21 03:31:39 +0000805 if (modal)
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000806 {
Gerard Patelf314e5e2000-08-21 03:31:39 +0000807 ownerEnabled = DIALOG_DisableOwner( owner );
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000808 if (ownerEnabled) dlgInfo->flags |= DF_OWNERENABLED;
809 }
Gerard Patelf314e5e2000-08-21 03:31:39 +0000810
Ulrich Weigandf03c9361999-07-10 13:08:50 +0000811 if (!win32Template)
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000812 hwnd = WIN_Handle32( CreateWindowEx16(template.exStyle, template.className,
813 template.caption, template.style & ~WS_VISIBLE,
814 rect.left, rect.top, rect.right, rect.bottom,
815 WIN_Handle16(owner), dlgInfo->hMenu, hInst, NULL ));
Alexandre Julliard3db94ef1997-09-28 17:43:24 +0000816 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000817 hwnd = CreateWindowExW(template.exStyle, (LPCWSTR)template.className,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000818 (LPCWSTR)template.caption,
819 template.style & ~WS_VISIBLE,
820 rect.left, rect.top, rect.right, rect.bottom,
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000821 owner, dlgInfo->hMenu, hInst, NULL );
822
Alexandre Julliard0e607781993-11-03 19:23:37 +0000823 if (!hwnd)
824 {
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000825 if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont );
826 if (dlgInfo->hMenu) DestroyMenu( dlgInfo->hMenu );
827 if (modal && (dlgInfo->flags & DF_OWNERENABLED)) DIALOG_EnableOwner(owner);
828 HeapFree( GetProcessHeap(), 0, dlgInfo );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000829 return 0;
830 }
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000831 wndPtr = WIN_GetPtr( hwnd );
Alexandre Julliard3051b641996-07-05 17:14:13 +0000832 wndPtr->flags |= WIN_ISDIALOG;
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000833 WIN_ReleasePtr( wndPtr );
Alexandre Julliard902da691995-11-05 14:39:02 +0000834
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000835 if (template.helpId) SetWindowContextHelpId( hwnd, template.helpId );
836 SetWindowLongW( hwnd, DWL_WINE_DIALOGINFO, (LONG)dlgInfo );
837 switch(procType)
838 {
839 case WIN_PROC_16: SetWindowLong16( WIN_Handle16(hwnd), DWL_DLGPROC, (LONG)dlgProc ); break;
840 case WIN_PROC_32A: SetWindowLongA( hwnd, DWL_DLGPROC, (LONG)dlgProc ); break;
841 case WIN_PROC_32W: SetWindowLongW( hwnd, DWL_DLGPROC, (LONG)dlgProc ); break;
842 default: break;
843 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000844
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000845 if (dlgInfo->hUserFont)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000846 SendMessageA( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000847
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000848 /* Create controls */
849
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000850 if (DIALOG_CreateControls( hwnd, dlgTemplate, &template,
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000851 hInst, win32Template ))
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000852 {
Adrian Thurston00442ba1999-10-23 16:48:05 +0000853 HWND hwndPreInitFocus;
854
855 /* Send initialisation messages and set focus */
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000856
Alexandre Julliarda3960291999-02-26 11:11:13 +0000857 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
Alexandre Julliard77b99181997-09-14 17:17:23 +0000858
Adrian Thurston00442ba1999-10-23 16:48:05 +0000859 hwndPreInitFocus = GetFocus();
Alexandre Julliarda3960291999-02-26 11:11:13 +0000860 if (SendMessageA( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ))
Sheri Steevesa4b73d42000-06-15 01:00:42 +0000861 {
Alexandre Julliard908464d2000-11-01 03:11:12 +0000862 /* check where the focus is again,
863 * some controls status might have changed in WM_INITDIALOG */
Dave Hawkes5446abe2001-12-06 22:21:36 +0000864 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
865 if( dlgInfo->hwndFocus )
866 SetFocus( dlgInfo->hwndFocus );
Sheri Steevesa4b73d42000-06-15 01:00:42 +0000867 }
868 else
869 {
870 /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
871 but the focus has not changed, set the focus where we expect it. */
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000872 if ((GetFocus() == hwndPreInitFocus) &&
873 (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
Sheri Steevesa4b73d42000-06-15 01:00:42 +0000874 {
875 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
Dave Hawkes5446abe2001-12-06 22:21:36 +0000876 if( dlgInfo->hwndFocus )
877 SetFocus( dlgInfo->hwndFocus );
Sheri Steevesa4b73d42000-06-15 01:00:42 +0000878 }
879 }
Alexandre Julliard77b99181997-09-14 17:17:23 +0000880
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000881 if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
Alexandre Julliard77b99181997-09-14 17:17:23 +0000882 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000883 ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
Alexandre Julliard77b99181997-09-14 17:17:23 +0000884 }
885 return hwnd;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000886 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000887 if( IsWindow(hwnd) ) DestroyWindow( hwnd );
Alexandre Julliard0801ffc2001-08-24 00:26:59 +0000888 if (modal && ownerEnabled) DIALOG_EnableOwner(owner);
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000889 return 0;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000890}
891
892
893/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000894 * CreateDialog (USER.89)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000895 */
Alexandre Julliardac7efef2000-11-27 21:54:01 +0000896HWND16 WINAPI CreateDialog16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000897 HWND16 owner, DLGPROC16 dlgProc )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000898{
899 return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
900}
901
902
903/***********************************************************************
Patrik Stridvall0c610282001-01-25 22:22:21 +0000904 * CreateDialogParam (USER.241)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000905 */
Alexandre Julliardac7efef2000-11-27 21:54:01 +0000906HWND16 WINAPI CreateDialogParam16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000907 HWND16 owner, DLGPROC16 dlgProc,
908 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000909{
910 HWND16 hwnd = 0;
Alexandre Julliard8cc3a5e1996-08-11 15:49:51 +0000911 HRSRC16 hRsrc;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000912 HGLOBAL16 hmem;
913 LPCVOID data;
914
Alexandre Julliardac7efef2000-11-27 21:54:01 +0000915 TRACE("%04x,%s,%04x,%08lx,%ld\n",
916 hInst, debugres_a(dlgTemplate), owner, (DWORD)dlgProc, param );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000917
Alexandre Julliardac7efef2000-11-27 21:54:01 +0000918 if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOGA ))) return 0;
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000919 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
920 if (!(data = LockResource16( hmem ))) hwnd = 0;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000921 else hwnd = CreateDialogIndirectParam16( hInst, data, owner,
922 dlgProc, param );
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000923 FreeResource16( hmem );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000924 return hwnd;
925}
926
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000927/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000928 * CreateDialogParamA (USER32.@)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000929 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000930HWND WINAPI CreateDialogParamA( HINSTANCE hInst, LPCSTR name,
931 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000932 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000933{
Ove Kaaven483c5481999-07-18 15:29:09 +0000934 HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
935 if (!hrsrc) return 0;
936 return CreateDialogIndirectParamA( hInst,
937 (LPVOID)LoadResource(hInst, hrsrc),
938 owner, dlgProc, param );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000939}
940
941
942/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000943 * CreateDialogParamW (USER32.@)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000944 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000945HWND WINAPI CreateDialogParamW( HINSTANCE hInst, LPCWSTR name,
946 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000947 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000948{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000949 HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000950 if (!hrsrc) return 0;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000951 return CreateDialogIndirectParamW( hInst,
952 (LPVOID)LoadResource(hInst, hrsrc),
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000953 owner, dlgProc, param );
954}
955
956
957/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000958 * CreateDialogIndirect (USER.219)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000959 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000960HWND16 WINAPI CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
961 HWND16 owner, DLGPROC16 dlgProc )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000962{
963 return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
964}
965
966
967/***********************************************************************
Patrik Stridvall0c610282001-01-25 22:22:21 +0000968 * CreateDialogIndirectParam (USER.242)
969 * CreateDialogIndirectParam16 (USER32.@)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000970 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000971HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst,
972 LPCVOID dlgTemplate,
973 HWND16 owner, DLGPROC16 dlgProc,
974 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000975{
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000976 return WIN_Handle16( DIALOG_CreateIndirect( hInst, dlgTemplate, WIN_Handle32(owner),
977 (DLGPROC)dlgProc, param, WIN_PROC_16, FALSE ));
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000978}
979
980
981/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000982 * CreateDialogIndirectParamA (USER32.@)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000983 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000984HWND WINAPI CreateDialogIndirectParamA( HINSTANCE hInst,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000985 LPCVOID dlgTemplate,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000986 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000987 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000988{
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000989 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32A, FALSE );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000990}
991
Juergen Schmied84b358d1998-10-11 15:38:35 +0000992/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000993 * CreateDialogIndirectParamAorW (USER32.@)
Juergen Schmied84b358d1998-10-11 15:38:35 +0000994 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000995HWND WINAPI CreateDialogIndirectParamAorW( HINSTANCE hInst,
Juergen Schmied84b358d1998-10-11 15:38:35 +0000996 LPCVOID dlgTemplate,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000997 HWND owner, DLGPROC dlgProc,
Juergen Schmied84b358d1998-10-11 15:38:35 +0000998 LPARAM param )
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000999{ FIXME("assume WIN_PROC_32W\n");
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001000 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32W, FALSE );
Juergen Schmied84b358d1998-10-11 15:38:35 +00001001}
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001002
1003/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001004 * CreateDialogIndirectParamW (USER32.@)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001005 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001006HWND WINAPI CreateDialogIndirectParamW( HINSTANCE hInst,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001007 LPCVOID dlgTemplate,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001008 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001009 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001010{
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001011 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32W, FALSE );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001012}
1013
1014
1015/***********************************************************************
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001016 * DIALOG_DoDialogBox
Alexandre Julliard0e607781993-11-03 19:23:37 +00001017 */
Gerard Patele3bd8d02000-08-18 23:05:44 +00001018static INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001019{
Alexandre Julliard0e607781993-11-03 19:23:37 +00001020 DIALOGINFO * dlgInfo;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001021 MSG msg;
1022 INT retval;
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001023 HWND ownerMsg = GetAncestor( owner, GA_ROOT );
Alexandre Julliard0e607781993-11-03 19:23:37 +00001024
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001025 if (!(dlgInfo = DIALOG_get_info( hwnd ))) return -1;
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001026
Gerard Patelf314e5e2000-08-21 03:31:39 +00001027 if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */
Alexandre Julliard0e607781993-11-03 19:23:37 +00001028 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001029 ShowWindow( hwnd, SW_SHOW );
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001030 for (;;)
Gerard Patel902f9c61999-02-14 11:22:03 +00001031 {
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001032 if (!(GetWindowLongW( hwnd, GWL_STYLE ) & DS_NOIDLEMSG))
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001033 {
1034 if (!PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ))
1035 {
1036 /* No message present -> send ENTERIDLE and wait */
1037 SendMessageW( ownerMsg, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)hwnd );
1038 if (!GetMessageW( &msg, 0, 0, 0 )) break;
1039 }
1040 }
1041 else if (!GetMessageW( &msg, 0, 0, 0 )) break;
1042
1043 if (CallMsgFilterW( &msg, MSGF_DIALOGBOX )) continue;
1044
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001045 if (!IsWindow( hwnd )) return -1;
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001046 if (!(dlgInfo->flags & DF_END) && !IsDialogMessageW( hwnd, &msg))
Gerard Patel902f9c61999-02-14 11:22:03 +00001047 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001048 TranslateMessage( &msg );
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001049 DispatchMessageW( &msg );
Gerard Patel902f9c61999-02-14 11:22:03 +00001050 }
1051 if (dlgInfo->flags & DF_END) break;
1052 }
Alexandre Julliard0e607781993-11-03 19:23:37 +00001053 }
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001054 if (dlgInfo->flags & DF_OWNERENABLED) DIALOG_EnableOwner( owner );
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001055 retval = dlgInfo->idResult;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001056 DestroyWindow( hwnd );
Alexandre Julliard0e607781993-11-03 19:23:37 +00001057 return retval;
1058}
1059
1060
1061/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001062 * DialogBox (USER.87)
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001063 */
Alexandre Julliardac7efef2000-11-27 21:54:01 +00001064INT16 WINAPI DialogBox16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001065 HWND16 owner, DLGPROC16 dlgProc )
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001066{
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001067 return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001068}
1069
1070
1071/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001072 * DialogBoxParam (USER.239)
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001073 */
Alexandre Julliardac7efef2000-11-27 21:54:01 +00001074INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, LPCSTR template,
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001075 HWND16 owner16, DLGPROC16 dlgProc, LPARAM param )
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001076{
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001077 HWND hwnd = 0;
Gerard Patelf314e5e2000-08-21 03:31:39 +00001078 HRSRC16 hRsrc;
1079 HGLOBAL16 hmem;
1080 LPCVOID data;
1081 int ret = -1;
1082
Alexandre Julliardac7efef2000-11-27 21:54:01 +00001083 if (!(hRsrc = FindResource16( hInst, template, RT_DIALOGA ))) return 0;
Gerard Patelf314e5e2000-08-21 03:31:39 +00001084 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001085 if ((data = LockResource16( hmem )))
1086 {
1087 HWND owner = WIN_Handle32(owner16);
1088 hwnd = DIALOG_CreateIndirect( hInst, data, owner,
1089 (DLGPROC)dlgProc, param, WIN_PROC_16, TRUE );
1090 if (hwnd) ret = DIALOG_DoDialogBox( hwnd, owner );
1091 GlobalUnlock16( hmem );
1092 }
Gerard Patelf314e5e2000-08-21 03:31:39 +00001093 FreeResource16( hmem );
1094 return ret;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001095}
1096
1097
1098/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001099 * DialogBoxParamA (USER32.@)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001100 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001101INT WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name,
1102 HWND owner, DLGPROC dlgProc, LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001103{
Gerard Patelf314e5e2000-08-21 03:31:39 +00001104 HWND hwnd;
1105 HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
1106 if (!hrsrc) return 0;
1107 hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc),
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001108 owner, dlgProc, param, WIN_PROC_32A, TRUE );
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00001109 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001110 return -1;
1111}
1112
1113
1114/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001115 * DialogBoxParamW (USER32.@)
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001116 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001117INT WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
1118 HWND owner, DLGPROC dlgProc, LPARAM param )
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001119{
Gerard Patelf314e5e2000-08-21 03:31:39 +00001120 HWND hwnd;
1121 HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
1122 if (!hrsrc) return 0;
1123 hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc),
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001124 owner, dlgProc, param, WIN_PROC_32W, TRUE );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001125 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1126 return -1;
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001127}
1128
1129
1130/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001131 * DialogBoxIndirect (USER.218)
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001132 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001133INT16 WINAPI DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1134 HWND16 owner, DLGPROC16 dlgProc )
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001135{
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001136 return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
1137}
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001138
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001139
1140/***********************************************************************
Patrik Stridvall0c610282001-01-25 22:22:21 +00001141 * DialogBoxIndirectParam (USER.240)
1142 * DialogBoxIndirectParam16 (USER32.@)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001143 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001144INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001145 HWND16 owner16, DLGPROC16 dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001146 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001147{
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001148 HWND hwnd, owner = WIN_Handle32( owner16 );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001149 LPCVOID ptr;
1150
1151 if (!(ptr = GlobalLock16( dlgTemplate ))) return -1;
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001152 hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, (DLGPROC)dlgProc,
1153 param, WIN_PROC_16, TRUE );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001154 GlobalUnlock16( dlgTemplate );
Gerard Patelf314e5e2000-08-21 03:31:39 +00001155 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001156 return -1;
1157}
1158
1159
1160/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001161 * DialogBoxIndirectParamA (USER32.@)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001162 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001163INT WINAPI DialogBoxIndirectParamA(HINSTANCE hInstance, LPCVOID template,
1164 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001165 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001166{
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001167 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner,
1168 dlgProc, param, WIN_PROC_32A, TRUE );
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00001169 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001170 return -1;
1171}
1172
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00001173
Alexandre Julliard3ed37e01994-11-07 18:20:42 +00001174/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001175 * DialogBoxIndirectParamW (USER32.@)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001176 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001177INT WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCVOID template,
1178 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001179 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001180{
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001181 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner,
1182 dlgProc, param, WIN_PROC_32W, TRUE );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001183 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1184 return -1;
1185}
1186
Juergen Schmieda4d7ca02000-01-04 00:29:44 +00001187/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001188 * DialogBoxIndirectParamAorW (USER32.@)
Juergen Schmieda4d7ca02000-01-04 00:29:44 +00001189 */
1190INT WINAPI DialogBoxIndirectParamAorW(HINSTANCE hInstance, LPCVOID template,
1191 HWND owner, DLGPROC dlgProc,
1192 LPARAM param, DWORD x )
1193{
1194 HWND hwnd;
1195 FIXME("0x%08x %p 0x%08x %p 0x%08lx 0x%08lx\n",
1196 hInstance, template, owner, dlgProc, param, x);
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001197 hwnd = DIALOG_CreateIndirect( hInstance, template, owner, dlgProc, param, WIN_PROC_32W, TRUE );
Juergen Schmieda4d7ca02000-01-04 00:29:44 +00001198 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1199 return -1;
1200}
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001201
1202/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001203 * EndDialog (USER32.@)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001204 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001205BOOL WINAPI EndDialog( HWND hwnd, INT retval )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001206{
Gerard Patelf314e5e2000-08-21 03:31:39 +00001207 BOOL wasEnabled = TRUE;
Andreas Mohrbeae14d2000-02-12 13:21:23 +00001208 DIALOGINFO * dlgInfo;
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001209 HWND owner;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001210
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001211 TRACE("%04x %d\n", hwnd, retval );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001212
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001213 if (!(dlgInfo = DIALOG_get_info( hwnd )))
Andreas Mohrbeae14d2000-02-12 13:21:23 +00001214 {
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001215 ERR("got invalid window handle (%04x); buggy app !?\n", hwnd);
1216 return FALSE;
Andreas Mohrbeae14d2000-02-12 13:21:23 +00001217 }
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001218 dlgInfo->idResult = retval;
1219 dlgInfo->flags |= DF_END;
1220 wasEnabled = (dlgInfo->flags & DF_OWNERENABLED);
Andreas Mohr01f84261999-03-19 16:49:30 +00001221
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001222 if (wasEnabled && (owner = GetWindow( hwnd, GW_OWNER )))
1223 DIALOG_EnableOwner( owner );
1224
Abey George3336f481999-10-13 15:45:23 +00001225 /* Windows sets the focus to the dialog itself in EndDialog */
Abey George15c58c41999-08-07 14:10:04 +00001226
1227 if (IsChild(hwnd, GetFocus()))
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001228 SetFocus( hwnd );
Abey George15c58c41999-08-07 14:10:04 +00001229
Abey George3336f481999-10-13 15:45:23 +00001230 /* Don't have to send a ShowWindow(SW_HIDE), just do
1231 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
Andreas Mohr01f84261999-03-19 16:49:30 +00001232
Abey George3336f481999-10-13 15:45:23 +00001233 SetWindowPos(hwnd, (HWND)0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
1234 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW);
Stephane Lussier18613bb1999-07-24 10:18:02 +00001235
Gerard Patel53cad8b2001-03-05 19:59:50 +00001236 /* unblock dialog loop */
1237 PostMessageA(hwnd, WM_NULL, 0, 0);
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001238 return TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001239}
1240
1241
1242/***********************************************************************
Norman Stevensa83d0651998-10-12 07:25:35 +00001243 * DIALOG_IsAccelerator
1244 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001245static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM vKey )
Norman Stevensa83d0651998-10-12 07:25:35 +00001246{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001247 HWND hwndControl = hwnd;
1248 HWND hwndNext;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001249 INT dlgCode;
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001250 WCHAR buffer[128];
Norman Stevensa83d0651998-10-12 07:25:35 +00001251
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001252 do
1253 {
1254 DWORD style = GetWindowLongW( hwndControl, GWL_STYLE );
1255 if ((style & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE)
Norman Stevensa83d0651998-10-12 07:25:35 +00001256 {
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001257 dlgCode = SendMessageA( hwndControl, WM_GETDLGCODE, 0, 0 );
1258 if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) &&
1259 GetWindowTextW( hwndControl, buffer, sizeof(buffer)/sizeof(WCHAR) ))
Norman Stevensa83d0651998-10-12 07:25:35 +00001260 {
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001261 /* find the accelerator key */
1262 LPWSTR p = buffer - 2;
1263 char a_char = vKey;
1264 WCHAR w_char = 0;
1265
1266 do
Norman Stevensa83d0651998-10-12 07:25:35 +00001267 {
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001268 p = strchrW( p + 2, '&' );
Norman Stevensa83d0651998-10-12 07:25:35 +00001269 }
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001270 while (p != NULL && p[1] == '&');
Dmitry Timoshkovf92a7771999-12-05 23:51:15 +00001271
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001272 /* and check if it's the one we're looking for */
1273 MultiByteToWideChar(CP_ACP, 0, &a_char, 1, &w_char, 1);
1274 if (p != NULL && toupperW( p[1] ) == toupperW( w_char ) )
1275 {
1276 if ((dlgCode & DLGC_STATIC) || (style & 0x0f) == BS_GROUPBOX )
1277 {
1278 /* set focus to the control */
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001279 SendMessageA( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndControl, 1);
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001280 /* and bump it on to next */
1281 SendMessageA( hwndDlg, WM_NEXTDLGCTL, 0, 0);
1282 }
1283 else if (dlgCode & DLGC_BUTTON)
1284 {
1285 /* send BM_CLICK message to the control */
1286 SendMessageA( hwndControl, BM_CLICK, 0, 0 );
1287 }
1288 return TRUE;
1289 }
1290 }
1291 hwndNext = GetWindow( hwndControl, GW_CHILD );
1292 }
1293 else hwndNext = 0;
1294
1295 if (!hwndNext) hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1296
1297 while (!hwndNext && hwndControl)
1298 {
1299 hwndControl = GetParent( hwndControl );
1300 if (hwndControl == hwndDlg)
1301 {
1302 if(hwnd==hwndDlg) /* prevent endless loop */
1303 {
1304 hwndNext=hwnd;
1305 break;
1306 }
1307 hwndNext = GetWindow( hwndDlg, GW_CHILD );
1308 }
1309 else
1310 hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1311 }
1312 hwndControl = hwndNext;
1313 }
1314 while (hwndControl && (hwndControl != hwnd));
1315
1316 return FALSE;
Norman Stevensa83d0651998-10-12 07:25:35 +00001317}
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001318
Andrew Lewycky0ceb2552000-03-19 14:20:52 +00001319/***********************************************************************
1320 * DIALOG_FindMsgDestination
1321 *
Alexandre Julliard908464d2000-11-01 03:11:12 +00001322 * The messages that IsDialogMessage sends may not go to the dialog
Andrew Lewycky0ceb2552000-03-19 14:20:52 +00001323 * calling IsDialogMessage if that dialog is a child, and it has the
1324 * DS_CONTROL style set.
Alexandre Julliard908464d2000-11-01 03:11:12 +00001325 * We propagate up until we hit one that does not have DS_CONTROL, or
Andrew Lewycky0ceb2552000-03-19 14:20:52 +00001326 * whose parent is not a dialog.
1327 *
1328 * This is undocumented behaviour.
1329 */
1330static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
1331{
1332 while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL)
1333 {
1334 WND *pParent;
1335 HWND hParent = GetParent(hwndDlg);
1336 if (!hParent) break;
1337
1338 pParent = WIN_FindWndPtr(hParent);
1339 if (!pParent) break;
1340
1341 if (!(pParent->flags & WIN_ISDIALOG))
1342 {
1343 WIN_ReleaseWndPtr(pParent);
1344 break;
1345 }
1346 WIN_ReleaseWndPtr(pParent);
1347
1348 hwndDlg = hParent;
1349 }
1350
1351 return hwndDlg;
1352}
Norman Stevensa83d0651998-10-12 07:25:35 +00001353
1354/***********************************************************************
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001355 * DIALOG_IsDialogMessage
Alexandre Julliard0e607781993-11-03 19:23:37 +00001356 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001357static BOOL DIALOG_IsDialogMessage( HWND hwnd, HWND hwndDlg,
1358 UINT message, WPARAM wParam,
1359 LPARAM lParam, BOOL *translate,
1360 BOOL *dispatch, INT dlgCode )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001361{
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001362 *translate = *dispatch = FALSE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001363
Alexandre Julliard641ee761997-08-04 16:34:36 +00001364 if (message == WM_PAINT)
1365 {
1366 /* Apparently, we have to handle this one as well */
1367 *dispatch = TRUE;
1368 return TRUE;
1369 }
1370
Alexandre Julliardaca05781994-10-17 18:12:41 +00001371 /* Only the key messages get special processing */
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001372 if ((message != WM_KEYDOWN) &&
Dmitry Timoshkov780bb792000-11-25 02:10:04 +00001373 (message != WM_SYSKEYDOWN) &&
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001374 (message != WM_SYSCHAR) &&
1375 (message != WM_CHAR))
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00001376 return FALSE;
1377
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00001378 if (dlgCode & DLGC_WANTMESSAGE)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001379 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001380 *translate = *dispatch = TRUE;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00001381 return TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001382 }
Alexandre Julliardaca05781994-10-17 18:12:41 +00001383
Andrew Lewycky0ceb2552000-03-19 14:20:52 +00001384 hwndDlg = DIALOG_FindMsgDestination(hwndDlg);
1385
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001386 switch(message)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001387 {
Alexandre Julliardaca05781994-10-17 18:12:41 +00001388 case WM_KEYDOWN:
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001389 switch(wParam)
Alexandre Julliardaca05781994-10-17 18:12:41 +00001390 {
1391 case VK_TAB:
1392 if (!(dlgCode & DLGC_WANTTAB))
1393 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001394 SendMessageA( hwndDlg, WM_NEXTDLGCTL,
1395 (GetKeyState(VK_SHIFT) & 0x8000), 0 );
Alexandre Julliardaca05781994-10-17 18:12:41 +00001396 return TRUE;
1397 }
1398 break;
1399
1400 case VK_RIGHT:
1401 case VK_DOWN:
Alexandre Julliardaca05781994-10-17 18:12:41 +00001402 case VK_LEFT:
1403 case VK_UP:
1404 if (!(dlgCode & DLGC_WANTARROWS))
1405 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001406 BOOL fPrevious = (wParam == VK_LEFT || wParam == VK_UP);
1407 HWND hwndNext =
1408 GetNextDlgGroupItem (hwndDlg, GetFocus(), fPrevious );
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001409 SendMessageA( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndNext, 1 );
Alexandre Julliardaca05781994-10-17 18:12:41 +00001410 return TRUE;
1411 }
1412 break;
1413
1414 case VK_ESCAPE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001415 SendMessageA( hwndDlg, WM_COMMAND, IDCANCEL,
1416 (LPARAM)GetDlgItem( hwndDlg, IDCANCEL ) );
Norman Stevensa83d0651998-10-12 07:25:35 +00001417 return TRUE;
Alexandre Julliardaca05781994-10-17 18:12:41 +00001418
1419 case VK_RETURN:
1420 {
Alexandre Julliardbfb4a232001-08-06 18:05:47 +00001421 DWORD dw = SendMessageW( hwndDlg, DM_GETDEFID, 0, 0 );
Alexandre Julliardaca05781994-10-17 18:12:41 +00001422 if (HIWORD(dw) == DC_HASDEFID)
Norman Stevensa83d0651998-10-12 07:25:35 +00001423 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001424 SendMessageA( hwndDlg, WM_COMMAND,
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001425 MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
Alexandre Julliarda3960291999-02-26 11:11:13 +00001426 (LPARAM)GetDlgItem(hwndDlg, LOWORD(dw)));
Norman Stevensa83d0651998-10-12 07:25:35 +00001427 }
Alexandre Julliardaf0bae51995-10-03 17:06:08 +00001428 else
Norman Stevensa83d0651998-10-12 07:25:35 +00001429 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001430 SendMessageA( hwndDlg, WM_COMMAND, IDOK,
1431 (LPARAM)GetDlgItem( hwndDlg, IDOK ) );
Norman Stevensa83d0651998-10-12 07:25:35 +00001432
1433 }
Alexandre Julliardaca05781994-10-17 18:12:41 +00001434 }
Norman Stevensa83d0651998-10-12 07:25:35 +00001435 return TRUE;
Alexandre Julliardaca05781994-10-17 18:12:41 +00001436 }
Norman Stevensa83d0651998-10-12 07:25:35 +00001437 *translate = TRUE;
1438 break; /* case WM_KEYDOWN */
Alexandre Julliardaca05781994-10-17 18:12:41 +00001439
Alexandre Julliardaca05781994-10-17 18:12:41 +00001440 case WM_CHAR:
Norman Stevensa83d0651998-10-12 07:25:35 +00001441 if (dlgCode & DLGC_WANTCHARS) break;
1442 /* drop through */
Alexandre Julliardaca05781994-10-17 18:12:41 +00001443
1444 case WM_SYSCHAR:
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001445 if (DIALOG_IsAccelerator( WIN_GetFullHandle(hwnd), hwndDlg, wParam ))
Norman Stevensa83d0651998-10-12 07:25:35 +00001446 {
1447 /* don't translate or dispatch */
1448 return TRUE;
1449 }
Alexandre Julliardaca05781994-10-17 18:12:41 +00001450 break;
Dmitry Timoshkov780bb792000-11-25 02:10:04 +00001451
1452 case WM_SYSKEYDOWN:
1453 *translate = TRUE;
1454 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001455 }
Alexandre Julliardaca05781994-10-17 18:12:41 +00001456
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001457 /* If we get here, the message has not been treated specially */
1458 /* and can be sent to its destination window. */
1459 *dispatch = TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001460 return TRUE;
1461}
1462
1463
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001464/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001465 * IsDialogMessage (USER.90)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001466 */
Alexandre Julliardac7efef2000-11-27 21:54:01 +00001467BOOL16 WINAPI IsDialogMessage16( HWND16 hwndDlg, SEGPTR msg16 )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001468{
Alexandre Julliard982a2232000-12-13 20:20:09 +00001469 LPMSG16 msg = MapSL(msg16);
Alexandre Julliarda3960291999-02-26 11:11:13 +00001470 BOOL ret, translate, dispatch;
David Grantedb77971999-11-07 21:02:17 +00001471 INT dlgCode = 0;
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001472
1473 if ((hwndDlg != msg->hwnd) && !IsChild16( hwndDlg, msg->hwnd ))
1474 return FALSE;
1475
David Grantedb77971999-11-07 21:02:17 +00001476 if ((msg->message == WM_KEYDOWN) ||
David Grantedb77971999-11-07 21:02:17 +00001477 (msg->message == WM_CHAR))
1478 {
1479 dlgCode = SendMessage16( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg16);
1480 }
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001481 ret = DIALOG_IsDialogMessage( WIN_Handle32(msg->hwnd), WIN_Handle32(hwndDlg),
1482 msg->message, msg->wParam, msg->lParam,
Norman Stevensa83d0651998-10-12 07:25:35 +00001483 &translate, &dispatch, dlgCode );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001484 if (translate) TranslateMessage16( msg );
1485 if (dispatch) DispatchMessage16( msg );
1486 return ret;
1487}
1488
1489
1490/***********************************************************************
Patrik Stridvall17fd4e32001-06-28 18:04:41 +00001491 * IsDialogMessage (USER32.@)
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001492 * IsDialogMessageA (USER32.@)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001493 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001494BOOL WINAPI IsDialogMessageA( HWND hwndDlg, LPMSG msg )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001495{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001496 BOOL ret, translate, dispatch;
David Grantedb77971999-11-07 21:02:17 +00001497 INT dlgCode = 0;
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001498
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001499 hwndDlg = WIN_GetFullHandle( hwndDlg );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001500 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001501 return FALSE;
1502
David Grantedb77971999-11-07 21:02:17 +00001503 if ((msg->message == WM_KEYDOWN) ||
David Grantedb77971999-11-07 21:02:17 +00001504 (msg->message == WM_CHAR))
1505 {
1506 dlgCode = SendMessageA( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
1507 }
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001508 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1509 msg->wParam, msg->lParam,
Norman Stevensa83d0651998-10-12 07:25:35 +00001510 &translate, &dispatch, dlgCode );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001511 if (translate) TranslateMessage( msg );
1512 if (dispatch) DispatchMessageA( msg );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001513 return ret;
1514}
1515
1516
1517/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001518 * IsDialogMessageW (USER32.@)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001519 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001520BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001521{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001522 BOOL ret, translate, dispatch;
David Grantedb77971999-11-07 21:02:17 +00001523 INT dlgCode = 0;
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001524
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001525 hwndDlg = WIN_GetFullHandle( hwndDlg );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001526 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001527 return FALSE;
1528
David Grantedb77971999-11-07 21:02:17 +00001529 if ((msg->message == WM_KEYDOWN) ||
David Grantedb77971999-11-07 21:02:17 +00001530 (msg->message == WM_CHAR))
1531 {
1532 dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
1533 }
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001534 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1535 msg->wParam, msg->lParam,
Norman Stevensa83d0651998-10-12 07:25:35 +00001536 &translate, &dispatch, dlgCode );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001537 if (translate) TranslateMessage( msg );
1538 if (dispatch) DispatchMessageW( msg );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001539 return ret;
1540}
1541
1542
Patrik Stridvall54fe8382000-04-06 20:21:16 +00001543/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001544 * GetDlgCtrlID (USER32.@)
Alexandre Julliard01d63461997-01-20 19:43:45 +00001545 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001546INT WINAPI GetDlgCtrlID( HWND hwnd )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001547{
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001548 return GetWindowLongW( hwnd, GWL_ID );
Alexandre Julliard0e607781993-11-03 19:23:37 +00001549}
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001550
Alexandre Julliard0e607781993-11-03 19:23:37 +00001551
1552/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001553 * GetDlgItem (USER32.@)
Alexandre Julliard01d63461997-01-20 19:43:45 +00001554 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001555HWND WINAPI GetDlgItem( HWND hwndDlg, INT id )
Alexandre Julliard01d63461997-01-20 19:43:45 +00001556{
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001557 int i;
Alexandre Julliard9d9dac02001-08-24 19:28:21 +00001558 HWND *list = WIN_ListChildren( hwndDlg );
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001559 HWND ret = 0;
Alexandre Julliard01d63461997-01-20 19:43:45 +00001560
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001561 if (!list) return 0;
1562
1563 for (i = 0; list[i]; i++) if (GetWindowLongW( list[i], GWL_ID ) == id) break;
1564 ret = list[i];
Alexandre Julliard9d9dac02001-08-24 19:28:21 +00001565 HeapFree( GetProcessHeap(), 0, list );
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001566 return ret;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001567}
1568
1569
1570/*******************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001571 * SendDlgItemMessageA (USER32.@)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001572 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001573LRESULT WINAPI SendDlgItemMessageA( HWND hwnd, INT id, UINT msg,
1574 WPARAM wParam, LPARAM lParam )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001575{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001576 HWND hwndCtrl = GetDlgItem( hwnd, id );
1577 if (hwndCtrl) return SendMessageA( hwndCtrl, msg, wParam, lParam );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001578 else return 0;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001579}
1580
1581
1582/*******************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001583 * SendDlgItemMessageW (USER32.@)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001584 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001585LRESULT WINAPI SendDlgItemMessageW( HWND hwnd, INT id, UINT msg,
1586 WPARAM wParam, LPARAM lParam )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001587{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001588 HWND hwndCtrl = GetDlgItem( hwnd, id );
1589 if (hwndCtrl) return SendMessageW( hwndCtrl, msg, wParam, lParam );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001590 else return 0;
1591}
1592
1593
1594/*******************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001595 * SetDlgItemTextA (USER32.@)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001596 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001597BOOL WINAPI SetDlgItemTextA( HWND hwnd, INT id, LPCSTR lpString )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001598{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001599 return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001600}
1601
1602
1603/*******************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001604 * SetDlgItemTextW (USER32.@)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001605 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001606BOOL WINAPI SetDlgItemTextW( HWND hwnd, INT id, LPCWSTR lpString )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001607{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001608 return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001609}
1610
1611
1612/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001613 * GetDlgItemTextA (USER32.@)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001614 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001615INT WINAPI GetDlgItemTextA( HWND hwnd, INT id, LPSTR str, UINT len )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001616{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001617 return (INT)SendDlgItemMessageA( hwnd, id, WM_GETTEXT,
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001618 len, (LPARAM)str );
1619}
1620
1621
1622/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001623 * GetDlgItemTextW (USER32.@)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001624 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001625INT WINAPI GetDlgItemTextW( HWND hwnd, INT id, LPWSTR str, UINT len )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001626{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001627 return (INT)SendDlgItemMessageW( hwnd, id, WM_GETTEXT,
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001628 len, (LPARAM)str );
1629}
1630
1631
1632/*******************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001633 * SetDlgItemInt (USER32.@)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001634 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001635BOOL WINAPI SetDlgItemInt( HWND hwnd, INT id, UINT value,
1636 BOOL fSigned )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001637{
1638 char str[20];
1639
Alexandre Julliarda3960291999-02-26 11:11:13 +00001640 if (fSigned) sprintf( str, "%d", (INT)value );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001641 else sprintf( str, "%u", value );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001642 SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)str );
Eric Pouechb9544f11999-02-14 14:09:42 +00001643 return TRUE;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001644}
1645
1646
Alexandre Julliard0e607781993-11-03 19:23:37 +00001647/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001648 * GetDlgItemInt (USER32.@)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001649 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001650UINT WINAPI GetDlgItemInt( HWND hwnd, INT id, BOOL *translated,
1651 BOOL fSigned )
Alexandre Julliard01d63461997-01-20 19:43:45 +00001652{
1653 char str[30];
1654 char * endptr;
1655 long result = 0;
1656
1657 if (translated) *translated = FALSE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001658 if (!SendDlgItemMessageA(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str))
Alexandre Julliard01d63461997-01-20 19:43:45 +00001659 return 0;
1660 if (fSigned)
1661 {
1662 result = strtol( str, &endptr, 10 );
1663 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1664 return 0;
1665 if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE))
1666 return 0;
1667 }
1668 else
1669 {
1670 result = strtoul( str, &endptr, 10 );
1671 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1672 return 0;
1673 if ((result == ULONG_MAX) && (errno == ERANGE)) return 0;
1674 }
1675 if (translated) *translated = TRUE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001676 return (UINT)result;
Alexandre Julliard01d63461997-01-20 19:43:45 +00001677}
1678
1679
1680/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001681 * CheckDlgButton (USER32.@)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001682 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001683BOOL WINAPI CheckDlgButton( HWND hwnd, INT id, UINT check )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001684{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001685 SendDlgItemMessageA( hwnd, id, BM_SETCHECK, check, 0 );
Alexandre Julliard01d63461997-01-20 19:43:45 +00001686 return TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001687}
1688
1689
1690/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001691 * IsDlgButtonChecked (USER32.@)
Alexandre Julliard01d63461997-01-20 19:43:45 +00001692 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001693UINT WINAPI IsDlgButtonChecked( HWND hwnd, UINT id )
Alexandre Julliard01d63461997-01-20 19:43:45 +00001694{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001695 return (UINT)SendDlgItemMessageA( hwnd, id, BM_GETCHECK, 0, 0 );
Alexandre Julliard01d63461997-01-20 19:43:45 +00001696}
1697
1698
1699/***********************************************************************
Luc Tourangeau8e238d01999-05-29 14:19:42 +00001700 * CheckRB
1701 *
1702 * Callback function used to check/uncheck radio buttons that fall
1703 * within a specific range of IDs.
1704 */
1705static BOOL CALLBACK CheckRB(HWND hwndChild, LPARAM lParam)
1706{
1707 LONG lChildID = GetWindowLongA(hwndChild, GWL_ID);
1708 RADIOGROUP *lpRadioGroup = (RADIOGROUP *) lParam;
1709
1710 if ((lChildID >= lpRadioGroup->firstID) &&
1711 (lChildID <= lpRadioGroup->lastID))
1712 {
1713 if (lChildID == lpRadioGroup->checkID)
1714 {
1715 SendMessageA(hwndChild, BM_SETCHECK, BST_CHECKED, 0);
1716 }
1717 else
1718 {
1719 SendMessageA(hwndChild, BM_SETCHECK, BST_UNCHECKED, 0);
1720 }
1721 }
1722
1723 return TRUE;
1724}
1725
1726
1727/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001728 * CheckRadioButton (USER32.@)
Alexandre Julliard01d63461997-01-20 19:43:45 +00001729 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001730BOOL WINAPI CheckRadioButton( HWND hwndDlg, UINT firstID,
Luc Tourangeau8e238d01999-05-29 14:19:42 +00001731 UINT lastID, UINT checkID )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001732{
Luc Tourangeau8e238d01999-05-29 14:19:42 +00001733 RADIOGROUP radioGroup;
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00001734
Luc Tourangeau8e238d01999-05-29 14:19:42 +00001735 /* perform bounds checking for a radio button group */
1736 radioGroup.firstID = min(min(firstID, lastID), checkID);
1737 radioGroup.lastID = max(max(firstID, lastID), checkID);
1738 radioGroup.checkID = checkID;
1739
1740 return EnumChildWindows(hwndDlg, (WNDENUMPROC)CheckRB,
1741 (LPARAM)&radioGroup);
Alexandre Julliard0e607781993-11-03 19:23:37 +00001742}
1743
1744
1745/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +00001746 * GetDialogBaseUnits (USER.243)
1747 * GetDialogBaseUnits (USER32.@)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001748 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001749DWORD WINAPI GetDialogBaseUnits(void)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001750{
1751 return MAKELONG( xBaseUnit, yBaseUnit );
1752}
1753
1754
1755/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001756 * MapDialogRect (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001757 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001758BOOL WINAPI MapDialogRect( HWND hwnd, LPRECT rect )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001759{
1760 DIALOGINFO * dlgInfo;
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001761 if (!(dlgInfo = DIALOG_get_info( hwnd ))) return FALSE;
Francis Beaudeteb13dd41999-09-03 15:14:27 +00001762 rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4);
1763 rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4);
1764 rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8);
1765 rect->bottom = MulDiv(rect->bottom, dlgInfo->yBaseUnit, 8);
Eric Pouechb9544f11999-02-14 14:09:42 +00001766 return TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001767}
1768
1769
1770/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001771 * GetNextDlgGroupItem (USER32.@)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001772 */
Alexandre Julliardd23a82b2001-09-19 20:37:04 +00001773HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001774{
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001775 HWND hwnd, retvalue;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001776
Alexandre Julliard37a46392001-09-12 17:19:13 +00001777 hwndDlg = WIN_GetFullHandle( hwndDlg );
1778 hwndCtrl = WIN_GetFullHandle( hwndCtrl );
1779
Alexandre Julliarde6b82e71999-12-12 20:17:59 +00001780 if(hwndCtrl)
1781 {
Alexandre Julliard908464d2000-11-01 03:11:12 +00001782 /* if the hwndCtrl is the child of the control in the hwndDlg,
1783 * then the hwndDlg has to be the parent of the hwndCtrl */
Alexandre Julliarde6b82e71999-12-12 20:17:59 +00001784 if(GetParent(hwndCtrl) != hwndDlg && GetParent(GetParent(hwndCtrl)) == hwndDlg)
1785 hwndDlg = GetParent(hwndCtrl);
1786 }
1787
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001788 if (hwndCtrl)
1789 {
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001790 /* Make sure hwndCtrl is a top-level child */
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001791 HWND parent = GetParent( hwndCtrl );
1792 while (parent && parent != hwndDlg) parent = GetParent(parent);
1793 if (parent != hwndDlg) return 0;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001794 }
1795 else
1796 {
1797 /* No ctrl specified -> start from the beginning */
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001798 if (!(hwndCtrl = GetWindow( hwndDlg, GW_CHILD ))) return 0;
1799 if (fPrevious) hwndCtrl = GetWindow( hwndCtrl, GW_HWNDLAST );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001800 }
1801
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001802 retvalue = hwndCtrl;
1803 hwnd = GetWindow( hwndCtrl, GW_HWNDNEXT );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001804 while (1)
1805 {
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001806 if (!hwnd || (GetWindowLongW( hwnd, GWL_STYLE ) & WS_GROUP))
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001807 {
1808 /* Wrap-around to the beginning of the group */
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001809 HWND tmp;
Ulrich Weigand9c3b18f1999-05-17 14:54:09 +00001810
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001811 hwnd = GetWindow( hwndDlg, GW_CHILD );
1812 for (tmp = hwnd; tmp; tmp = GetWindow( tmp, GW_HWNDNEXT ) )
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001813 {
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001814 if (GetWindowLongW( tmp, GWL_STYLE ) & WS_GROUP) hwnd = tmp;
1815 if (tmp == hwndCtrl) break;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001816 }
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001817 }
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001818 if (hwnd == hwndCtrl) break;
1819 if ((GetWindowLongW( hwnd, GWL_STYLE ) & (WS_VISIBLE|WS_DISABLED)) == WS_VISIBLE)
1820 {
1821 retvalue = hwnd;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001822 if (!fPrevious) break;
1823 }
Alexandre Julliard0801ffc2001-08-24 00:26:59 +00001824 hwnd = GetWindow( hwnd, GW_HWNDNEXT );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001825 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001826 return retvalue;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001827}
1828
1829
1830/***********************************************************************
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001831 * DIALOG_GetNextTabItem
1832 *
1833 * Helper for GetNextDlgTabItem
1834 */
1835static HWND DIALOG_GetNextTabItem( HWND hwndMain, HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
1836{
1837 LONG dsStyle;
1838 LONG exStyle;
1839 UINT wndSearch = fPrevious ? GW_HWNDPREV : GW_HWNDNEXT;
1840 HWND retWnd = 0;
1841 HWND hChildFirst = 0;
1842
1843 if(!hwndCtrl)
1844 {
1845 hChildFirst = GetWindow(hwndDlg,GW_CHILD);
1846 if(fPrevious) hChildFirst = GetWindow(hChildFirst,GW_HWNDLAST);
1847 }
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001848 else if (IsChild( hwndMain, hwndCtrl ))
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001849 {
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001850 hChildFirst = GetWindow(hwndCtrl,wndSearch);
1851 if(!hChildFirst)
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001852 {
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001853 if(GetParent(hwndCtrl) != hwndMain)
1854 hChildFirst = GetWindow(GetParent(hwndCtrl),wndSearch);
1855 else
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001856 {
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001857 if(fPrevious)
1858 hChildFirst = GetWindow(hwndCtrl,GW_HWNDLAST);
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001859 else
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001860 hChildFirst = GetWindow(hwndCtrl,GW_HWNDFIRST);
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001861 }
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001862 }
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001863 }
Alexandre Julliardf44bbb82001-09-14 00:24:39 +00001864
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001865 while(hChildFirst)
1866 {
1867 BOOL bCtrl = FALSE;
1868 while(hChildFirst)
1869 {
1870 dsStyle = GetWindowLongA(hChildFirst,GWL_STYLE);
1871 exStyle = GetWindowLongA(hChildFirst,GWL_EXSTYLE);
Alexandre Julliarde6b82e71999-12-12 20:17:59 +00001872 if( (dsStyle & DS_CONTROL || exStyle & WS_EX_CONTROLPARENT) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001873 {
1874 bCtrl=TRUE;
1875 break;
1876 }
1877 else if( (dsStyle & WS_TABSTOP) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
1878 break;
1879 hChildFirst = GetWindow(hChildFirst,wndSearch);
1880 }
1881 if(hChildFirst)
1882 {
1883 if(bCtrl)
1884 retWnd = DIALOG_GetNextTabItem(hwndMain,hChildFirst,(HWND)NULL,fPrevious );
1885 else
1886 retWnd = hChildFirst;
1887 }
1888 if(retWnd) break;
1889 hChildFirst = GetWindow(hChildFirst,wndSearch);
1890 }
1891 if(!retWnd && hwndCtrl)
1892 {
1893 HWND hParent = GetParent(hwndCtrl);
1894 while(hParent)
1895 {
1896 if(hParent == hwndMain) break;
1897 retWnd = DIALOG_GetNextTabItem(hwndMain,GetParent(hParent),hParent,fPrevious );
1898 if(retWnd) break;
1899 hParent = GetParent(hParent);
1900 }
1901 if(!retWnd)
1902 retWnd = DIALOG_GetNextTabItem(hwndMain,hwndMain,(HWND)NULL,fPrevious );
1903 }
1904 return retWnd;
1905}
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001906
1907/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001908 * GetNextDlgTabItem (USER32.@)
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001909 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001910HWND WINAPI GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl,
1911 BOOL fPrevious )
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001912{
Alexandre Julliard37a46392001-09-12 17:19:13 +00001913 hwndDlg = WIN_GetFullHandle( hwndDlg );
1914 hwndCtrl = WIN_GetFullHandle( hwndCtrl );
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001915 return DIALOG_GetNextTabItem(hwndDlg,hwndDlg,hwndCtrl,fPrevious);
Alexandre Julliard0e607781993-11-03 19:23:37 +00001916}
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001917
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001918/**********************************************************************
1919 * DIALOG_DlgDirSelect
1920 *
1921 * Helper function for DlgDirSelect*
1922 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001923static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len,
Alexandre Julliardcb25e252001-08-08 23:28:42 +00001924 INT id, BOOL unicode, BOOL combo )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001925{
1926 char *buffer, *ptr;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001927 INT item, size;
1928 BOOL ret;
1929 HWND listbox = GetDlgItem( hwnd, id );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001930
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001931 TRACE("%04x '%s' %d\n", hwnd, str, id );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001932 if (!listbox) return FALSE;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001933
Alexandre Julliardcb25e252001-08-08 23:28:42 +00001934 item = SendMessageA(listbox, combo ? CB_GETCURSEL : LB_GETCURSEL, 0, 0 );
1935 if (item == LB_ERR) return FALSE;
1936 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN : LB_GETTEXTLEN, 0, 0 );
1937 if (size == LB_ERR) return FALSE;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001938
Alexandre Julliardcb25e252001-08-08 23:28:42 +00001939 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size+1 ))) return FALSE;
1940
1941 SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT, item, (LPARAM)buffer );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001942
1943 if ((ret = (buffer[0] == '['))) /* drive or directory */
1944 {
1945 if (buffer[1] == '-') /* drive */
1946 {
1947 buffer[3] = ':';
1948 buffer[4] = 0;
1949 ptr = buffer + 2;
1950 }
1951 else
1952 {
1953 buffer[strlen(buffer)-1] = '\\';
1954 ptr = buffer + 1;
1955 }
1956 }
1957 else ptr = buffer;
1958
Alexandre Julliard24a62ab2000-11-28 22:40:56 +00001959 if (unicode)
1960 {
1961 if (len > 0 && !MultiByteToWideChar( CP_ACP, 0, ptr, -1, (LPWSTR)str, len ))
1962 ((LPWSTR)str)[len-1] = 0;
1963 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00001964 else lstrcpynA( str, ptr, len );
Alexandre Julliardcb25e252001-08-08 23:28:42 +00001965 HeapFree( GetProcessHeap(), 0, buffer );
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001966 TRACE("Returning %d '%s'\n", ret, str );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001967 return ret;
1968}
1969
1970
1971/**********************************************************************
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00001972 * DIALOG_DlgDirList
1973 *
1974 * Helper function for DlgDirList*
1975 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001976static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox,
1977 INT idStatic, UINT attrib, BOOL combo )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00001978{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001979 HWND hwnd;
Alexandre Julliard84c70f51997-05-09 08:40:27 +00001980 LPSTR orig_spec = spec;
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00001981
1982#define SENDMSG(msg,wparam,lparam) \
Alexandre Julliarda3960291999-02-26 11:11:13 +00001983 ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \
1984 : SendMessageA( hwnd, msg, wparam, lparam ))
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00001985
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001986 TRACE("%04x '%s' %d %d %04x\n",
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00001987 hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
1988
Alexandre Julliard84c70f51997-05-09 08:40:27 +00001989 /* If the path exists and is a directory, chdir to it */
Alexandre Julliard91222da2000-12-10 23:01:33 +00001990 if (!spec || !spec[0] || SetCurrentDirectoryA( spec )) spec = "*.*";
Alexandre Julliard84c70f51997-05-09 08:40:27 +00001991 else
1992 {
1993 char *p, *p2;
1994 p = spec;
1995 if ((p2 = strrchr( p, '\\' ))) p = p2;
1996 if ((p2 = strrchr( p, '/' ))) p = p2;
1997 if (p != spec)
1998 {
1999 char sep = *p;
2000 *p = 0;
Alexandre Julliard91222da2000-12-10 23:01:33 +00002001 if (!SetCurrentDirectoryA( spec ))
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002002 {
2003 *p = sep; /* Restore the original spec */
2004 return FALSE;
2005 }
2006 spec = p + 1;
2007 }
2008 }
2009
Alexandre Julliard91222da2000-12-10 23:01:33 +00002010 TRACE( "mask=%s\n", spec );
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002011
Alexandre Julliarda3960291999-02-26 11:11:13 +00002012 if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0))
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002013 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002014 SENDMSG( combo ? CB_RESETCONTENT : LB_RESETCONTENT, 0, 0 );
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002015 if (attrib & DDL_DIRECTORY)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002016 {
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002017 if (!(attrib & DDL_EXCLUSIVE))
2018 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002019 if (SENDMSG( combo ? CB_DIR : LB_DIR,
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002020 attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
2021 (LPARAM)spec ) == LB_ERR)
2022 return FALSE;
2023 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00002024 if (SENDMSG( combo ? CB_DIR : LB_DIR,
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002025 (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
2026 (LPARAM)"*.*" ) == LB_ERR)
2027 return FALSE;
2028 }
2029 else
2030 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002031 if (SENDMSG( combo ? CB_DIR : LB_DIR, attrib,
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002032 (LPARAM)spec ) == LB_ERR)
2033 return FALSE;
2034 }
2035 }
2036
Alexandre Julliarda3960291999-02-26 11:11:13 +00002037 if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002038 {
Alexandre Julliard91222da2000-12-10 23:01:33 +00002039 char temp[MAX_PATH];
2040 GetCurrentDirectoryA( sizeof(temp), temp );
Alexandre Julliarda3960291999-02-26 11:11:13 +00002041 CharLowerA( temp );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002042 /* Can't use PostMessage() here, because the string is on the stack */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002043 SetDlgItemTextA( hDlg, idStatic, temp );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002044 }
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002045
2046 if (orig_spec && (spec != orig_spec))
2047 {
2048 /* Update the original file spec */
2049 char *p = spec;
2050 while ((*orig_spec++ = *p++));
2051 }
2052
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002053 return TRUE;
2054#undef SENDMSG
2055}
2056
2057
2058/**********************************************************************
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002059 * DIALOG_DlgDirListW
2060 *
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002061 * Helper function for DlgDirList*W
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002062 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002063static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2064 INT idStatic, UINT attrib, BOOL combo )
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002065{
2066 if (spec)
2067 {
2068 LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
Alexandre Julliarda3960291999-02-26 11:11:13 +00002069 INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002070 attrib, combo );
Alexandre Julliard24a62ab2000-11-28 22:40:56 +00002071 MultiByteToWideChar( CP_ACP, 0, specA, -1, spec, 0x7fffffff );
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002072 HeapFree( GetProcessHeap(), 0, specA );
2073 return ret;
2074 }
2075 return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
2076}
2077
2078
2079/**********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00002080 * DlgDirSelectExA (USER32.@)
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002081 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002082BOOL WINAPI DlgDirSelectExA( HWND hwnd, LPSTR str, INT len, INT id )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002083{
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002084 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002085}
2086
2087
2088/**********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00002089 * DlgDirSelectExW (USER32.@)
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002090 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002091BOOL WINAPI DlgDirSelectExW( HWND hwnd, LPWSTR str, INT len, INT id )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002092{
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002093 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, FALSE );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002094}
2095
2096
2097/**********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00002098 * DlgDirSelectComboBoxExA (USER32.@)
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002099 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002100BOOL WINAPI DlgDirSelectComboBoxExA( HWND hwnd, LPSTR str, INT len,
2101 INT id )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002102{
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002103 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, TRUE );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002104}
2105
2106
2107/**********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00002108 * DlgDirSelectComboBoxExW (USER32.@)
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002109 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002110BOOL WINAPI DlgDirSelectComboBoxExW( HWND hwnd, LPWSTR str, INT len,
2111 INT id)
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002112{
Alexandre Julliardcb25e252001-08-08 23:28:42 +00002113 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002114}
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002115
2116
2117/**********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00002118 * DlgDirListA (USER32.@)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002119 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002120INT WINAPI DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox,
2121 INT idStatic, UINT attrib )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002122{
2123 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2124}
2125
2126
2127/**********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00002128 * DlgDirListW (USER32.@)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002129 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002130INT WINAPI DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2131 INT idStatic, UINT attrib )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002132{
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002133 return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002134}
2135
2136
2137/**********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00002138 * DlgDirListComboBoxA (USER32.@)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002139 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002140INT WINAPI DlgDirListComboBoxA( HWND hDlg, LPSTR spec, INT idCBox,
2141 INT idStatic, UINT attrib )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002142{
2143 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
2144}
2145
2146
2147/**********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00002148 * DlgDirListComboBoxW (USER32.@)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002149 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002150INT WINAPI DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox,
2151 INT idStatic, UINT attrib )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002152{
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002153 return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002154}