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