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