Added version information.
[wine] / dlls / user / dialog16.c
1 /*
2  * 16-bit dialog functions
3  *
4  * Copyright 1993, 1994, 1996, 2003 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include "windef.h"
25 #include "wownt32.h"
26 #include "wine/winuser16.h"
27 #include "controls.h"
28 #include "win.h"
29 #include "user.h"
30 #include "wine/debug.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(dialog);
33
34 /* Dialog control information */
35 typedef struct
36 {
37     DWORD      style;
38     INT16      x;
39     INT16      y;
40     INT16      cx;
41     INT16      cy;
42     UINT       id;
43     LPCSTR     className;
44     LPCSTR     windowName;
45     LPCVOID    data;
46 } DLG_CONTROL_INFO;
47
48   /* Dialog template */
49 typedef struct
50 {
51     DWORD      style;
52     UINT16     nbItems;
53     INT16      x;
54     INT16      y;
55     INT16      cx;
56     INT16      cy;
57     LPCSTR     menuName;
58     LPCSTR     className;
59     LPCSTR     caption;
60     WORD       pointSize;
61     LPCSTR     faceName;
62 } DLG_TEMPLATE;
63
64
65 /***********************************************************************
66  *           DIALOG_GetControl16
67  *
68  * Return the class and text of the control pointed to by ptr,
69  * fill the header structure and return a pointer to the next control.
70  */
71 static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info )
72 {
73     static char buffer[10];
74     int int_id;
75
76     info->x       = GET_WORD(p);  p += sizeof(WORD);
77     info->y       = GET_WORD(p);  p += sizeof(WORD);
78     info->cx      = GET_WORD(p);  p += sizeof(WORD);
79     info->cy      = GET_WORD(p);  p += sizeof(WORD);
80     info->id      = GET_WORD(p);  p += sizeof(WORD);
81     info->style   = GET_DWORD(p); p += sizeof(DWORD);
82
83     if (*p & 0x80)
84     {
85         switch((BYTE)*p)
86         {
87             case 0x80: strcpy( buffer, "BUTTON" ); break;
88             case 0x81: strcpy( buffer, "EDIT" ); break;
89             case 0x82: strcpy( buffer, "STATIC" ); break;
90             case 0x83: strcpy( buffer, "LISTBOX" ); break;
91             case 0x84: strcpy( buffer, "SCROLLBAR" ); break;
92             case 0x85: strcpy( buffer, "COMBOBOX" ); break;
93             default:   buffer[0] = '\0'; break;
94         }
95         info->className = buffer;
96         p++;
97     }
98     else
99     {
100         info->className = p;
101         p += strlen(p) + 1;
102     }
103
104     int_id = ((BYTE)*p == 0xff);
105     if (int_id)
106     {
107         /* Integer id, not documented (?). Only works for SS_ICON controls */
108         info->windowName = (LPCSTR)(UINT)GET_WORD(p+1);
109         p += 3;
110     }
111     else
112     {
113         info->windowName = p;
114         p += strlen(p) + 1;
115     }
116
117     if (*p) info->data = p + 1;
118     else info->data = NULL;
119
120     p += *p + 1;
121
122     TRACE("   %s %s %d, %d, %d, %d, %d, %08lx, %p\n",
123           debugstr_a(info->className),  debugstr_a(info->windowName),
124           info->id, info->x, info->y, info->cx, info->cy,
125           info->style, info->data );
126
127     return p;
128 }
129
130
131 /***********************************************************************
132  *           DIALOG_CreateControls16
133  *
134  * Create the control windows for a dialog.
135  */
136 static BOOL DIALOG_CreateControls16( HWND hwnd, LPCSTR template,
137                                      const DLG_TEMPLATE *dlgTemplate, HINSTANCE16 hInst )
138 {
139     DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd );
140     DLG_CONTROL_INFO info;
141     HWND hwndCtrl, hwndDefButton = 0;
142     INT items = dlgTemplate->nbItems;
143
144     TRACE(" BEGIN\n" );
145     while (items--)
146     {
147         HINSTANCE16 instance = hInst;
148         SEGPTR segptr;
149
150         template = DIALOG_GetControl16( template, &info );
151         if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
152             !(GetWindowLongW( hwnd, GWL_STYLE ) & DS_LOCALEDIT))
153         {
154             if (!dlgInfo->hDialogHeap)
155             {
156                 dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000);
157                 if (!dlgInfo->hDialogHeap)
158                 {
159                     ERR("Insufficient memory to create heap for edit control\n" );
160                     continue;
161                 }
162                 LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff);
163             }
164             instance = dlgInfo->hDialogHeap;
165         }
166
167         segptr = MapLS( info.data );
168         hwndCtrl = WIN_Handle32( CreateWindowEx16( WS_EX_NOPARENTNOTIFY,
169                                                    info.className, info.windowName,
170                                                    info.style | WS_CHILD,
171                                                    MulDiv(info.x, dlgInfo->xBaseUnit, 4),
172                                                    MulDiv(info.y, dlgInfo->yBaseUnit, 8),
173                                                    MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
174                                                    MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
175                                                    HWND_16(hwnd), (HMENU16)info.id,
176                                                    instance, (LPVOID)segptr ));
177         UnMapLS( segptr );
178
179         if (!hwndCtrl)
180         {
181             if (dlgTemplate->style & DS_NOFAILCREATE) continue;
182             return FALSE;
183         }
184
185             /* Send initialisation messages to the control */
186         if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT,
187                                              (WPARAM)dlgInfo->hUserFont, 0 );
188         if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
189         {
190               /* If there's already a default push-button, set it back */
191               /* to normal and use this one instead. */
192             if (hwndDefButton)
193                 SendMessageA( hwndDefButton, BM_SETSTYLE,
194                                 BS_PUSHBUTTON,FALSE );
195             hwndDefButton = hwndCtrl;
196             dlgInfo->idResult = GetWindowLongA( hwndCtrl, GWL_ID );
197         }
198     }
199     TRACE(" END\n" );
200     return TRUE;
201 }
202
203
204 /***********************************************************************
205  *           DIALOG_ParseTemplate16
206  *
207  * Fill a DLG_TEMPLATE structure from the dialog template, and return
208  * a pointer to the first control.
209  */
210 static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result )
211 {
212     result->style   = GET_DWORD(p); p += sizeof(DWORD);
213     result->nbItems = (unsigned char) *p++;
214     result->x       = GET_WORD(p);  p += sizeof(WORD);
215     result->y       = GET_WORD(p);  p += sizeof(WORD);
216     result->cx      = GET_WORD(p);  p += sizeof(WORD);
217     result->cy      = GET_WORD(p);  p += sizeof(WORD);
218
219     TRACE("DIALOG %d, %d, %d, %d\n", result->x, result->y, result->cx, result->cy );
220     TRACE(" STYLE %08lx\n", result->style );
221
222     /* Get the menu name */
223
224     switch( (BYTE)*p )
225     {
226     case 0:
227         result->menuName = 0;
228         p++;
229         break;
230     case 0xff:
231         result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
232         p += 3;
233         TRACE(" MENU %04x\n", LOWORD(result->menuName) );
234         break;
235     default:
236         result->menuName = p;
237         TRACE(" MENU '%s'\n", p );
238         p += strlen(p) + 1;
239         break;
240     }
241
242     /* Get the class name */
243
244     if (*p)
245     {
246         result->className = p;
247         TRACE(" CLASS '%s'\n", result->className );
248     }
249     else result->className = DIALOG_CLASS_ATOMA;
250     p += strlen(p) + 1;
251
252     /* Get the window caption */
253
254     result->caption = p;
255     p += strlen(p) + 1;
256     TRACE(" CAPTION '%s'\n", result->caption );
257
258     /* Get the font name */
259
260     if (result->style & DS_SETFONT)
261     {
262         result->pointSize = GET_WORD(p);
263         p += sizeof(WORD);
264         result->faceName = p;
265         p += strlen(p) + 1;
266         TRACE(" FONT %d,'%s'\n", result->pointSize, result->faceName );
267     }
268     return p;
269 }
270
271
272 /***********************************************************************
273  *           DIALOG_CreateIndirect16
274  *
275  * Creates a dialog box window
276  *
277  * modal = TRUE if we are called from a modal dialog box.
278  * (it's more compatible to do it here, as under Windows the owner
279  * is never disabled if the dialog fails because of an invalid template)
280  */
281 static HWND DIALOG_CreateIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
282                                      HWND owner, DLGPROC16 dlgProc, LPARAM param,
283                                      BOOL modal )
284 {
285     HWND hwnd;
286     RECT rect;
287     WND * wndPtr;
288     DLG_TEMPLATE template;
289     DIALOGINFO * dlgInfo;
290     BOOL ownerEnabled = TRUE;
291     DWORD exStyle = 0;
292     DWORD units = GetDialogBaseUnits();
293
294       /* Parse dialog template */
295
296     dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
297
298       /* Initialise dialog extra data */
299
300     if (!(dlgInfo = HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo) ))) return 0;
301     dlgInfo->hwndFocus   = 0;
302     dlgInfo->hUserFont   = 0;
303     dlgInfo->hMenu       = 0;
304     dlgInfo->xBaseUnit   = LOWORD(units);
305     dlgInfo->yBaseUnit   = HIWORD(units);
306     dlgInfo->idResult    = 0;
307     dlgInfo->flags       = 0;
308     dlgInfo->hDialogHeap = 0;
309
310       /* Load menu */
311
312     if (template.menuName)
313     {
314         dlgInfo->hMenu = HMENU_32(LoadMenu16( hInst, template.menuName ));
315     }
316
317       /* Create custom font if needed */
318
319     if (template.style & DS_SETFONT)
320     {
321           /* We convert the size to pixels and then make it -ve.  This works
322            * for both +ve and -ve template.pointSize */
323         HDC dc;
324         int pixels;
325         dc = GetDC(0);
326         pixels = MulDiv(template.pointSize, GetDeviceCaps(dc , LOGPIXELSY), 72);
327         ReleaseDC(0, dc);
328         dlgInfo->hUserFont = CreateFontA( -pixels, 0, 0, 0, FW_DONTCARE,
329                                           FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
330                                           PROOF_QUALITY, FF_DONTCARE, template.faceName );
331         if (dlgInfo->hUserFont)
332         {
333             SIZE charSize;
334             if (DIALOG_GetCharSize( dlgInfo->hUserFont, &charSize ))
335             {
336                 dlgInfo->xBaseUnit = charSize.cx;
337                 dlgInfo->yBaseUnit = charSize.cy;
338             }
339         }
340         TRACE("units = %d,%d\n", dlgInfo->xBaseUnit, dlgInfo->yBaseUnit );
341     }
342
343     /* Create dialog main window */
344
345     rect.left = rect.top = 0;
346     rect.right = MulDiv(template.cx, dlgInfo->xBaseUnit, 4);
347     rect.bottom =  MulDiv(template.cy, dlgInfo->yBaseUnit, 8);
348     if (template.style & DS_MODALFRAME) exStyle |= WS_EX_DLGMODALFRAME;
349     AdjustWindowRectEx( &rect, template.style, (dlgInfo->hMenu != 0), exStyle );
350     rect.right -= rect.left;
351     rect.bottom -= rect.top;
352
353     if (template.x == CW_USEDEFAULT16)
354     {
355         rect.left = rect.top = CW_USEDEFAULT16;
356     }
357     else
358     {
359         if (template.style & DS_CENTER)
360         {
361             rect.left = (GetSystemMetrics(SM_CXSCREEN) - rect.right) / 2;
362             rect.top = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / 2;
363         }
364         else
365         {
366             rect.left += MulDiv(template.x, dlgInfo->xBaseUnit, 4);
367             rect.top += MulDiv(template.y, dlgInfo->yBaseUnit, 8);
368         }
369         if ( !(template.style & WS_CHILD) )
370         {
371             INT16 dX, dY;
372
373             if( !(template.style & DS_ABSALIGN) )
374                 ClientToScreen( owner, (POINT *)&rect );
375
376             /* try to fit it into the desktop */
377
378             if( (dX = rect.left + rect.right + GetSystemMetrics(SM_CXDLGFRAME)
379                  - GetSystemMetrics(SM_CXSCREEN)) > 0 ) rect.left -= dX;
380             if( (dY = rect.top + rect.bottom + GetSystemMetrics(SM_CYDLGFRAME)
381                  - GetSystemMetrics(SM_CYSCREEN)) > 0 ) rect.top -= dY;
382             if( rect.left < 0 ) rect.left = 0;
383             if( rect.top < 0 ) rect.top = 0;
384         }
385     }
386
387     if (modal)
388     {
389         ownerEnabled = DIALOG_DisableOwner( owner );
390         if (ownerEnabled) dlgInfo->flags |= DF_OWNERENABLED;
391     }
392
393     hwnd = WIN_Handle32( CreateWindowEx16(exStyle, template.className,
394                                           template.caption, template.style & ~WS_VISIBLE,
395                                           rect.left, rect.top, rect.right, rect.bottom,
396                                           HWND_16(owner), HMENU_16(dlgInfo->hMenu),
397                                           hInst, NULL ));
398     if (!hwnd)
399     {
400         if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont );
401         if (dlgInfo->hMenu) DestroyMenu( dlgInfo->hMenu );
402         if (modal && (dlgInfo->flags & DF_OWNERENABLED)) DIALOG_EnableOwner(owner);
403         HeapFree( GetProcessHeap(), 0, dlgInfo );
404         return 0;
405     }
406     wndPtr = WIN_GetPtr( hwnd );
407     wndPtr->flags |= WIN_ISDIALOG;
408     WIN_ReleasePtr( wndPtr );
409
410     SetWindowLongW( hwnd, DWL_WINE_DIALOGINFO, (LONG)dlgInfo );
411     SetWindowLong16( HWND_16(hwnd), DWL_DLGPROC, (LONG)dlgProc );
412
413     if (dlgInfo->hUserFont)
414         SendMessageA( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
415
416     /* Create controls */
417
418     if (DIALOG_CreateControls16( hwnd, dlgTemplate, &template, hInst ))
419     {
420         HWND hwndPreInitFocus;
421
422         /* Send initialisation messages and set focus */
423
424         dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
425
426         hwndPreInitFocus = GetFocus();
427         if (SendMessageA( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ))
428         {
429             /* check where the focus is again,
430              * some controls status might have changed in WM_INITDIALOG */
431             dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
432             if( dlgInfo->hwndFocus )
433                 SetFocus( dlgInfo->hwndFocus );
434         }
435         else
436         {
437             /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
438                but the focus has not changed, set the focus where we expect it. */
439             if ((GetFocus() == hwndPreInitFocus) &&
440                 (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
441             {
442                 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
443                 if( dlgInfo->hwndFocus )
444                     SetFocus( dlgInfo->hwndFocus );
445             }
446         }
447
448         if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
449         {
450             ShowWindow( hwnd, SW_SHOWNORMAL );  /* SW_SHOW doesn't always work */
451         }
452         return hwnd;
453     }
454     if( IsWindow(hwnd) ) DestroyWindow( hwnd );
455     if (modal && ownerEnabled) DIALOG_EnableOwner(owner);
456     return 0;
457 }
458
459
460 /***********************************************************************
461  *              DialogBox (USER.87)
462  */
463 INT16 WINAPI DialogBox16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
464                           HWND16 owner, DLGPROC16 dlgProc )
465 {
466     return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
467 }
468
469
470 /**************************************************************************
471  *              EndDialog   (USER.88)
472  */
473 BOOL16 WINAPI EndDialog16( HWND16 hwnd, INT16 retval )
474 {
475     return EndDialog( WIN_Handle32(hwnd), retval );
476 }
477
478
479 /***********************************************************************
480  *              CreateDialog (USER.89)
481  */
482 HWND16 WINAPI CreateDialog16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
483                               HWND16 owner, DLGPROC16 dlgProc )
484 {
485     return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
486 }
487
488
489 /**************************************************************************
490  *              GetDlgItem   (USER.91)
491  */
492 HWND16 WINAPI GetDlgItem16( HWND16 hwndDlg, INT16 id )
493 {
494     return HWND_16( GetDlgItem( WIN_Handle32(hwndDlg), (UINT16) id ));
495 }
496
497
498 /**************************************************************************
499  *              SetDlgItemText   (USER.92)
500  */
501 void WINAPI SetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR lpString )
502 {
503     SendDlgItemMessage16( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
504 }
505
506
507 /**************************************************************************
508  *              GetDlgItemText   (USER.93)
509  */
510 INT16 WINAPI GetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR str, UINT16 len )
511 {
512     return (INT16)SendDlgItemMessage16( hwnd, id, WM_GETTEXT, len, (LPARAM)str );
513 }
514
515
516 /**************************************************************************
517  *              SetDlgItemInt   (USER.94)
518  */
519 void WINAPI SetDlgItemInt16( HWND16 hwnd, INT16 id, UINT16 value, BOOL16 fSigned )
520 {
521     SetDlgItemInt( WIN_Handle32(hwnd), (UINT)(UINT16)id,
522              (UINT)(fSigned ? (INT16) value : (UINT16) value), fSigned );
523 }
524
525
526 /**************************************************************************
527  *              GetDlgItemInt   (USER.95)
528  */
529 UINT16 WINAPI GetDlgItemInt16( HWND16 hwnd, INT16 id, BOOL16 *translated, BOOL16 fSigned )
530 {
531     UINT result;
532     BOOL ok;
533
534     if (translated) *translated = FALSE;
535     result = GetDlgItemInt( WIN_Handle32(hwnd), (UINT)(UINT16)id, &ok, fSigned );
536     if (!ok) return 0;
537     if (fSigned)
538     {
539         if (((INT)result < -32767) || ((INT)result > 32767)) return 0;
540     }
541     else
542     {
543         if (result > 65535) return 0;
544     }
545     if (translated) *translated = TRUE;
546     return (UINT16)result;
547 }
548
549
550 /**************************************************************************
551  *              CheckRadioButton   (USER.96)
552  */
553 BOOL16 WINAPI CheckRadioButton16( HWND16 hwndDlg, UINT16 firstID,
554                                   UINT16 lastID, UINT16 checkID )
555 {
556     return CheckRadioButton( WIN_Handle32(hwndDlg), firstID, lastID, checkID );
557 }
558
559
560 /**************************************************************************
561  *              CheckDlgButton   (USER.97)
562  */
563 BOOL16 WINAPI CheckDlgButton16( HWND16 hwnd, INT16 id, UINT16 check )
564 {
565     SendDlgItemMessage16( hwnd, id, BM_SETCHECK16, check, 0 );
566     return TRUE;
567 }
568
569
570 /**************************************************************************
571  *              IsDlgButtonChecked   (USER.98)
572  */
573 UINT16 WINAPI IsDlgButtonChecked16( HWND16 hwnd, UINT16 id )
574 {
575     return (UINT16)SendDlgItemMessage16( hwnd, id, BM_GETCHECK16, 0, 0 );
576 }
577
578
579 /**************************************************************************
580  *              DlgDirSelect   (USER.99)
581  */
582 BOOL16 WINAPI DlgDirSelect16( HWND16 hwnd, LPSTR str, INT16 id )
583 {
584     return DlgDirSelectEx16( hwnd, str, 128, id );
585 }
586
587
588 /**************************************************************************
589  *              DlgDirList   (USER.100)
590  */
591 INT16 WINAPI DlgDirList16( HWND16 hDlg, LPSTR spec, INT16 idLBox,
592                            INT16 idStatic, UINT16 attrib )
593 {
594     /* according to Win16 docs, DDL_DRIVES should make DDL_EXCLUSIVE
595      * be set automatically (this is different in Win32, and
596      * DIALOG_DlgDirList sends Win32 messages to the control,
597      * so do it here) */
598     if (attrib & DDL_DRIVES) attrib |= DDL_EXCLUSIVE;
599     return DlgDirListA( WIN_Handle32(hDlg), spec, idLBox, idStatic, attrib );
600 }
601
602
603 /**************************************************************************
604  *              SendDlgItemMessage   (USER.101)
605  */
606 LRESULT WINAPI SendDlgItemMessage16( HWND16 hwnd, INT16 id, UINT16 msg,
607                                      WPARAM16 wParam, LPARAM lParam )
608 {
609     HWND16 hwndCtrl = GetDlgItem16( hwnd, id );
610     if (hwndCtrl) return SendMessage16( hwndCtrl, msg, wParam, lParam );
611     else return 0;
612 }
613
614
615 /**************************************************************************
616  *              MapDialogRect   (USER.103)
617  */
618 void WINAPI MapDialogRect16( HWND16 hwnd, LPRECT16 rect )
619 {
620     RECT rect32;
621     MapDialogRect( WIN_Handle32(hwnd), &rect32 );
622     rect->left   = rect32.left;
623     rect->right  = rect32.right;
624     rect->top    = rect32.top;
625     rect->bottom = rect32.bottom;
626 }
627
628
629 /**************************************************************************
630  *              DlgDirSelectComboBox   (USER.194)
631  */
632 BOOL16 WINAPI DlgDirSelectComboBox16( HWND16 hwnd, LPSTR str, INT16 id )
633 {
634     return DlgDirSelectComboBoxEx16( hwnd, str, 128, id );
635 }
636
637
638 /**************************************************************************
639  *              DlgDirListComboBox   (USER.195)
640  */
641 INT16 WINAPI DlgDirListComboBox16( HWND16 hDlg, LPSTR spec, INT16 idCBox,
642                                    INT16 idStatic, UINT16 attrib )
643 {
644     return DlgDirListComboBoxA( WIN_Handle32(hDlg), spec, idCBox, idStatic, attrib );
645 }
646
647
648 /***********************************************************************
649  *              DialogBoxIndirect (USER.218)
650  */
651 INT16 WINAPI DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
652                                   HWND16 owner, DLGPROC16 dlgProc )
653 {
654     return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
655 }
656
657
658 /***********************************************************************
659  *              CreateDialogIndirect (USER.219)
660  */
661 HWND16 WINAPI CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
662                                       HWND16 owner, DLGPROC16 dlgProc )
663 {
664     return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
665 }
666
667
668 /**************************************************************************
669  *              GetNextDlgGroupItem   (USER.227)
670  */
671 HWND16 WINAPI GetNextDlgGroupItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
672                                      BOOL16 fPrevious )
673 {
674     return HWND_16( GetNextDlgGroupItem( WIN_Handle32(hwndDlg), WIN_Handle32(hwndCtrl), fPrevious ));
675 }
676
677
678 /**************************************************************************
679  *              GetNextDlgTabItem   (USER.228)
680  */
681 HWND16 WINAPI GetNextDlgTabItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
682                                    BOOL16 fPrevious )
683 {
684     return HWND_16( GetNextDlgTabItem( WIN_Handle32(hwndDlg), WIN_Handle32(hwndCtrl), fPrevious ));
685 }
686
687
688 /***********************************************************************
689  *              DialogBoxParam (USER.239)
690  */
691 INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, LPCSTR template,
692                                HWND16 owner16, DLGPROC16 dlgProc, LPARAM param )
693 {
694     HWND hwnd = 0;
695     HRSRC16 hRsrc;
696     HGLOBAL16 hmem;
697     LPCVOID data;
698     int ret = -1;
699
700     if (!(hRsrc = FindResource16( hInst, template, RT_DIALOGA ))) return 0;
701     if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
702     if ((data = LockResource16( hmem )))
703     {
704         HWND owner = WIN_Handle32(owner16);
705         hwnd = DIALOG_CreateIndirect16( hInst, data, owner, dlgProc, param, TRUE );
706         if (hwnd) ret = DIALOG_DoDialogBox( hwnd, owner );
707         GlobalUnlock16( hmem );
708     }
709     FreeResource16( hmem );
710     return ret;
711 }
712
713
714 /***********************************************************************
715  *              DialogBoxIndirectParam (USER.240)
716  */
717 INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
718                                        HWND16 owner16, DLGPROC16 dlgProc, LPARAM param )
719 {
720     HWND hwnd, owner = WIN_Handle32( owner16 );
721     LPCVOID ptr;
722
723     if (!(ptr = GlobalLock16( dlgTemplate ))) return -1;
724     hwnd = DIALOG_CreateIndirect16( hInst, ptr, owner, dlgProc, param, TRUE );
725     GlobalUnlock16( dlgTemplate );
726     if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
727     return -1;
728 }
729
730
731 /***********************************************************************
732  *              CreateDialogParam (USER.241)
733  */
734 HWND16 WINAPI CreateDialogParam16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
735                                    HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
736 {
737     HWND16 hwnd = 0;
738     HRSRC16 hRsrc;
739     HGLOBAL16 hmem;
740     LPCVOID data;
741
742     TRACE("%04x,%s,%04x,%08lx,%ld\n",
743           hInst, debugstr_a(dlgTemplate), owner, (DWORD)dlgProc, param );
744
745     if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOGA ))) return 0;
746     if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
747     if (!(data = LockResource16( hmem ))) hwnd = 0;
748     else hwnd = CreateDialogIndirectParam16( hInst, data, owner, dlgProc, param );
749     FreeResource16( hmem );
750     return hwnd;
751 }
752
753
754 /***********************************************************************
755  *              CreateDialogIndirectParam (USER.242)
756  */
757 HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
758                                            HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
759 {
760     if (!dlgTemplate) return 0;
761     return HWND_16( DIALOG_CreateIndirect16( hInst, dlgTemplate, WIN_Handle32(owner),
762                                              dlgProc, param, FALSE ));
763 }
764
765
766 /**************************************************************************
767  *              DlgDirSelectEx   (USER.422)
768  */
769 BOOL16 WINAPI DlgDirSelectEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id )
770 {
771     return DlgDirSelectExA( WIN_Handle32(hwnd), str, len, id );
772 }
773
774
775 /**************************************************************************
776  *              DlgDirSelectComboBoxEx   (USER.423)
777  */
778 BOOL16 WINAPI DlgDirSelectComboBoxEx16( HWND16 hwnd, LPSTR str, INT16 len,
779                                         INT16 id )
780 {
781     return DlgDirSelectComboBoxExA( WIN_Handle32(hwnd), str, len, id );
782 }