blob: 3d9b73d83b6c38d8daa0b55362ccd6921db62998 [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 Julliard59730ae1996-03-24 16:20:51 +00005 */
Alexandre Julliard0e607781993-11-03 19:23:37 +00006
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00007#include <ctype.h>
Patrik Stridvall1e1cf481998-10-17 12:56:00 +00008#include <errno.h>
Alexandre Julliard01d63461997-01-20 19:43:45 +00009#include <limits.h>
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000010#include <stdlib.h>
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000011#include <string.h>
Marcus Meissner61afa331999-02-22 10:16:00 +000012#include "winuser.h"
Slava Monich3a170a11999-06-06 09:03:08 +000013#include "windowsx.h"
Marcus Meissner61afa331999-02-22 10:16:00 +000014#include "wine/winuser16.h"
15#include "wine/winbase16.h"
Alexandre Julliard0e607781993-11-03 19:23:37 +000016#include "dialog.h"
Alexandre Julliardda0cfb31996-12-01 17:17:47 +000017#include "drive.h"
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000018#include "heap.h"
Alexandre Julliard0e607781993-11-03 19:23:37 +000019#include "win.h"
Alexandre Julliarde2abbb11995-03-19 17:39:39 +000020#include "ldt.h"
Alexandre Julliarddba420a1994-02-02 06:48:31 +000021#include "user.h"
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000022#include "winproc.h"
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +000023#include "message.h"
Alexandre Julliard359f497e1999-07-04 16:02:24 +000024#include "debugtools.h"
Alexandre Julliard0e607781993-11-03 19:23:37 +000025
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000026DEFAULT_DEBUG_CHANNEL(dialog)
27
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000028
29 /* Dialog control information */
30typedef struct
31{
32 DWORD style;
33 DWORD exStyle;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000034 DWORD helpId;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000035 INT16 x;
36 INT16 y;
37 INT16 cx;
38 INT16 cy;
Alexandre Julliarda3960291999-02-26 11:11:13 +000039 UINT id;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000040 LPCSTR className;
41 LPCSTR windowName;
42 LPVOID data;
43} DLG_CONTROL_INFO;
44
45 /* Dialog template */
46typedef struct
47{
48 DWORD style;
49 DWORD exStyle;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000050 DWORD helpId;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000051 UINT16 nbItems;
52 INT16 x;
53 INT16 y;
54 INT16 cx;
55 INT16 cy;
56 LPCSTR menuName;
57 LPCSTR className;
58 LPCSTR caption;
59 WORD pointSize;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000060 WORD weight;
Alexandre Julliarda3960291999-02-26 11:11:13 +000061 BOOL italic;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000062 LPCSTR faceName;
Alexandre Julliarda3960291999-02-26 11:11:13 +000063 BOOL dialogEx;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000064} DLG_TEMPLATE;
65
Luc Tourangeau8e238d01999-05-29 14:19:42 +000066 /* Radio button group */
67typedef struct
68{
69 UINT firstID;
70 UINT lastID;
71 UINT checkID;
72} RADIOGROUP;
73
Alexandre Julliard0e607781993-11-03 19:23:37 +000074 /* Dialog base units */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000075static WORD xBaseUnit = 0, yBaseUnit = 0;
Alexandre Julliard0e607781993-11-03 19:23:37 +000076
Alexandre Julliard0e607781993-11-03 19:23:37 +000077/***********************************************************************
Slava Monich3a170a11999-06-06 09:03:08 +000078 * DIALOG_GetCharSizeFromDC
79 *
80 *
81 * Calculates the *true* average size of English characters in the
82 * specified font as oppposed to the one returned by GetTextMetrics.
Richard Cohen0ded0fe1999-09-05 12:25:33 +000083 *
84 * Latest: the X font driver will now compute a proper average width
85 * so this code can be removed
Slava Monich3a170a11999-06-06 09:03:08 +000086 */
87static BOOL DIALOG_GetCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize )
88{
89 BOOL Success = FALSE;
90 HFONT hFontPrev = 0;
91 pSize->cx = xBaseUnit;
92 pSize->cy = yBaseUnit;
93 if ( hDC )
94 {
95 /* select the font */
96 TEXTMETRICA tm;
97 memset(&tm,0,sizeof(tm));
98 if (hFont) hFontPrev = SelectFont(hDC,hFont);
99 if (GetTextMetricsA(hDC,&tm))
100 {
101 pSize->cx = tm.tmAveCharWidth;
102 pSize->cy = tm.tmHeight;
103
104 /* if variable width font */
105 if (tm.tmPitchAndFamily & TMPF_FIXED_PITCH)
106 {
107 SIZE total;
Richard Cohen0ded0fe1999-09-05 12:25:33 +0000108 const char* szAvgChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
Slava Monich3a170a11999-06-06 09:03:08 +0000109
110 /* Calculate a true average as opposed to the one returned
111 * by tmAveCharWidth. This works better when dealing with
112 * proportional spaced fonts and (more important) that's
113 * how Microsoft's dialog creation code calculates the size
114 * of the font
115 */
116 if (GetTextExtentPointA(hDC,szAvgChars,sizeof(szAvgChars),&total))
117 {
118 /* round up */
119 pSize->cx = ((2*total.cx/sizeof(szAvgChars)) + 1)/2;
120 Success = TRUE;
121 }
122 }
123 else
124 {
125 Success = TRUE;
126 }
Richard Cohen0ded0fe1999-09-05 12:25:33 +0000127 /* Use the text metrics */
128 TRACE("Using tm: %ldx%ld (dlg: %dx%d) (%s)\n", tm.tmAveCharWidth, tm.tmHeight, pSize->cx, pSize->cy,
129 tm.tmPitchAndFamily & TMPF_FIXED_PITCH ? "variable" : "fixed");
130 pSize->cx = tm.tmAveCharWidth;
131 pSize->cy = tm.tmHeight;
Slava Monich3a170a11999-06-06 09:03:08 +0000132 }
Slava Monich3a170a11999-06-06 09:03:08 +0000133 /* select the original font */
134 if (hFontPrev) SelectFont(hDC,hFontPrev);
135 }
136 return (Success);
137}
138
Slava Monich3a170a11999-06-06 09:03:08 +0000139/***********************************************************************
140 * DIALOG_GetCharSize
141 *
Slava Monich3a170a11999-06-06 09:03:08 +0000142 * A convenient variant of DIALOG_GetCharSizeFromDC.
143 */
144static BOOL DIALOG_GetCharSize( HFONT hFont, SIZE * pSize )
145{
146 HDC hDC = GetDC(0);
147 BOOL Success = DIALOG_GetCharSizeFromDC( hDC, hFont, pSize );
148 ReleaseDC(0, hDC);
149 return Success;
150}
151
Slava Monich3a170a11999-06-06 09:03:08 +0000152/***********************************************************************
Alexandre Julliard0e607781993-11-03 19:23:37 +0000153 * DIALOG_Init
154 *
155 * Initialisation of the dialog manager.
156 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000157BOOL DIALOG_Init(void)
Alexandre Julliard0e607781993-11-03 19:23:37 +0000158{
Alexandre Julliard530ee841996-10-23 16:59:13 +0000159 HDC16 hdc;
Slava Monich3a170a11999-06-06 09:03:08 +0000160 SIZE size;
161
Alexandre Julliard0e607781993-11-03 19:23:37 +0000162 /* Calculate the dialog base units */
163
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000164 if (!(hdc = CreateDC16( "DISPLAY", NULL, NULL, NULL ))) return FALSE;
Slava Monich3a170a11999-06-06 09:03:08 +0000165 if (!DIALOG_GetCharSizeFromDC( hdc, 0, &size )) return FALSE;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000166 DeleteDC( hdc );
Slava Monich3a170a11999-06-06 09:03:08 +0000167 xBaseUnit = size.cx;
168 yBaseUnit = size.cy;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +0000169
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000170 TRACE("base units = %d,%d\n", xBaseUnit, yBaseUnit );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000171 return TRUE;
172}
173
174
175/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000176 * DIALOG_GetControl16
Alexandre Julliard0e607781993-11-03 19:23:37 +0000177 *
178 * Return the class and text of the control pointed to by ptr,
Alexandre Julliard329f0681996-04-14 13:21:20 +0000179 * fill the header structure and return a pointer to the next control.
Alexandre Julliard0e607781993-11-03 19:23:37 +0000180 */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000181static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000182{
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000183 static char buffer[10];
Alexandre Julliard03468f71998-02-15 19:40:49 +0000184 int int_id;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000185
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000186 info->x = GET_WORD(p); p += sizeof(WORD);
187 info->y = GET_WORD(p); p += sizeof(WORD);
188 info->cx = GET_WORD(p); p += sizeof(WORD);
189 info->cy = GET_WORD(p); p += sizeof(WORD);
190 info->id = GET_WORD(p); p += sizeof(WORD);
191 info->style = GET_DWORD(p); p += sizeof(DWORD);
192 info->exStyle = 0;
Alexandre Julliard7e50df31994-08-06 11:22:41 +0000193
Alexandre Julliard0e607781993-11-03 19:23:37 +0000194 if (*p & 0x80)
195 {
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000196 switch((BYTE)*p)
197 {
198 case 0x80: strcpy( buffer, "BUTTON" ); break;
199 case 0x81: strcpy( buffer, "EDIT" ); break;
200 case 0x82: strcpy( buffer, "STATIC" ); break;
201 case 0x83: strcpy( buffer, "LISTBOX" ); break;
202 case 0x84: strcpy( buffer, "SCROLLBAR" ); break;
203 case 0x85: strcpy( buffer, "COMBOBOX" ); break;
204 default: buffer[0] = '\0'; break;
205 }
206 info->className = buffer;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000207 p++;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000208 }
209 else
210 {
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000211 info->className = p;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000212 p += strlen(p) + 1;
213 }
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000214
Alexandre Julliard03468f71998-02-15 19:40:49 +0000215 int_id = ((BYTE)*p == 0xff);
216 if (int_id)
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000217 {
218 /* Integer id, not documented (?). Only works for SS_ICON controls */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000219 info->windowName = (LPCSTR)(UINT)GET_WORD(p+1);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000220 p += 3;
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000221 }
222 else
223 {
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000224 info->windowName = p;
225 p += strlen(p) + 1;
Alexandre Julliard7e50df31994-08-06 11:22:41 +0000226 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000227
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000228 info->data = (LPVOID)(*p ? p + 1 : NULL); /* FIXME: should be a segptr */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000229 p += *p + 1;
230
Alexandre Julliard03468f71998-02-15 19:40:49 +0000231 if(int_id)
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000232 TRACE(" %s %04x %d, %d, %d, %d, %d, %08lx, %08lx\n",
Alexandre Julliard03468f71998-02-15 19:40:49 +0000233 info->className, LOWORD(info->windowName),
234 info->id, info->x, info->y, info->cx, info->cy,
235 info->style, (DWORD)info->data);
236 else
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000237 TRACE(" %s '%s' %d, %d, %d, %d, %d, %08lx, %08lx\n",
Alexandre Julliard03468f71998-02-15 19:40:49 +0000238 info->className, info->windowName,
239 info->id, info->x, info->y, info->cx, info->cy,
240 info->style, (DWORD)info->data);
241
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000242 return p;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000243}
244
245
246/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000247 * DIALOG_GetControl32
Alexandre Julliard0e607781993-11-03 19:23:37 +0000248 *
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000249 * Return the class and text of the control pointed to by ptr,
250 * fill the header structure and return a pointer to the next control.
Alexandre Julliard0e607781993-11-03 19:23:37 +0000251 */
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000252static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000253 BOOL dialogEx )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000254{
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000255 if (dialogEx)
256 {
257 info->helpId = GET_DWORD(p); p += 2;
258 info->exStyle = GET_DWORD(p); p += 2;
259 info->style = GET_DWORD(p); p += 2;
260 }
261 else
262 {
263 info->helpId = 0;
264 info->style = GET_DWORD(p); p += 2;
265 info->exStyle = GET_DWORD(p); p += 2;
266 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000267 info->x = GET_WORD(p); p++;
268 info->y = GET_WORD(p); p++;
269 info->cx = GET_WORD(p); p++;
270 info->cy = GET_WORD(p); p++;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000271
272 if (dialogEx)
273 {
274 /* id is a DWORD for DIALOGEX */
275 info->id = GET_DWORD(p);
276 p += 2;
277 }
278 else
279 {
280 info->id = GET_WORD(p);
281 p++;
282 }
Alexandre Julliard0e607781993-11-03 19:23:37 +0000283
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000284 if (GET_WORD(p) == 0xffff)
Alexandre Julliard0e607781993-11-03 19:23:37 +0000285 {
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000286 static const WCHAR class_names[6][10] =
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000287 {
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000288 { 'B','u','t','t','o','n', }, /* 0x80 */
289 { 'E','d','i','t', }, /* 0x81 */
290 { 'S','t','a','t','i','c', }, /* 0x82 */
291 { 'L','i','s','t','B','o','x', }, /* 0x83 */
292 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
293 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
294 };
295 WORD id = GET_WORD(p+1);
296 if ((id >= 0x80) && (id <= 0x85))
297 info->className = (LPCSTR)class_names[id - 0x80];
298 else
299 {
300 info->className = NULL;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000301 ERR("Unknown built-in class id %04x\n", id );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000302 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000303 p += 2;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000304 }
305 else
306 {
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000307 info->className = (LPCSTR)p;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000308 p += lstrlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000309 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000310
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000311 if (GET_WORD(p) == 0xffff) /* Is it an integer id? */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000312 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000313 info->windowName = (LPCSTR)(UINT)GET_WORD(p + 1);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000314 p += 2;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000315 }
316 else
317 {
318 info->windowName = (LPCSTR)p;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000319 p += lstrlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000320 }
321
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000322 TRACE(" %s %s %d, %d, %d, %d, %d, %08lx, %08lx, %08lx\n",
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000323 debugstr_w( (LPCWSTR)info->className ),
324 debugres_w( (LPCWSTR)info->windowName ),
325 info->id, info->x, info->y, info->cx, info->cy,
326 info->style, info->exStyle, info->helpId );
327
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000328 if (GET_WORD(p))
329 {
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000330 if (TRACE_ON(dialog))
331 {
332 WORD i, count = GET_WORD(p) / sizeof(WORD);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000333 TRACE(" BEGIN\n");
334 TRACE(" ");
335 for (i = 0; i < count; i++) DPRINTF( "%04x,", GET_WORD(p+i+1) );
336 DPRINTF("\n");
337 TRACE(" END\n" );
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000338 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000339 info->data = (LPVOID)(p + 1);
340 p += GET_WORD(p) / sizeof(WORD);
341 }
342 else info->data = NULL;
343 p++;
344
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000345 /* Next control is on dword boundary */
346 return (const WORD *)((((int)p) + 3) & ~3);
347}
348
349
350/***********************************************************************
351 * DIALOG_CreateControls
352 *
353 * Create the control windows for a dialog.
354 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000355static BOOL DIALOG_CreateControls( WND *pWnd, LPCSTR template,
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000356 const DLG_TEMPLATE *dlgTemplate,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000357 HINSTANCE hInst, BOOL win32 )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000358{
359 DIALOGINFO *dlgInfo = (DIALOGINFO *)pWnd->wExtra;
360 DLG_CONTROL_INFO info;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000361 HWND hwndCtrl, hwndDefButton = 0;
362 INT items = dlgTemplate->nbItems;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000363
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000364 TRACE(" BEGIN\n" );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000365 while (items--)
366 {
367 if (!win32)
368 {
369 HINSTANCE16 instance;
370 template = DIALOG_GetControl16( template, &info );
371 if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000372 ((pWnd->dwStyle & DS_LOCALEDIT) != DS_LOCALEDIT))
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000373 {
374 if (!dlgInfo->hDialogHeap)
375 {
376 dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000);
377 if (!dlgInfo->hDialogHeap)
378 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000379 ERR("Insufficient memory to create heap for edit control\n" );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000380 continue;
381 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000382 LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000383 }
384 instance = dlgInfo->hDialogHeap;
385 }
386 else instance = (HINSTANCE16)hInst;
387
388 hwndCtrl = CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY,
389 info.className, info.windowName,
390 info.style | WS_CHILD,
Francis Beaudeteb13dd41999-09-03 15:14:27 +0000391 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
392 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
393 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
394 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000395 pWnd->hwndSelf, (HMENU16)info.id,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000396 instance, info.data );
397 }
398 else
399 {
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000400 template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info,
401 dlgTemplate->dialogEx );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000402 hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000403 (LPCWSTR)info.className,
404 (LPCWSTR)info.windowName,
405 info.style | WS_CHILD,
Francis Beaudeteb13dd41999-09-03 15:14:27 +0000406 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
407 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
408 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
409 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
Alexandre Julliarda3960291999-02-26 11:11:13 +0000410 pWnd->hwndSelf, (HMENU)info.id,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000411 hInst, info.data );
412 }
413 if (!hwndCtrl) return FALSE;
414
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000415 /* Send initialisation messages to the control */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000416 if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT,
417 (WPARAM)dlgInfo->hUserFont, 0 );
418 if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000419 {
420 /* If there's already a default push-button, set it back */
421 /* to normal and use this one instead. */
422 if (hwndDefButton)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000423 SendMessageA( hwndDefButton, BM_SETSTYLE,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000424 BS_PUSHBUTTON,FALSE );
425 hwndDefButton = hwndCtrl;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000426 dlgInfo->idResult = GetWindowWord( hwndCtrl, GWW_ID );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000427 }
428 }
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000429 TRACE(" END\n" );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000430 return TRUE;
431}
432
433
434/***********************************************************************
435 * DIALOG_ParseTemplate16
436 *
437 * Fill a DLG_TEMPLATE structure from the dialog template, and return
438 * a pointer to the first control.
439 */
440static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result )
441{
442 result->style = GET_DWORD(p); p += sizeof(DWORD);
443 result->exStyle = 0;
Pavel Roskin4b5f8761999-06-12 08:11:32 +0000444 result->nbItems = (unsigned char) *p++;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000445 result->x = GET_WORD(p); p += sizeof(WORD);
446 result->y = GET_WORD(p); p += sizeof(WORD);
447 result->cx = GET_WORD(p); p += sizeof(WORD);
448 result->cy = GET_WORD(p); p += sizeof(WORD);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000449 TRACE("DIALOG %d, %d, %d, %d\n",
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000450 result->x, result->y, result->cx, result->cy );
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000451 TRACE(" STYLE %08lx\n", result->style );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000452
453 /* Get the menu name */
454
455 switch( (BYTE)*p )
456 {
457 case 0:
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000458 result->menuName = 0;
459 p++;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000460 break;
461 case 0xff:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000462 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000463 p += 3;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000464 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000465 break;
466 default:
467 result->menuName = p;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000468 TRACE(" MENU '%s'\n", p );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000469 p += strlen(p) + 1;
470 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000471 }
Alexandre Julliard0e607781993-11-03 19:23:37 +0000472
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000473 /* Get the class name */
474
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000475 if (*p)
476 {
477 result->className = p;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000478 TRACE(" CLASS '%s'\n", result->className );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000479 }
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000480 else result->className = DIALOG_CLASS_ATOM;
481 p += strlen(p) + 1;
482
483 /* Get the window caption */
484
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000485 result->caption = p;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000486 p += strlen(p) + 1;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000487 TRACE(" CAPTION '%s'\n", result->caption );
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000488
489 /* Get the font name */
490
Alexandre Julliard329f0681996-04-14 13:21:20 +0000491 if (result->style & DS_SETFONT)
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000492 {
Alexandre Julliard329f0681996-04-14 13:21:20 +0000493 result->pointSize = GET_WORD(p);
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000494 p += sizeof(WORD);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000495 result->faceName = p;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000496 p += strlen(p) + 1;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000497 TRACE(" FONT %d,'%s'\n",
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000498 result->pointSize, result->faceName );
499 }
500 return p;
501}
502
503
504/***********************************************************************
505 * DIALOG_ParseTemplate32
506 *
507 * Fill a DLG_TEMPLATE structure from the dialog template, and return
508 * a pointer to the first control.
509 */
510static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result )
511{
512 const WORD *p = (const WORD *)template;
513
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000514 result->style = GET_DWORD(p); p += 2;
515 if (result->style == 0xffff0001) /* DIALOGEX resource */
516 {
517 result->dialogEx = TRUE;
518 result->helpId = GET_DWORD(p); p += 2;
519 result->exStyle = GET_DWORD(p); p += 2;
520 result->style = GET_DWORD(p); p += 2;
521 }
522 else
523 {
524 result->dialogEx = FALSE;
525 result->helpId = 0;
526 result->exStyle = GET_DWORD(p); p += 2;
527 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000528 result->nbItems = GET_WORD(p); p++;
529 result->x = GET_WORD(p); p++;
530 result->y = GET_WORD(p); p++;
531 result->cx = GET_WORD(p); p++;
532 result->cy = GET_WORD(p); p++;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000533 TRACE("DIALOG%s %d, %d, %d, %d, %ld\n",
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000534 result->dialogEx ? "EX" : "", result->x, result->y,
535 result->cx, result->cy, result->helpId );
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000536 TRACE(" STYLE 0x%08lx\n", result->style );
537 TRACE(" EXSTYLE 0x%08lx\n", result->exStyle );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000538
539 /* Get the menu name */
540
541 switch(GET_WORD(p))
542 {
543 case 0x0000:
544 result->menuName = NULL;
545 p++;
546 break;
547 case 0xffff:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000548 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000549 p += 2;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000550 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000551 break;
552 default:
553 result->menuName = (LPCSTR)p;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000554 TRACE(" MENU %s\n", debugstr_w( (LPCWSTR)p ));
Alexandre Julliarda3960291999-02-26 11:11:13 +0000555 p += lstrlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000556 break;
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000557 }
558
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000559 /* Get the class name */
Alexandre Julliard0e607781993-11-03 19:23:37 +0000560
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000561 switch(GET_WORD(p))
562 {
563 case 0x0000:
564 result->className = DIALOG_CLASS_ATOM;
565 p++;
566 break;
567 case 0xffff:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000568 result->className = (LPCSTR)(UINT)GET_WORD( p + 1 );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000569 p += 2;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000570 TRACE(" CLASS %04x\n", LOWORD(result->className) );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000571 break;
572 default:
573 result->className = (LPCSTR)p;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000574 TRACE(" CLASS %s\n", debugstr_w( (LPCWSTR)p ));
Alexandre Julliarda3960291999-02-26 11:11:13 +0000575 p += lstrlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000576 break;
577 }
Alexandre Julliard0e607781993-11-03 19:23:37 +0000578
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000579 /* Get the window caption */
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000580
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000581 result->caption = (LPCSTR)p;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000582 p += lstrlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000583 TRACE(" CAPTION %s\n", debugstr_w( (LPCWSTR)result->caption ) );
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000584
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000585 /* Get the font name */
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000586
Alexandre Julliard329f0681996-04-14 13:21:20 +0000587 if (result->style & DS_SETFONT)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000588 {
589 result->pointSize = GET_WORD(p);
590 p++;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000591 if (result->dialogEx)
592 {
593 result->weight = GET_WORD(p); p++;
594 result->italic = LOBYTE(GET_WORD(p)); p++;
595 }
596 else
597 {
598 result->weight = FW_DONTCARE;
599 result->italic = FALSE;
600 }
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000601 result->faceName = (LPCSTR)p;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000602 p += lstrlenW( (LPCWSTR)p ) + 1;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000603 TRACE(" FONT %d, %s, %d, %s\n",
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000604 result->pointSize, debugstr_w( (LPCWSTR)result->faceName ),
605 result->weight, result->italic ? "TRUE" : "FALSE" );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000606 }
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000607
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000608 /* First control is on dword boundary */
609 return (LPCSTR)((((int)p) + 3) & ~3);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000610}
Alexandre Julliard0e607781993-11-03 19:23:37 +0000611
612
613/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000614 * DIALOG_CreateIndirect
Alexandre Julliard0e607781993-11-03 19:23:37 +0000615 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000616HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
617 BOOL win32Template, HWND owner,
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000618 DLGPROC16 dlgProc, LPARAM param,
619 WINDOWPROCTYPE procType )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000620{
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000621 HMENU16 hMenu = 0;
622 HFONT16 hFont = 0;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000623 HWND hwnd;
624 RECT rect;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000625 WND * wndPtr;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000626 DLG_TEMPLATE template;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000627 DIALOGINFO * dlgInfo;
628 WORD xUnit = xBaseUnit;
629 WORD yUnit = yBaseUnit;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000630
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000631 /* Parse dialog template */
632
633 if (!dlgTemplate) return 0;
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000634 if (win32Template)
Alexandre Julliard3051b641996-07-05 17:14:13 +0000635 dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template );
636 else
637 dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000638
639 /* Load menu */
640
Alexandre Julliard491502b1997-11-01 19:08:16 +0000641 if (template.menuName)
642 {
643 if (!win32Template)
Alexandre Julliard77b99181997-09-14 17:17:23 +0000644 {
645 LPSTR str = SEGPTR_STRDUP( template.menuName );
646 hMenu = LoadMenu16( hInst, SEGPTR_GET(str) );
647 SEGPTR_FREE( str );
Alexandre Julliard491502b1997-11-01 19:08:16 +0000648 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000649 else hMenu = LoadMenuW( hInst, (LPCWSTR)template.menuName );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000650 }
Alexandre Julliard0e607781993-11-03 19:23:37 +0000651
652 /* Create custom font if needed */
653
Alexandre Julliard329f0681996-04-14 13:21:20 +0000654 if (template.style & DS_SETFONT)
Alexandre Julliard0e607781993-11-03 19:23:37 +0000655 {
Richard Cohen0ded0fe1999-09-05 12:25:33 +0000656 /* The font height must be negative as it is a point size */
657 /* and must be converted to pixels first */
Alexandre Julliard3ed37e01994-11-07 18:20:42 +0000658 /* (see CreateFont() documentation in the Windows SDK). */
Richard Cohen0ded0fe1999-09-05 12:25:33 +0000659 HDC dc = GetDC(0);
660 int pixels = template.pointSize * GetDeviceCaps(dc , LOGPIXELSY)/72;
661 ReleaseDC(0, dc);
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000662
Alexandre Julliard3db94ef1997-09-28 17:43:24 +0000663 if (win32Template)
Richard Cohen0ded0fe1999-09-05 12:25:33 +0000664 hFont = CreateFontW( -pixels, 0, 0, 0, template.weight,
665 template.italic, FALSE, FALSE,
666 DEFAULT_CHARSET, 0, 0,
667 PROOF_QUALITY, FF_DONTCARE,
668 (LPCWSTR)template.faceName );
Alexandre Julliard3db94ef1997-09-28 17:43:24 +0000669 else
Richard Cohen0ded0fe1999-09-05 12:25:33 +0000670 hFont = CreateFont16( -pixels, 0, 0, 0, FW_DONTCARE,
671 FALSE, FALSE, FALSE,
672 DEFAULT_CHARSET, 0, 0,
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000673 PROOF_QUALITY, FF_DONTCARE,
674 template.faceName );
Slava Monich3a170a11999-06-06 09:03:08 +0000675 if (hFont)
676 {
677 SIZE charSize;
678 DIALOG_GetCharSize(hFont,&charSize);
679 xUnit = charSize.cx;
680 yUnit = charSize.cy;
681 }
Richard Cohen0ded0fe1999-09-05 12:25:33 +0000682 TRACE("units = %d,%d\n", xUnit, yUnit );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000683 }
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000684
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000685 /* Create dialog main window */
Alexandre Julliard0e607781993-11-03 19:23:37 +0000686
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000687 rect.left = rect.top = 0;
Francis Beaudeteb13dd41999-09-03 15:14:27 +0000688 rect.right = MulDiv(template.cx, xUnit, 4);
689 rect.bottom = MulDiv(template.cy, yUnit, 8);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000690 if (template.style & DS_MODALFRAME)
691 template.exStyle |= WS_EX_DLGMODALFRAME;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000692 AdjustWindowRectEx( &rect, template.style,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000693 hMenu ? TRUE : FALSE , template.exStyle );
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000694 rect.right -= rect.left;
695 rect.bottom -= rect.top;
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000696
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000697 if ((INT16)template.x == CW_USEDEFAULT16)
Alexandre Julliardca22b331996-07-12 19:02:39 +0000698 {
Ulrich Weigandf03c9361999-07-10 13:08:50 +0000699 rect.left = rect.top = win32Template? CW_USEDEFAULT : CW_USEDEFAULT16;
Alexandre Julliardca22b331996-07-12 19:02:39 +0000700 }
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000701 else
702 {
Dave Picklesfcc9d131998-10-10 15:52:46 +0000703 if (template.style & DS_CENTER)
704 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000705 rect.left = (GetSystemMetrics(SM_CXSCREEN) - rect.right) / 2;
706 rect.top = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / 2;
Dave Picklesfcc9d131998-10-10 15:52:46 +0000707 }
708 else
709 {
Francis Beaudeteb13dd41999-09-03 15:14:27 +0000710 rect.left += MulDiv(template.x, xUnit, 4);
711 rect.top += MulDiv(template.y, yUnit, 8);
Dave Picklesfcc9d131998-10-10 15:52:46 +0000712 }
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000713 if ( !(template.style & WS_CHILD) )
714 {
715 INT16 dX, dY;
716
717 if( !(template.style & DS_ABSALIGN) )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000718 ClientToScreen( owner, (POINT *)&rect );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000719
720 /* try to fit it into the desktop */
721
Marcus Meissnerddca3151999-05-22 11:33:23 +0000722 if( (dX = rect.left + rect.right + GetSystemMetrics(SM_CXDLGFRAME)
723 - GetSystemMetrics(SM_CXSCREEN)) > 0 ) rect.left -= dX;
724 if( (dY = rect.top + rect.bottom + GetSystemMetrics(SM_CYDLGFRAME)
725 - GetSystemMetrics(SM_CYSCREEN)) > 0 ) rect.top -= dY;
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000726 if( rect.left < 0 ) rect.left = 0;
727 if( rect.top < 0 ) rect.top = 0;
728 }
Alexandre Julliardff8331e1995-09-18 11:19:54 +0000729 }
730
Ulrich Weigandf03c9361999-07-10 13:08:50 +0000731 if (!win32Template)
Alexandre Julliard3db94ef1997-09-28 17:43:24 +0000732 hwnd = CreateWindowEx16(template.exStyle, template.className,
733 template.caption, template.style & ~WS_VISIBLE,
734 rect.left, rect.top, rect.right, rect.bottom,
735 owner, hMenu, hInst, NULL );
736 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000737 hwnd = CreateWindowExW(template.exStyle, (LPCWSTR)template.className,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000738 (LPCWSTR)template.caption,
739 template.style & ~WS_VISIBLE,
740 rect.left, rect.top, rect.right, rect.bottom,
741 owner, hMenu, hInst, NULL );
Alexandre Julliard3db94ef1997-09-28 17:43:24 +0000742
Alexandre Julliard0e607781993-11-03 19:23:37 +0000743 if (!hwnd)
744 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000745 if (hFont) DeleteObject( hFont );
746 if (hMenu) DestroyMenu( hMenu );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000747 return 0;
748 }
Alexandre Julliard902da691995-11-05 14:39:02 +0000749 wndPtr = WIN_FindWndPtr( hwnd );
Alexandre Julliard3051b641996-07-05 17:14:13 +0000750 wndPtr->flags |= WIN_ISDIALOG;
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000751 wndPtr->helpContext = template.helpId;
Alexandre Julliard902da691995-11-05 14:39:02 +0000752
Alexandre Julliard0e607781993-11-03 19:23:37 +0000753 /* Initialise dialog extra data */
754
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000755 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
Marcus Meissner03479f81999-01-28 10:06:38 +0000756 WINPROC_SetProc( &dlgInfo->dlgProc, (WNDPROC16)dlgProc, procType, WIN_PROC_WINDOW );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000757 dlgInfo->hUserFont = hFont;
758 dlgInfo->hMenu = hMenu;
759 dlgInfo->xBaseUnit = xUnit;
760 dlgInfo->yBaseUnit = yUnit;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000761 dlgInfo->msgResult = 0;
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +0000762 dlgInfo->idResult = 0;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000763 dlgInfo->flags = 0;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000764 dlgInfo->hDialogHeap = 0;
765
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000766 if (dlgInfo->hUserFont)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000767 SendMessageA( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000768
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000769 /* Create controls */
770
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000771 if (DIALOG_CreateControls( wndPtr, dlgTemplate, &template,
772 hInst, win32Template ))
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000773 {
Adrian Thurston00442ba1999-10-23 16:48:05 +0000774 HWND hwndPreInitFocus;
775
776 /* Send initialisation messages and set focus */
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000777
Alexandre Julliarda3960291999-02-26 11:11:13 +0000778 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
Alexandre Julliard77b99181997-09-14 17:17:23 +0000779
Adrian Thurston00442ba1999-10-23 16:48:05 +0000780 hwndPreInitFocus = GetFocus();
Alexandre Julliarda3960291999-02-26 11:11:13 +0000781 if (SendMessageA( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ))
782 SetFocus( dlgInfo->hwndFocus );
Adrian Thurston00442ba1999-10-23 16:48:05 +0000783 else
784 {
785 /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
786 but the focus has not changed, set the focus where we expect it. */
787 if ( GetFocus() == hwndPreInitFocus )
788 SetFocus( dlgInfo->hwndFocus );
789 }
Alexandre Julliard77b99181997-09-14 17:17:23 +0000790
791 if (template.style & WS_VISIBLE && !(wndPtr->dwStyle & WS_VISIBLE))
792 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000793 ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
794 UpdateWindow( hwnd );
Alexandre Julliard77b99181997-09-14 17:17:23 +0000795 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000796 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000797 return hwnd;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000798 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000799 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000800 if( IsWindow(hwnd) ) DestroyWindow( hwnd );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000801 return 0;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000802}
803
804
805/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000806 * CreateDialog16 (USER.89)
807 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000808HWND16 WINAPI CreateDialog16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
809 HWND16 owner, DLGPROC16 dlgProc )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000810{
811 return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
812}
813
814
815/***********************************************************************
816 * CreateDialogParam16 (USER.241)
817 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000818HWND16 WINAPI CreateDialogParam16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
819 HWND16 owner, DLGPROC16 dlgProc,
820 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000821{
822 HWND16 hwnd = 0;
Alexandre Julliard8cc3a5e1996-08-11 15:49:51 +0000823 HRSRC16 hRsrc;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000824 HGLOBAL16 hmem;
825 LPCVOID data;
826
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000827 TRACE("%04x,%08lx,%04x,%08lx,%ld\n",
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000828 hInst, (DWORD)dlgTemplate, owner, (DWORD)dlgProc, param );
829
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000830 if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOG16 ))) return 0;
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000831 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
832 if (!(data = LockResource16( hmem ))) hwnd = 0;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000833 else hwnd = CreateDialogIndirectParam16( hInst, data, owner,
834 dlgProc, param );
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000835 FreeResource16( hmem );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000836 return hwnd;
837}
838
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000839/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000840 * CreateDialogParam32A (USER32.73)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000841 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000842HWND WINAPI CreateDialogParamA( HINSTANCE hInst, LPCSTR name,
843 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000844 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000845{
Ove Kaaven483c5481999-07-18 15:29:09 +0000846 HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
847 if (!hrsrc) return 0;
848 return CreateDialogIndirectParamA( hInst,
849 (LPVOID)LoadResource(hInst, hrsrc),
850 owner, dlgProc, param );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000851}
852
853
854/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000855 * CreateDialogParam32W (USER32.74)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000856 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000857HWND WINAPI CreateDialogParamW( HINSTANCE hInst, LPCWSTR name,
858 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000859 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000860{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000861 HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000862 if (!hrsrc) return 0;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000863 return CreateDialogIndirectParamW( hInst,
864 (LPVOID)LoadResource(hInst, hrsrc),
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000865 owner, dlgProc, param );
866}
867
868
869/***********************************************************************
870 * CreateDialogIndirect16 (USER.219)
871 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000872HWND16 WINAPI CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
873 HWND16 owner, DLGPROC16 dlgProc )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000874{
875 return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
876}
877
878
879/***********************************************************************
880 * CreateDialogIndirectParam16 (USER.242)
881 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000882HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst,
883 LPCVOID dlgTemplate,
884 HWND16 owner, DLGPROC16 dlgProc,
885 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000886{
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000887 return DIALOG_CreateIndirect( hInst, dlgTemplate, FALSE, owner,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000888 dlgProc, param, WIN_PROC_16 );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000889}
890
891
892/***********************************************************************
893 * CreateDialogIndirectParam32A (USER32.69)
894 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000895HWND WINAPI CreateDialogIndirectParamA( HINSTANCE hInst,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000896 LPCVOID dlgTemplate,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000897 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000898 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000899{
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000900 return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000901 (DLGPROC16)dlgProc, param, WIN_PROC_32A );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000902}
903
Juergen Schmied84b358d1998-10-11 15:38:35 +0000904/***********************************************************************
905 * CreateDialogIndirectParam32AorW (USER32.71)
906 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000907HWND WINAPI CreateDialogIndirectParamAorW( HINSTANCE hInst,
Juergen Schmied84b358d1998-10-11 15:38:35 +0000908 LPCVOID dlgTemplate,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000909 HWND owner, DLGPROC dlgProc,
Juergen Schmied84b358d1998-10-11 15:38:35 +0000910 LPARAM param )
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000911{ FIXME("assume WIN_PROC_32W\n");
Juergen Schmied84b358d1998-10-11 15:38:35 +0000912 return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
913 (DLGPROC16)dlgProc, param, WIN_PROC_32W );
914}
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000915
916/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000917 * CreateDialogIndirectParam32W (USER32.72)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000918 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000919HWND WINAPI CreateDialogIndirectParamW( HINSTANCE hInst,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000920 LPCVOID dlgTemplate,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000921 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000922 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000923{
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000924 return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000925 (DLGPROC16)dlgProc, param, WIN_PROC_32W );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000926}
927
928
929/***********************************************************************
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000930 * DIALOG_DoDialogBox
Alexandre Julliard0e607781993-11-03 19:23:37 +0000931 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000932INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
Alexandre Julliard0e607781993-11-03 19:23:37 +0000933{
Alexandre Julliard0e607781993-11-03 19:23:37 +0000934 WND * wndPtr;
935 DIALOGINFO * dlgInfo;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000936 MSG msg;
937 INT retval;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000938
Alexandre Julliardaca05781994-10-17 18:12:41 +0000939 /* Owner must be a top-level window */
Alexandre Julliarde2991ea1995-07-29 13:09:43 +0000940 owner = WIN_GetTopParent( owner );
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000941 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return -1;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000942 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000943
Gerard Patel902f9c61999-02-14 11:22:03 +0000944 if (!dlgInfo->flags & DF_END) /* was EndDialog called in WM_INITDIALOG ? */
Alexandre Julliard0e607781993-11-03 19:23:37 +0000945 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000946 EnableWindow( owner, FALSE );
947 ShowWindow( hwnd, SW_SHOW );
Ulrich Weigand2faf2cf1999-12-10 03:47:13 +0000948 while (MSG_InternalGetMessage(QMSG_WIN32A, &msg, hwnd, owner, MSGF_DIALOGBOX,
Francis Beaudet7ed1af31999-08-15 16:58:03 +0000949 PM_REMOVE, !(wndPtr->dwStyle & DS_NOIDLEMSG), NULL ))
Gerard Patel902f9c61999-02-14 11:22:03 +0000950 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000951 if (!IsDialogMessageA( hwnd, &msg))
Gerard Patel902f9c61999-02-14 11:22:03 +0000952 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000953 TranslateMessage( &msg );
954 DispatchMessageA( &msg );
Gerard Patel902f9c61999-02-14 11:22:03 +0000955 }
956 if (dlgInfo->flags & DF_END) break;
957 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000958 EnableWindow( owner, TRUE );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000959 }
Gerard Patel902f9c61999-02-14 11:22:03 +0000960 retval = dlgInfo->idResult;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000961 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000962 DestroyWindow( hwnd );
Alexandre Julliard0e607781993-11-03 19:23:37 +0000963 return retval;
964}
965
966
967/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000968 * DialogBox16 (USER.87)
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000969 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000970INT16 WINAPI DialogBox16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
971 HWND16 owner, DLGPROC16 dlgProc )
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000972{
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000973 return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000974}
975
976
977/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000978 * DialogBoxParam16 (USER.239)
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000979 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000980INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, SEGPTR template,
981 HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000982{
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000983 HWND16 hwnd = CreateDialogParam16( hInst, template, owner, dlgProc, param);
984 if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner );
985 return -1;
986}
987
988
989/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000990 * DialogBoxParam32A (USER32.139)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000991 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000992INT WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name,
993 HWND owner, DLGPROC dlgProc, LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000994{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000995 HWND hwnd = CreateDialogParamA( hInst, name, owner, dlgProc, param );
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +0000996 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
Alexandre Julliarde399fc31993-11-24 17:08:56 +0000997 return -1;
998}
999
1000
1001/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001002 * DialogBoxParam32W (USER32.140)
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001003 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001004INT WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
1005 HWND owner, DLGPROC dlgProc, LPARAM param )
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001006{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001007 HWND hwnd = CreateDialogParamW( hInst, name, owner, dlgProc, param );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001008 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1009 return -1;
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001010}
1011
1012
1013/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001014 * DialogBoxIndirect16 (USER.218)
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001015 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001016INT16 WINAPI DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1017 HWND16 owner, DLGPROC16 dlgProc )
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001018{
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001019 return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
1020}
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001021
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001022
1023/***********************************************************************
1024 * DialogBoxIndirectParam16 (USER.240)
1025 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001026INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1027 HWND16 owner, DLGPROC16 dlgProc,
1028 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001029{
1030 HWND16 hwnd;
1031 LPCVOID ptr;
1032
1033 if (!(ptr = GlobalLock16( dlgTemplate ))) return -1;
1034 hwnd = CreateDialogIndirectParam16( hInst, ptr, owner, dlgProc, param );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001035 GlobalUnlock16( dlgTemplate );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001036 if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner );
1037 return -1;
1038}
1039
1040
1041/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001042 * DialogBoxIndirectParam32A (USER32.136)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001043 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001044INT WINAPI DialogBoxIndirectParamA(HINSTANCE hInstance, LPCVOID template,
1045 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001046 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001047{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001048 HWND hwnd = CreateDialogIndirectParamA( hInstance, template,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001049 owner, dlgProc, param );
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +00001050 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
Alexandre Julliarde399fc31993-11-24 17:08:56 +00001051 return -1;
1052}
1053
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00001054
Alexandre Julliard3ed37e01994-11-07 18:20:42 +00001055/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001056 * DialogBoxIndirectParam32W (USER32.138)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001057 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001058INT WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCVOID template,
1059 HWND owner, DLGPROC dlgProc,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001060 LPARAM param )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001061{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001062 HWND hwnd = CreateDialogIndirectParamW( hInstance, template,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001063 owner, dlgProc, param );
1064 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1065 return -1;
1066}
1067
Juergen Schmieda4d7ca02000-01-04 00:29:44 +00001068/***********************************************************************
1069 * DialogBoxIndirectParamAorW (USER32.138)
1070 */
1071INT WINAPI DialogBoxIndirectParamAorW(HINSTANCE hInstance, LPCVOID template,
1072 HWND owner, DLGPROC dlgProc,
1073 LPARAM param, DWORD x )
1074{
1075 HWND hwnd;
1076 FIXME("0x%08x %p 0x%08x %p 0x%08lx 0x%08lx\n",
1077 hInstance, template, owner, dlgProc, param, x);
1078 hwnd = CreateDialogIndirectParamW( hInstance, template,
1079 owner, dlgProc, param );
1080 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1081 return -1;
1082}
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001083
1084/***********************************************************************
Andreas Mohr01f84261999-03-19 16:49:30 +00001085 * EndDialog16 (USER.88)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001086 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001087BOOL16 WINAPI EndDialog16( HWND16 hwnd, INT16 retval )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001088{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001089 return EndDialog( hwnd, retval );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001090}
1091
1092
1093/***********************************************************************
Andreas Mohr01f84261999-03-19 16:49:30 +00001094 * EndDialog32 (USER32.173)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001095 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001096BOOL WINAPI EndDialog( HWND hwnd, INT retval )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001097{
1098 WND * wndPtr = WIN_FindWndPtr( hwnd );
1099 DIALOGINFO * dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
Abey George3336f481999-10-13 15:45:23 +00001100 HWND hOwner = 0;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001101
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001102 TRACE("%04x %d\n", hwnd, retval );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001103
1104 if( dlgInfo )
1105 {
1106 dlgInfo->idResult = retval;
1107 dlgInfo->flags |= DF_END;
1108 }
Andreas Mohr01f84261999-03-19 16:49:30 +00001109
Abey George3336f481999-10-13 15:45:23 +00001110 if(wndPtr->owner)
1111 hOwner = WIN_GetTopParent( wndPtr->owner->hwndSelf );
1112
1113 /* Enable the owner first */
1114 if (hOwner && !IsWindowEnabled(hOwner))
1115 EnableWindow( hOwner, TRUE );
1116
1117 /* Windows sets the focus to the dialog itself in EndDialog */
Abey George15c58c41999-08-07 14:10:04 +00001118
1119 if (IsChild(hwnd, GetFocus()))
1120 SetFocus(wndPtr->hwndSelf);
1121
Abey George3336f481999-10-13 15:45:23 +00001122 /* Don't have to send a ShowWindow(SW_HIDE), just do
1123 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
Andreas Mohr01f84261999-03-19 16:49:30 +00001124
Abey George3336f481999-10-13 15:45:23 +00001125 SetWindowPos(hwnd, (HWND)0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
1126 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW);
Stephane Lussier18613bb1999-07-24 10:18:02 +00001127
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001128 WIN_ReleaseWndPtr(wndPtr);
Abey George3336f481999-10-13 15:45:23 +00001129
Alexandre Julliard0c126c71996-02-18 18:44:41 +00001130 return TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001131}
1132
1133
1134/***********************************************************************
Norman Stevensa83d0651998-10-12 07:25:35 +00001135 * DIALOG_IsAccelerator
1136 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001137static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM vKey )
Norman Stevensa83d0651998-10-12 07:25:35 +00001138{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001139 HWND hwndControl = hwnd;
1140 HWND hwndNext;
Norman Stevensa83d0651998-10-12 07:25:35 +00001141 WND *wndPtr;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001142 BOOL RetVal = FALSE;
1143 INT dlgCode;
Norman Stevensa83d0651998-10-12 07:25:35 +00001144
Norman Stevensa83d0651998-10-12 07:25:35 +00001145 do
1146 {
1147 wndPtr = WIN_FindWndPtr( hwndControl );
Francis Beaudetf91e6d01999-03-25 13:22:42 +00001148 if ( (wndPtr != NULL) &&
1149 ((wndPtr->dwStyle & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE) )
Norman Stevensa83d0651998-10-12 07:25:35 +00001150 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001151 dlgCode = SendMessageA( hwndControl, WM_GETDLGCODE, 0, 0 );
Francis Beaudetf91e6d01999-03-25 13:22:42 +00001152 if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) &&
1153 (wndPtr->text!=NULL))
Norman Stevensa83d0651998-10-12 07:25:35 +00001154 {
1155 /* find the accelerator key */
1156 LPSTR p = wndPtr->text - 2;
1157 do
1158 {
1159 p = strchr( p + 2, '&' );
1160 }
1161 while (p != NULL && p[1] == '&');
1162
1163 /* and check if it's the one we're looking for */
1164 if (p != NULL && toupper( p[1] ) == toupper( vKey ) )
1165 {
1166 if ((dlgCode & DLGC_STATIC) ||
1167 (wndPtr->dwStyle & 0x0f) == BS_GROUPBOX )
1168 {
1169 /* set focus to the control */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001170 SendMessageA( hwndDlg, WM_NEXTDLGCTL,
Norman Stevensa83d0651998-10-12 07:25:35 +00001171 hwndControl, 1);
1172 /* and bump it on to next */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001173 SendMessageA( hwndDlg, WM_NEXTDLGCTL, 0, 0);
Norman Stevensa83d0651998-10-12 07:25:35 +00001174 }
Dmitry Timoshkovb7bb42d1999-12-25 22:52:44 +00001175 else if (dlgCode & DLGC_BUTTON)
1176 {
Dmitry Timoshkov6fb62f52000-01-29 22:09:40 +00001177 /* send BM_CLICK message to the control */
1178 SendMessageA( hwndControl, BM_CLICK, 0, 0 );
Dmitry Timoshkovb7bb42d1999-12-25 22:52:44 +00001179 }
Dmitry Timoshkovf92a7771999-12-05 23:51:15 +00001180
Norman Stevensa83d0651998-10-12 07:25:35 +00001181 RetVal = TRUE;
Abey George15c58c41999-08-07 14:10:04 +00001182 WIN_ReleaseWndPtr(wndPtr);
Norman Stevensa83d0651998-10-12 07:25:35 +00001183 break;
1184 }
1185 }
Norman Stevens460881c1999-02-28 09:59:32 +00001186 hwndNext = GetWindow( hwndControl, GW_CHILD );
Norman Stevensa83d0651998-10-12 07:25:35 +00001187 }
Norman Stevens460881c1999-02-28 09:59:32 +00001188 else
1189 {
1190 hwndNext = 0;
1191 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001192 WIN_ReleaseWndPtr(wndPtr);
NF Stevense1f67b91998-11-08 16:44:41 +00001193 if (!hwndNext)
1194 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001195 hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
NF Stevense1f67b91998-11-08 16:44:41 +00001196 }
Marcus Meissner6f7797b1999-09-03 16:39:36 +00001197 while (!hwndNext && hwndControl)
NF Stevense1f67b91998-11-08 16:44:41 +00001198 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001199 hwndControl = GetParent( hwndControl );
NF Stevense1f67b91998-11-08 16:44:41 +00001200 if (hwndControl == hwndDlg)
1201 {
Abey George15c58c41999-08-07 14:10:04 +00001202 if(hwnd==hwndDlg){ /* prevent endless loop */
1203 hwndNext=hwnd;
1204 break;
1205 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00001206 hwndNext = GetWindow( hwndDlg, GW_CHILD );
NF Stevense1f67b91998-11-08 16:44:41 +00001207 }
1208 else
1209 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001210 hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
NF Stevense1f67b91998-11-08 16:44:41 +00001211 }
1212 }
1213 hwndControl = hwndNext;
Norman Stevensa83d0651998-10-12 07:25:35 +00001214 }
Marcus Meissner6f7797b1999-09-03 16:39:36 +00001215 while (hwndControl && (hwndControl != hwnd));
Dmitry Timoshkovf92a7771999-12-05 23:51:15 +00001216
Norman Stevensa83d0651998-10-12 07:25:35 +00001217 return RetVal;
1218}
1219
1220
1221/***********************************************************************
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001222 * DIALOG_IsDialogMessage
Alexandre Julliard0e607781993-11-03 19:23:37 +00001223 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001224static BOOL DIALOG_IsDialogMessage( HWND hwnd, HWND hwndDlg,
1225 UINT message, WPARAM wParam,
1226 LPARAM lParam, BOOL *translate,
1227 BOOL *dispatch, INT dlgCode )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001228{
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001229 *translate = *dispatch = FALSE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001230
Alexandre Julliard641ee761997-08-04 16:34:36 +00001231 if (message == WM_PAINT)
1232 {
1233 /* Apparently, we have to handle this one as well */
1234 *dispatch = TRUE;
1235 return TRUE;
1236 }
1237
Alexandre Julliardaca05781994-10-17 18:12:41 +00001238 /* Only the key messages get special processing */
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001239 if ((message != WM_KEYDOWN) &&
1240 (message != WM_SYSCHAR) &&
1241 (message != WM_CHAR))
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00001242 return FALSE;
1243
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00001244 if (dlgCode & DLGC_WANTMESSAGE)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001245 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +00001246 *translate = *dispatch = TRUE;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00001247 return TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001248 }
Alexandre Julliardaca05781994-10-17 18:12:41 +00001249
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001250 switch(message)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001251 {
Alexandre Julliardaca05781994-10-17 18:12:41 +00001252 case WM_KEYDOWN:
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001253 switch(wParam)
Alexandre Julliardaca05781994-10-17 18:12:41 +00001254 {
1255 case VK_TAB:
1256 if (!(dlgCode & DLGC_WANTTAB))
1257 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001258 SendMessageA( hwndDlg, WM_NEXTDLGCTL,
1259 (GetKeyState(VK_SHIFT) & 0x8000), 0 );
Alexandre Julliardaca05781994-10-17 18:12:41 +00001260 return TRUE;
1261 }
1262 break;
1263
1264 case VK_RIGHT:
1265 case VK_DOWN:
Alexandre Julliardaca05781994-10-17 18:12:41 +00001266 case VK_LEFT:
1267 case VK_UP:
1268 if (!(dlgCode & DLGC_WANTARROWS))
1269 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001270 BOOL fPrevious = (wParam == VK_LEFT || wParam == VK_UP);
1271 HWND hwndNext =
1272 GetNextDlgGroupItem (hwndDlg, GetFocus(), fPrevious );
1273 SendMessageA( hwndDlg, WM_NEXTDLGCTL, hwndNext, 1 );
Alexandre Julliardaca05781994-10-17 18:12:41 +00001274 return TRUE;
1275 }
1276 break;
1277
1278 case VK_ESCAPE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001279 SendMessageA( hwndDlg, WM_COMMAND, IDCANCEL,
1280 (LPARAM)GetDlgItem( hwndDlg, IDCANCEL ) );
Norman Stevensa83d0651998-10-12 07:25:35 +00001281 return TRUE;
Alexandre Julliardaca05781994-10-17 18:12:41 +00001282
1283 case VK_RETURN:
1284 {
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001285 DWORD dw = SendMessage16( hwndDlg, DM_GETDEFID, 0, 0 );
Alexandre Julliardaca05781994-10-17 18:12:41 +00001286 if (HIWORD(dw) == DC_HASDEFID)
Norman Stevensa83d0651998-10-12 07:25:35 +00001287 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001288 SendMessageA( hwndDlg, WM_COMMAND,
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001289 MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
Alexandre Julliarda3960291999-02-26 11:11:13 +00001290 (LPARAM)GetDlgItem(hwndDlg, LOWORD(dw)));
Norman Stevensa83d0651998-10-12 07:25:35 +00001291 }
Alexandre Julliardaf0bae51995-10-03 17:06:08 +00001292 else
Norman Stevensa83d0651998-10-12 07:25:35 +00001293 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001294 SendMessageA( hwndDlg, WM_COMMAND, IDOK,
1295 (LPARAM)GetDlgItem( hwndDlg, IDOK ) );
Norman Stevensa83d0651998-10-12 07:25:35 +00001296
1297 }
Alexandre Julliardaca05781994-10-17 18:12:41 +00001298 }
Norman Stevensa83d0651998-10-12 07:25:35 +00001299 return TRUE;
Alexandre Julliardaca05781994-10-17 18:12:41 +00001300 }
Norman Stevensa83d0651998-10-12 07:25:35 +00001301 *translate = TRUE;
1302 break; /* case WM_KEYDOWN */
Alexandre Julliardaca05781994-10-17 18:12:41 +00001303
Alexandre Julliardaca05781994-10-17 18:12:41 +00001304 case WM_CHAR:
Norman Stevensa83d0651998-10-12 07:25:35 +00001305 if (dlgCode & DLGC_WANTCHARS) break;
1306 /* drop through */
Alexandre Julliardaca05781994-10-17 18:12:41 +00001307
1308 case WM_SYSCHAR:
Norman Stevensa83d0651998-10-12 07:25:35 +00001309 if (DIALOG_IsAccelerator( hwnd, hwndDlg, wParam ))
1310 {
1311 /* don't translate or dispatch */
1312 return TRUE;
1313 }
Alexandre Julliardaca05781994-10-17 18:12:41 +00001314 break;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001315 }
Alexandre Julliardaca05781994-10-17 18:12:41 +00001316
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001317 /* If we get here, the message has not been treated specially */
1318 /* and can be sent to its destination window. */
1319 *dispatch = TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001320 return TRUE;
1321}
1322
1323
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001324/***********************************************************************
1325 * IsDialogMessage16 (USER.90)
1326 */
Ove Kaaven748acbb1998-11-01 15:27:12 +00001327BOOL16 WINAPI WIN16_IsDialogMessage16( HWND16 hwndDlg, SEGPTR msg16 )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001328{
Ove Kaaven748acbb1998-11-01 15:27:12 +00001329 LPMSG16 msg = PTR_SEG_TO_LIN(msg16);
Alexandre Julliarda3960291999-02-26 11:11:13 +00001330 BOOL ret, translate, dispatch;
David Grantedb77971999-11-07 21:02:17 +00001331 INT dlgCode = 0;
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001332
1333 if ((hwndDlg != msg->hwnd) && !IsChild16( hwndDlg, msg->hwnd ))
1334 return FALSE;
1335
David Grantedb77971999-11-07 21:02:17 +00001336 if ((msg->message == WM_KEYDOWN) ||
1337 (msg->message == WM_SYSCHAR) ||
1338 (msg->message == WM_CHAR))
1339 {
1340 dlgCode = SendMessage16( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg16);
1341 }
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001342 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1343 msg->wParam, msg->lParam,
Norman Stevensa83d0651998-10-12 07:25:35 +00001344 &translate, &dispatch, dlgCode );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001345 if (translate) TranslateMessage16( msg );
1346 if (dispatch) DispatchMessage16( msg );
1347 return ret;
1348}
1349
1350
Ove Kaaven748acbb1998-11-01 15:27:12 +00001351BOOL16 WINAPI IsDialogMessage16( HWND16 hwndDlg, LPMSG16 msg )
1352{
1353 LPMSG16 msg16 = SEGPTR_NEW(MSG16);
Alexandre Julliarda3960291999-02-26 11:11:13 +00001354 BOOL ret;
Ove Kaaven748acbb1998-11-01 15:27:12 +00001355
1356 *msg16 = *msg;
1357 ret = WIN16_IsDialogMessage16( hwndDlg, SEGPTR_GET(msg16) );
1358 SEGPTR_FREE(msg16);
1359 return ret;
1360}
1361
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001362/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001363 * IsDialogMessage32A (USER32.342)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001364 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001365BOOL WINAPI IsDialogMessageA( HWND hwndDlg, LPMSG msg )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001366{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001367 BOOL ret, translate, dispatch;
David Grantedb77971999-11-07 21:02:17 +00001368 INT dlgCode = 0;
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001369
Alexandre Julliarda3960291999-02-26 11:11:13 +00001370 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001371 return FALSE;
1372
David Grantedb77971999-11-07 21:02:17 +00001373 if ((msg->message == WM_KEYDOWN) ||
1374 (msg->message == WM_SYSCHAR) ||
1375 (msg->message == WM_CHAR))
1376 {
1377 dlgCode = SendMessageA( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
1378 }
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001379 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1380 msg->wParam, msg->lParam,
Norman Stevensa83d0651998-10-12 07:25:35 +00001381 &translate, &dispatch, dlgCode );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001382 if (translate) TranslateMessage( msg );
1383 if (dispatch) DispatchMessageA( msg );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001384 return ret;
1385}
1386
1387
1388/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001389 * IsDialogMessage32W (USER32.343)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001390 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001391BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001392{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001393 BOOL ret, translate, dispatch;
David Grantedb77971999-11-07 21:02:17 +00001394 INT dlgCode = 0;
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001395
Alexandre Julliarda3960291999-02-26 11:11:13 +00001396 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001397 return FALSE;
1398
David Grantedb77971999-11-07 21:02:17 +00001399 if ((msg->message == WM_KEYDOWN) ||
1400 (msg->message == WM_SYSCHAR) ||
1401 (msg->message == WM_CHAR))
1402 {
1403 dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
1404 }
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001405 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1406 msg->wParam, msg->lParam,
Norman Stevensa83d0651998-10-12 07:25:35 +00001407 &translate, &dispatch, dlgCode );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001408 if (translate) TranslateMessage( msg );
1409 if (dispatch) DispatchMessageW( msg );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001410 return ret;
1411}
1412
1413
Alexandre Julliard0e607781993-11-03 19:23:37 +00001414/****************************************************************
Alexandre Julliard01d63461997-01-20 19:43:45 +00001415 * GetDlgCtrlID16 (USER.277)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001416 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001417INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
Alexandre Julliard01d63461997-01-20 19:43:45 +00001418{
1419 WND *wndPtr = WIN_FindWndPtr(hwnd);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001420 INT16 retvalue;
1421
1422 if (!wndPtr) return 0;
1423
1424 retvalue = wndPtr->wIDmenu;
1425 WIN_ReleaseWndPtr(wndPtr);
1426 return retvalue;
Alexandre Julliard01d63461997-01-20 19:43:45 +00001427}
1428
1429
1430/****************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001431 * GetDlgCtrlID32 (USER32.234)
Alexandre Julliard01d63461997-01-20 19:43:45 +00001432 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001433INT WINAPI GetDlgCtrlID( HWND hwnd )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001434{
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001435 INT retvalue;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001436 WND *wndPtr = WIN_FindWndPtr(hwnd);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001437 if (!wndPtr) return 0;
1438 retvalue = wndPtr->wIDmenu;
1439 WIN_ReleaseWndPtr(wndPtr);
1440 return retvalue;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001441}
1442
1443
1444/***********************************************************************
Alexandre Julliard01d63461997-01-20 19:43:45 +00001445 * GetDlgItem16 (USER.91)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001446 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001447HWND16 WINAPI GetDlgItem16( HWND16 hwndDlg, INT16 id )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001448{
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001449 WND *pWnd;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001450
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001451 if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001452 for (WIN_UpdateWndPtr(&pWnd,pWnd->child); pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next))
1453 if (pWnd->wIDmenu == (UINT16)id)
1454 {
1455 HWND16 retvalue = pWnd->hwndSelf;
1456 WIN_ReleaseWndPtr(pWnd);
1457 return retvalue;
1458 }
Alexandre Julliard01d63461997-01-20 19:43:45 +00001459 return 0;
1460}
1461
1462
1463/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001464 * GetDlgItem32 (USER32.235)
Alexandre Julliard01d63461997-01-20 19:43:45 +00001465 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001466HWND WINAPI GetDlgItem( HWND hwndDlg, INT id )
Alexandre Julliard01d63461997-01-20 19:43:45 +00001467{
1468 WND *pWnd;
1469
1470 if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001471 for (WIN_UpdateWndPtr(&pWnd,pWnd->child); pWnd;WIN_UpdateWndPtr(&pWnd,pWnd->next))
1472 if (pWnd->wIDmenu == (UINT16)id)
1473 {
1474 HWND retvalue = pWnd->hwndSelf;
1475 WIN_ReleaseWndPtr(pWnd);
1476 return retvalue;
1477 }
Alexandre Julliard0e607781993-11-03 19:23:37 +00001478 return 0;
1479}
1480
1481
1482/*******************************************************************
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001483 * SendDlgItemMessage16 (USER.101)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001484 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001485LRESULT WINAPI SendDlgItemMessage16( HWND16 hwnd, INT16 id, UINT16 msg,
1486 WPARAM16 wParam, LPARAM lParam )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001487{
Alexandre Julliard01d63461997-01-20 19:43:45 +00001488 HWND16 hwndCtrl = GetDlgItem16( hwnd, id );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001489 if (hwndCtrl) return SendMessage16( hwndCtrl, msg, wParam, lParam );
Alexandre Julliard0e607781993-11-03 19:23:37 +00001490 else return 0;
1491}
1492
1493
1494/*******************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001495 * SendDlgItemMessage32A (USER32.452)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001496 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001497LRESULT WINAPI SendDlgItemMessageA( HWND hwnd, INT id, UINT msg,
1498 WPARAM wParam, LPARAM lParam )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001499{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001500 HWND hwndCtrl = GetDlgItem( hwnd, id );
1501 if (hwndCtrl) return SendMessageA( hwndCtrl, msg, wParam, lParam );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001502 else return 0;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001503}
1504
1505
1506/*******************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001507 * SendDlgItemMessage32W (USER32.453)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001508 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001509LRESULT WINAPI SendDlgItemMessageW( HWND hwnd, INT id, UINT msg,
1510 WPARAM wParam, LPARAM lParam )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001511{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001512 HWND hwndCtrl = GetDlgItem( hwnd, id );
1513 if (hwndCtrl) return SendMessageW( hwndCtrl, msg, wParam, lParam );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001514 else return 0;
1515}
1516
1517
1518/*******************************************************************
1519 * SetDlgItemText16 (USER.92)
1520 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001521void WINAPI SetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR lpString )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001522{
1523 SendDlgItemMessage16( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1524}
1525
1526
1527/*******************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001528 * SetDlgItemText32A (USER32.478)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001529 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001530BOOL WINAPI SetDlgItemTextA( HWND hwnd, INT id, LPCSTR lpString )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001531{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001532 return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001533}
1534
1535
1536/*******************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001537 * SetDlgItemText32W (USER32.479)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001538 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001539BOOL WINAPI SetDlgItemTextW( HWND hwnd, INT id, LPCWSTR lpString )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001540{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001541 return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001542}
1543
1544
1545/***********************************************************************
1546 * GetDlgItemText16 (USER.93)
1547 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001548INT16 WINAPI GetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR str, UINT16 len )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001549{
1550 return (INT16)SendDlgItemMessage16( hwnd, id, WM_GETTEXT,
1551 len, (LPARAM)str );
1552}
1553
1554
1555/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001556 * GetDlgItemText32A (USER32.237)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001557 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001558INT WINAPI GetDlgItemTextA( HWND hwnd, INT id, LPSTR str, UINT len )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001559{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001560 return (INT)SendDlgItemMessageA( hwnd, id, WM_GETTEXT,
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001561 len, (LPARAM)str );
1562}
1563
1564
1565/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001566 * GetDlgItemText32W (USER32.238)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001567 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001568INT WINAPI GetDlgItemTextW( HWND hwnd, INT id, LPWSTR str, UINT len )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001569{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001570 return (INT)SendDlgItemMessageW( hwnd, id, WM_GETTEXT,
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001571 len, (LPARAM)str );
1572}
1573
1574
1575/*******************************************************************
1576 * SetDlgItemInt16 (USER.94)
1577 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001578void WINAPI SetDlgItemInt16( HWND16 hwnd, INT16 id, UINT16 value, BOOL16 fSigned )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001579{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001580 SetDlgItemInt( hwnd, (UINT)(UINT16)id, value, fSigned );
Alexandre Julliard0e607781993-11-03 19:23:37 +00001581}
1582
1583
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001584/*******************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001585 * SetDlgItemInt32 (USER32.477)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001586 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001587BOOL WINAPI SetDlgItemInt( HWND hwnd, INT id, UINT value,
1588 BOOL fSigned )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001589{
1590 char str[20];
1591
Alexandre Julliarda3960291999-02-26 11:11:13 +00001592 if (fSigned) sprintf( str, "%d", (INT)value );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001593 else sprintf( str, "%u", value );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001594 SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)str );
Eric Pouechb9544f11999-02-14 14:09:42 +00001595 return TRUE;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001596}
1597
1598
Alexandre Julliard0e607781993-11-03 19:23:37 +00001599/***********************************************************************
Alexandre Julliard01d63461997-01-20 19:43:45 +00001600 * GetDlgItemInt16 (USER.95)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001601 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001602UINT16 WINAPI GetDlgItemInt16( HWND16 hwnd, INT16 id, BOOL16 *translated,
1603 BOOL16 fSigned )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001604{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001605 UINT result;
1606 BOOL ok;
Alexandre Julliard01d63461997-01-20 19:43:45 +00001607
Alexandre Julliard0e607781993-11-03 19:23:37 +00001608 if (translated) *translated = FALSE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001609 result = GetDlgItemInt( hwnd, (UINT)(UINT16)id, &ok, fSigned );
Alexandre Julliard01d63461997-01-20 19:43:45 +00001610 if (!ok) return 0;
1611 if (fSigned)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001612 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001613 if (((INT)result < -32767) || ((INT)result > 32767)) return 0;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001614 }
Alexandre Julliard01d63461997-01-20 19:43:45 +00001615 else
1616 {
1617 if (result > 65535) return 0;
1618 }
1619 if (translated) *translated = TRUE;
1620 return (UINT16)result;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001621}
1622
1623
1624/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001625 * GetDlgItemInt32 (USER32.236)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001626 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001627UINT WINAPI GetDlgItemInt( HWND hwnd, INT id, BOOL *translated,
1628 BOOL fSigned )
Alexandre Julliard01d63461997-01-20 19:43:45 +00001629{
1630 char str[30];
1631 char * endptr;
1632 long result = 0;
1633
1634 if (translated) *translated = FALSE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001635 if (!SendDlgItemMessageA(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str))
Alexandre Julliard01d63461997-01-20 19:43:45 +00001636 return 0;
1637 if (fSigned)
1638 {
1639 result = strtol( str, &endptr, 10 );
1640 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1641 return 0;
1642 if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE))
1643 return 0;
1644 }
1645 else
1646 {
1647 result = strtoul( str, &endptr, 10 );
1648 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1649 return 0;
1650 if ((result == ULONG_MAX) && (errno == ERANGE)) return 0;
1651 }
1652 if (translated) *translated = TRUE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001653 return (UINT)result;
Alexandre Julliard01d63461997-01-20 19:43:45 +00001654}
1655
1656
1657/***********************************************************************
1658 * CheckDlgButton16 (USER.97)
1659 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001660BOOL16 WINAPI CheckDlgButton16( HWND16 hwnd, INT16 id, UINT16 check )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001661{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001662 SendDlgItemMessageA( hwnd, id, BM_SETCHECK, check, 0 );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001663 return TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001664}
1665
1666
1667/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001668 * CheckDlgButton32 (USER32.45)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001669 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001670BOOL WINAPI CheckDlgButton( HWND hwnd, INT id, UINT check )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001671{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001672 SendDlgItemMessageA( hwnd, id, BM_SETCHECK, check, 0 );
Alexandre Julliard01d63461997-01-20 19:43:45 +00001673 return TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001674}
1675
1676
1677/***********************************************************************
Alexandre Julliard01d63461997-01-20 19:43:45 +00001678 * IsDlgButtonChecked16 (USER.98)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001679 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001680UINT16 WINAPI IsDlgButtonChecked16( HWND16 hwnd, UINT16 id )
Alexandre Julliard01d63461997-01-20 19:43:45 +00001681{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001682 return (UINT16)SendDlgItemMessageA( hwnd, id, BM_GETCHECK, 0, 0 );
Alexandre Julliard01d63461997-01-20 19:43:45 +00001683}
1684
1685
1686/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001687 * IsDlgButtonChecked32 (USER32.344)
Alexandre Julliard01d63461997-01-20 19:43:45 +00001688 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001689UINT WINAPI IsDlgButtonChecked( HWND hwnd, UINT id )
Alexandre Julliard01d63461997-01-20 19:43:45 +00001690{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001691 return (UINT)SendDlgItemMessageA( hwnd, id, BM_GETCHECK, 0, 0 );
Alexandre Julliard01d63461997-01-20 19:43:45 +00001692}
1693
1694
1695/***********************************************************************
1696 * CheckRadioButton16 (USER.96)
1697 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001698BOOL16 WINAPI CheckRadioButton16( HWND16 hwndDlg, UINT16 firstID,
1699 UINT16 lastID, UINT16 checkID )
Alexandre Julliard01d63461997-01-20 19:43:45 +00001700{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001701 return CheckRadioButton( hwndDlg, firstID, lastID, checkID );
Alexandre Julliard01d63461997-01-20 19:43:45 +00001702}
1703
1704
1705/***********************************************************************
Luc Tourangeau8e238d01999-05-29 14:19:42 +00001706 * CheckRB
1707 *
1708 * Callback function used to check/uncheck radio buttons that fall
1709 * within a specific range of IDs.
1710 */
1711static BOOL CALLBACK CheckRB(HWND hwndChild, LPARAM lParam)
1712{
1713 LONG lChildID = GetWindowLongA(hwndChild, GWL_ID);
1714 RADIOGROUP *lpRadioGroup = (RADIOGROUP *) lParam;
1715
1716 if ((lChildID >= lpRadioGroup->firstID) &&
1717 (lChildID <= lpRadioGroup->lastID))
1718 {
1719 if (lChildID == lpRadioGroup->checkID)
1720 {
1721 SendMessageA(hwndChild, BM_SETCHECK, BST_CHECKED, 0);
1722 }
1723 else
1724 {
1725 SendMessageA(hwndChild, BM_SETCHECK, BST_UNCHECKED, 0);
1726 }
1727 }
1728
1729 return TRUE;
1730}
1731
1732
1733/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001734 * CheckRadioButton32 (USER32.48)
Alexandre Julliard01d63461997-01-20 19:43:45 +00001735 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001736BOOL WINAPI CheckRadioButton( HWND hwndDlg, UINT firstID,
Luc Tourangeau8e238d01999-05-29 14:19:42 +00001737 UINT lastID, UINT checkID )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001738{
Luc Tourangeau8e238d01999-05-29 14:19:42 +00001739 RADIOGROUP radioGroup;
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00001740
Luc Tourangeau8e238d01999-05-29 14:19:42 +00001741 /* perform bounds checking for a radio button group */
1742 radioGroup.firstID = min(min(firstID, lastID), checkID);
1743 radioGroup.lastID = max(max(firstID, lastID), checkID);
1744 radioGroup.checkID = checkID;
1745
1746 return EnumChildWindows(hwndDlg, (WNDENUMPROC)CheckRB,
1747 (LPARAM)&radioGroup);
Alexandre Julliard0e607781993-11-03 19:23:37 +00001748}
1749
1750
1751/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001752 * GetDialogBaseUnits (USER.243) (USER32.233)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001753 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001754DWORD WINAPI GetDialogBaseUnits(void)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001755{
1756 return MAKELONG( xBaseUnit, yBaseUnit );
1757}
1758
1759
1760/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001761 * MapDialogRect16 (USER.103)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001762 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001763void WINAPI MapDialogRect16( HWND16 hwnd, LPRECT16 rect )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001764{
1765 DIALOGINFO * dlgInfo;
1766 WND * wndPtr = WIN_FindWndPtr( hwnd );
1767 if (!wndPtr) return;
1768 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
Francis Beaudeteb13dd41999-09-03 15:14:27 +00001769 rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4);
1770 rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4);
1771 rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8);
1772 rect->bottom = MulDiv(rect->bottom, dlgInfo->yBaseUnit, 8);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001773 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001774}
1775
1776
1777/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001778 * MapDialogRect32 (USER32.382)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001779 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001780BOOL WINAPI MapDialogRect( HWND hwnd, LPRECT rect )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001781{
1782 DIALOGINFO * dlgInfo;
1783 WND * wndPtr = WIN_FindWndPtr( hwnd );
Eric Pouechb9544f11999-02-14 14:09:42 +00001784 if (!wndPtr) return FALSE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001785 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
Francis Beaudeteb13dd41999-09-03 15:14:27 +00001786 rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4);
1787 rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4);
1788 rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8);
1789 rect->bottom = MulDiv(rect->bottom, dlgInfo->yBaseUnit, 8);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001790 WIN_ReleaseWndPtr(wndPtr);
Eric Pouechb9544f11999-02-14 14:09:42 +00001791 return TRUE;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001792}
1793
1794
1795/***********************************************************************
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001796 * GetNextDlgGroupItem16 (USER.227)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001797 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001798HWND16 WINAPI GetNextDlgGroupItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
1799 BOOL16 fPrevious )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001800{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001801 return (HWND16)GetNextDlgGroupItem( hwndDlg, hwndCtrl, fPrevious );
Alexandre Julliard0e607781993-11-03 19:23:37 +00001802}
1803
1804
1805/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001806 * GetNextDlgGroupItem32 (USER32.275)
Alexandre Julliard0e607781993-11-03 19:23:37 +00001807 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001808HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl,
1809 BOOL fPrevious )
Alexandre Julliard0e607781993-11-03 19:23:37 +00001810{
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001811 WND *pWnd = NULL,
1812 *pWndLast = NULL,
1813 *pWndCtrl = NULL,
1814 *pWndDlg = NULL;
1815 HWND retvalue;
Alexandre Julliard0e607781993-11-03 19:23:37 +00001816
Alexandre Julliarde6b82e71999-12-12 20:17:59 +00001817 if(hwndCtrl)
1818 {
1819 /* if the hwndCtrl is the child of the control in the hwndDlg then the hwndDlg has to be the parent of the hwndCtrl */
1820 if(GetParent(hwndCtrl) != hwndDlg && GetParent(GetParent(hwndCtrl)) == hwndDlg)
1821 hwndDlg = GetParent(hwndCtrl);
1822 }
1823
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001824 if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001825 if (hwndCtrl)
1826 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001827 if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl )))
1828 {
1829 retvalue = 0;
1830 goto END;
1831 }
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001832 /* Make sure hwndCtrl is a top-level child */
1833 while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg))
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001834 WIN_UpdateWndPtr(&pWndCtrl,pWndCtrl->parent);
1835 if (pWndCtrl->parent != pWndDlg)
1836 {
1837 retvalue = 0;
1838 goto END;
1839 }
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001840 }
1841 else
1842 {
1843 /* No ctrl specified -> start from the beginning */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001844 if (!(pWndCtrl = WIN_LockWndPtr(pWndDlg->child)))
1845 {
1846 retvalue = 0;
1847 goto END;
1848 }
1849 if (fPrevious)
1850 while (pWndCtrl->next) WIN_UpdateWndPtr(&pWndCtrl,pWndCtrl->next);
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001851 }
1852
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001853 pWndLast = WIN_LockWndPtr(pWndCtrl);
1854 pWnd = WIN_LockWndPtr(pWndCtrl->next);
1855
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001856 while (1)
1857 {
1858 if (!pWnd || (pWnd->dwStyle & WS_GROUP))
1859 {
1860 /* Wrap-around to the beginning of the group */
Ulrich Weigand9c3b18f1999-05-17 14:54:09 +00001861 WND *pWndTemp;
1862
1863 WIN_UpdateWndPtr( &pWnd, pWndDlg->child );
1864 for ( pWndTemp = WIN_LockWndPtr( pWnd );
1865 pWndTemp;
1866 WIN_UpdateWndPtr( &pWndTemp, pWndTemp->next) )
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001867 {
Ulrich Weigand9c3b18f1999-05-17 14:54:09 +00001868 if (pWndTemp->dwStyle & WS_GROUP) WIN_UpdateWndPtr( &pWnd, pWndTemp );
1869 if (pWndTemp == pWndCtrl) break;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001870 }
Ulrich Weigand9c3b18f1999-05-17 14:54:09 +00001871 WIN_ReleaseWndPtr( pWndTemp );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001872 }
1873 if (pWnd == pWndCtrl) break;
1874 if ((pWnd->dwStyle & WS_VISIBLE) && !(pWnd->dwStyle & WS_DISABLED))
1875 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001876 WIN_UpdateWndPtr(&pWndLast,pWnd);
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001877 if (!fPrevious) break;
1878 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001879 WIN_UpdateWndPtr(&pWnd,pWnd->next);
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001880 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001881 retvalue = pWndLast->hwndSelf;
1882
1883 WIN_ReleaseWndPtr(pWndLast);
1884 WIN_ReleaseWndPtr(pWnd);
1885END:
1886 WIN_ReleaseWndPtr(pWndCtrl);
1887 WIN_ReleaseWndPtr(pWndDlg);
1888
1889 return retvalue;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001890}
1891
1892
1893/***********************************************************************
1894 * GetNextDlgTabItem16 (USER.228)
1895 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001896HWND16 WINAPI GetNextDlgTabItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
1897 BOOL16 fPrevious )
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001898{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001899 return (HWND16)GetNextDlgTabItem( hwndDlg, hwndCtrl, fPrevious );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001900}
1901
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001902/***********************************************************************
1903 * DIALOG_GetNextTabItem
1904 *
1905 * Helper for GetNextDlgTabItem
1906 */
1907static HWND DIALOG_GetNextTabItem( HWND hwndMain, HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
1908{
1909 LONG dsStyle;
1910 LONG exStyle;
1911 UINT wndSearch = fPrevious ? GW_HWNDPREV : GW_HWNDNEXT;
1912 HWND retWnd = 0;
1913 HWND hChildFirst = 0;
1914
1915 if(!hwndCtrl)
1916 {
1917 hChildFirst = GetWindow(hwndDlg,GW_CHILD);
1918 if(fPrevious) hChildFirst = GetWindow(hChildFirst,GW_HWNDLAST);
1919 }
1920 else
1921 {
1922 HWND hParent = GetParent(hwndCtrl);
1923 BOOL bValid = FALSE;
1924 while( hParent)
1925 {
1926 if(hParent == hwndMain)
1927 {
1928 bValid = TRUE;
1929 break;
1930 }
1931 hParent = GetParent(hParent);
1932 }
1933 if(bValid)
1934 {
1935 hChildFirst = GetWindow(hwndCtrl,wndSearch);
1936 if(!hChildFirst)
1937 {
1938 if(GetParent(hwndCtrl) != hwndMain)
1939 hChildFirst = GetWindow(GetParent(hwndCtrl),wndSearch);
1940 else
1941 {
1942 if(fPrevious)
1943 hChildFirst = GetWindow(hwndCtrl,GW_HWNDLAST);
1944 else
1945 hChildFirst = GetWindow(hwndCtrl,GW_HWNDFIRST);
1946 }
1947 }
1948 }
1949 }
1950 while(hChildFirst)
1951 {
1952 BOOL bCtrl = FALSE;
1953 while(hChildFirst)
1954 {
1955 dsStyle = GetWindowLongA(hChildFirst,GWL_STYLE);
1956 exStyle = GetWindowLongA(hChildFirst,GWL_EXSTYLE);
Alexandre Julliarde6b82e71999-12-12 20:17:59 +00001957 if( (dsStyle & DS_CONTROL || exStyle & WS_EX_CONTROLPARENT) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001958 {
1959 bCtrl=TRUE;
1960 break;
1961 }
1962 else if( (dsStyle & WS_TABSTOP) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
1963 break;
1964 hChildFirst = GetWindow(hChildFirst,wndSearch);
1965 }
1966 if(hChildFirst)
1967 {
1968 if(bCtrl)
1969 retWnd = DIALOG_GetNextTabItem(hwndMain,hChildFirst,(HWND)NULL,fPrevious );
1970 else
1971 retWnd = hChildFirst;
1972 }
1973 if(retWnd) break;
1974 hChildFirst = GetWindow(hChildFirst,wndSearch);
1975 }
1976 if(!retWnd && hwndCtrl)
1977 {
1978 HWND hParent = GetParent(hwndCtrl);
1979 while(hParent)
1980 {
1981 if(hParent == hwndMain) break;
1982 retWnd = DIALOG_GetNextTabItem(hwndMain,GetParent(hParent),hParent,fPrevious );
1983 if(retWnd) break;
1984 hParent = GetParent(hParent);
1985 }
1986 if(!retWnd)
1987 retWnd = DIALOG_GetNextTabItem(hwndMain,hwndMain,(HWND)NULL,fPrevious );
1988 }
1989 return retWnd;
1990}
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001991
1992/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001993 * GetNextDlgTabItem32 (USER32.276)
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001994 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001995HWND WINAPI GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl,
1996 BOOL fPrevious )
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001997{
Ulrich Czekalla1720c981999-10-31 21:35:35 +00001998 return DIALOG_GetNextTabItem(hwndDlg,hwndDlg,hwndCtrl,fPrevious);
Alexandre Julliard0e607781993-11-03 19:23:37 +00001999}
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002000
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002001/**********************************************************************
2002 * DIALOG_DlgDirSelect
2003 *
2004 * Helper function for DlgDirSelect*
2005 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002006static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len,
2007 INT id, BOOL win32, BOOL unicode,
2008 BOOL combo )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002009{
2010 char *buffer, *ptr;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002011 INT item, size;
2012 BOOL ret;
2013 HWND listbox = GetDlgItem( hwnd, id );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002014
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002015 TRACE("%04x '%s' %d\n", hwnd, str, id );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002016 if (!listbox) return FALSE;
2017 if (win32)
2018 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002019 item = SendMessageA(listbox, combo ? CB_GETCURSEL
2020 : LB_GETCURSEL, 0, 0 );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002021 if (item == LB_ERR) return FALSE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002022 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN
2023 : LB_GETTEXTLEN, 0, 0 );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002024 if (size == LB_ERR) return FALSE;
2025 }
2026 else
2027 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002028 item = SendMessageA(listbox, combo ? CB_GETCURSEL16
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002029 : LB_GETCURSEL16, 0, 0 );
2030 if (item == LB_ERR) return FALSE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002031 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN16
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002032 : LB_GETTEXTLEN16, 0, 0 );
2033 if (size == LB_ERR) return FALSE;
2034 }
2035
2036 if (!(buffer = SEGPTR_ALLOC( size+1 ))) return FALSE;
2037
2038 if (win32)
Alexandre Julliarda3960291999-02-26 11:11:13 +00002039 SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT,
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002040 item, (LPARAM)buffer );
2041 else
2042 SendMessage16( listbox, combo ? CB_GETLBTEXT16 : LB_GETTEXT16,
2043 item, (LPARAM)SEGPTR_GET(buffer) );
2044
2045 if ((ret = (buffer[0] == '['))) /* drive or directory */
2046 {
2047 if (buffer[1] == '-') /* drive */
2048 {
2049 buffer[3] = ':';
2050 buffer[4] = 0;
2051 ptr = buffer + 2;
2052 }
2053 else
2054 {
2055 buffer[strlen(buffer)-1] = '\\';
2056 ptr = buffer + 1;
2057 }
2058 }
2059 else ptr = buffer;
2060
2061 if (unicode) lstrcpynAtoW( (LPWSTR)str, ptr, len );
Alexandre Julliarda3960291999-02-26 11:11:13 +00002062 else lstrcpynA( str, ptr, len );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002063 SEGPTR_FREE( buffer );
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002064 TRACE("Returning %d '%s'\n", ret, str );
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002065 return ret;
2066}
2067
2068
2069/**********************************************************************
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002070 * DIALOG_DlgDirList
2071 *
2072 * Helper function for DlgDirList*
2073 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002074static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox,
2075 INT idStatic, UINT attrib, BOOL combo )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002076{
2077 int drive;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002078 HWND hwnd;
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002079 LPSTR orig_spec = spec;
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002080
2081#define SENDMSG(msg,wparam,lparam) \
Alexandre Julliarda3960291999-02-26 11:11:13 +00002082 ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \
2083 : SendMessageA( hwnd, msg, wparam, lparam ))
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002084
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002085 TRACE("%04x '%s' %d %d %04x\n",
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002086 hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
2087
2088 if (spec && spec[0] && (spec[1] == ':'))
2089 {
2090 drive = toupper( spec[0] ) - 'A';
2091 spec += 2;
2092 if (!DRIVE_SetCurrentDrive( drive )) return FALSE;
2093 }
2094 else drive = DRIVE_GetCurrentDrive();
2095
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002096 /* If the path exists and is a directory, chdir to it */
2097 if (!spec || !spec[0] || DRIVE_Chdir( drive, spec )) spec = "*.*";
2098 else
2099 {
2100 char *p, *p2;
2101 p = spec;
2102 if ((p2 = strrchr( p, '\\' ))) p = p2;
2103 if ((p2 = strrchr( p, '/' ))) p = p2;
2104 if (p != spec)
2105 {
2106 char sep = *p;
2107 *p = 0;
2108 if (!DRIVE_Chdir( drive, spec ))
2109 {
2110 *p = sep; /* Restore the original spec */
2111 return FALSE;
2112 }
2113 spec = p + 1;
2114 }
2115 }
2116
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002117 TRACE("path=%c:\\%s mask=%s\n",
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002118 'A' + drive, DRIVE_GetDosCwd(drive), spec );
2119
Alexandre Julliarda3960291999-02-26 11:11:13 +00002120 if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0))
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002121 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002122 SENDMSG( combo ? CB_RESETCONTENT : LB_RESETCONTENT, 0, 0 );
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002123 if (attrib & DDL_DIRECTORY)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002124 {
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002125 if (!(attrib & DDL_EXCLUSIVE))
2126 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002127 if (SENDMSG( combo ? CB_DIR : LB_DIR,
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002128 attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
2129 (LPARAM)spec ) == LB_ERR)
2130 return FALSE;
2131 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00002132 if (SENDMSG( combo ? CB_DIR : LB_DIR,
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002133 (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
2134 (LPARAM)"*.*" ) == LB_ERR)
2135 return FALSE;
2136 }
2137 else
2138 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002139 if (SENDMSG( combo ? CB_DIR : LB_DIR, attrib,
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002140 (LPARAM)spec ) == LB_ERR)
2141 return FALSE;
2142 }
2143 }
2144
Alexandre Julliarda3960291999-02-26 11:11:13 +00002145 if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002146 {
2147 char temp[512];
2148 int drive = DRIVE_GetCurrentDrive();
2149 strcpy( temp, "A:\\" );
2150 temp[0] += drive;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002151 lstrcpynA( temp + 3, DRIVE_GetDosCwd(drive), sizeof(temp)-3 );
2152 CharLowerA( temp );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002153 /* Can't use PostMessage() here, because the string is on the stack */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002154 SetDlgItemTextA( hDlg, idStatic, temp );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002155 }
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002156
2157 if (orig_spec && (spec != orig_spec))
2158 {
2159 /* Update the original file spec */
2160 char *p = spec;
2161 while ((*orig_spec++ = *p++));
2162 }
2163
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002164 return TRUE;
2165#undef SENDMSG
2166}
2167
2168
2169/**********************************************************************
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002170 * DIALOG_DlgDirListW
2171 *
2172 * Helper function for DlgDirList*32W
2173 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002174static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2175 INT idStatic, UINT attrib, BOOL combo )
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002176{
2177 if (spec)
2178 {
2179 LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
Alexandre Julliarda3960291999-02-26 11:11:13 +00002180 INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002181 attrib, combo );
2182 lstrcpyAtoW( spec, specA );
2183 HeapFree( GetProcessHeap(), 0, specA );
2184 return ret;
2185 }
2186 return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
2187}
2188
2189
2190/**********************************************************************
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002191 * DlgDirSelect (USER.99)
2192 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002193BOOL16 WINAPI DlgDirSelect16( HWND16 hwnd, LPSTR str, INT16 id )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002194{
2195 return DlgDirSelectEx16( hwnd, str, 128, id );
2196}
2197
2198
2199/**********************************************************************
2200 * DlgDirSelectComboBox (USER.194)
2201 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002202BOOL16 WINAPI DlgDirSelectComboBox16( HWND16 hwnd, LPSTR str, INT16 id )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002203{
2204 return DlgDirSelectComboBoxEx16( hwnd, str, 128, id );
2205}
2206
2207
2208/**********************************************************************
2209 * DlgDirSelectEx16 (USER.422)
2210 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002211BOOL16 WINAPI DlgDirSelectEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002212{
2213 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE, FALSE );
2214}
2215
2216
2217/**********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00002218 * DlgDirSelectEx32A (USER32.149)
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002219 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002220BOOL WINAPI DlgDirSelectExA( HWND hwnd, LPSTR str, INT len, INT id )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002221{
2222 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, FALSE );
2223}
2224
2225
2226/**********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00002227 * DlgDirSelectEx32W (USER32.150)
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002228 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002229BOOL WINAPI DlgDirSelectExW( HWND hwnd, LPWSTR str, INT len, INT id )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002230{
2231 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, FALSE );
2232}
2233
2234
2235/**********************************************************************
2236 * DlgDirSelectComboBoxEx16 (USER.423)
2237 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002238BOOL16 WINAPI DlgDirSelectComboBoxEx16( HWND16 hwnd, LPSTR str, INT16 len,
2239 INT16 id )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002240{
2241 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE, TRUE );
2242}
2243
2244
2245/**********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00002246 * DlgDirSelectComboBoxEx32A (USER32.147)
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002247 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002248BOOL WINAPI DlgDirSelectComboBoxExA( HWND hwnd, LPSTR str, INT len,
2249 INT id )
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002250{
2251 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, TRUE );
2252}
2253
2254
2255/**********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00002256 * DlgDirSelectComboBoxEx32W (USER32.148)
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002257 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002258BOOL WINAPI DlgDirSelectComboBoxExW( HWND hwnd, LPWSTR str, INT len,
2259 INT id)
Alexandre Julliard75d86e11996-11-17 18:59:11 +00002260{
2261 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, TRUE );
2262}
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002263
2264
2265/**********************************************************************
2266 * DlgDirList16 (USER.100)
2267 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002268INT16 WINAPI DlgDirList16( HWND16 hDlg, LPSTR spec, INT16 idLBox,
2269 INT16 idStatic, UINT16 attrib )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002270{
2271 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2272}
2273
2274
2275/**********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00002276 * DlgDirList32A (USER32.143)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002277 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002278INT WINAPI DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox,
2279 INT idStatic, UINT attrib )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002280{
2281 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2282}
2283
2284
2285/**********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00002286 * DlgDirList32W (USER32.146)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002287 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002288INT WINAPI DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2289 INT idStatic, UINT attrib )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002290{
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002291 return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002292}
2293
2294
2295/**********************************************************************
2296 * DlgDirListComboBox16 (USER.195)
2297 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002298INT16 WINAPI DlgDirListComboBox16( HWND16 hDlg, LPSTR spec, INT16 idCBox,
2299 INT16 idStatic, UINT16 attrib )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002300{
2301 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
2302}
2303
2304
2305/**********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00002306 * DlgDirListComboBox32A (USER32.144)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002307 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002308INT WINAPI DlgDirListComboBoxA( HWND hDlg, LPSTR spec, INT idCBox,
2309 INT idStatic, UINT attrib )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002310{
2311 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
2312}
2313
2314
2315/**********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00002316 * DlgDirListComboBox32W (USER32.145)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002317 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002318INT WINAPI DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox,
2319 INT idStatic, UINT attrib )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002320{
Alexandre Julliard84c70f51997-05-09 08:40:27 +00002321 return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +00002322}