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