Release 20030408.
[wine/gsoc-2012-control.git] / dlls / user / dialog16.c
blobc0d6b2c2144457ced453f3c9ea38727e050f7447
1 /*
2 * 16-bit dialog functions
4 * Copyright 1993, 1994, 1996, 2003 Alexandre Julliard
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.
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.
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
21 #include "config.h"
22 #include "wine/port.h"
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"
32 WINE_DEFAULT_DEBUG_CHANNEL(dialog);
34 /* Dialog control information */
35 typedef struct
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;
48 /* Dialog template */
49 typedef struct
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;
65 /***********************************************************************
66 * DIALOG_GetControl16
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.
71 static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info )
73 static char buffer[10];
74 int int_id;
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);
83 if (*p & 0x80)
85 switch((BYTE)*p)
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;
95 info->className = buffer;
96 p++;
98 else
100 info->className = p;
101 p += strlen(p) + 1;
104 int_id = ((BYTE)*p == 0xff);
105 if (int_id)
107 /* Integer id, not documented (?). Only works for SS_ICON controls */
108 info->windowName = (LPCSTR)(UINT)GET_WORD(p+1);
109 p += 3;
111 else
113 info->windowName = p;
114 p += strlen(p) + 1;
117 if (*p) info->data = p + 1;
118 else info->data = NULL;
120 p += *p + 1;
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 );
127 return p;
131 /***********************************************************************
132 * DIALOG_CreateControls16
134 * Create the control windows for a dialog.
136 static BOOL DIALOG_CreateControls16( HWND hwnd, LPCSTR template,
137 const DLG_TEMPLATE *dlgTemplate, HINSTANCE16 hInst )
139 DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd );
140 DLG_CONTROL_INFO info;
141 HWND hwndCtrl, hwndDefButton = 0;
142 INT items = dlgTemplate->nbItems;
144 TRACE(" BEGIN\n" );
145 while (items--)
147 HINSTANCE16 instance = hInst;
148 SEGPTR segptr;
150 template = DIALOG_GetControl16( template, &info );
151 if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
152 !(GetWindowLongW( hwnd, GWL_STYLE ) & DS_LOCALEDIT))
154 if (!dlgInfo->hDialogHeap)
156 dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000);
157 if (!dlgInfo->hDialogHeap)
159 ERR("Insufficient memory to create heap for edit control\n" );
160 continue;
162 LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff);
164 instance = dlgInfo->hDialogHeap;
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 );
179 if (!hwndCtrl) return FALSE;
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)
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 );
195 TRACE(" END\n" );
196 return TRUE;
200 /***********************************************************************
201 * DIALOG_ParseTemplate16
203 * Fill a DLG_TEMPLATE structure from the dialog template, and return
204 * a pointer to the first control.
206 static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result )
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);
215 TRACE("DIALOG %d, %d, %d, %d\n", result->x, result->y, result->cx, result->cy );
216 TRACE(" STYLE %08lx\n", result->style );
218 /* Get the menu name */
220 switch( (BYTE)*p )
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;
238 /* Get the class name */
240 if (*p)
242 result->className = p;
243 TRACE(" CLASS '%s'\n", result->className );
245 else result->className = DIALOG_CLASS_ATOMA;
246 p += strlen(p) + 1;
248 /* Get the window caption */
250 result->caption = p;
251 p += strlen(p) + 1;
252 TRACE(" CAPTION '%s'\n", result->caption );
254 /* Get the font name */
256 if (result->style & DS_SETFONT)
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 );
264 return p;
268 /***********************************************************************
269 * DIALOG_CreateIndirect16
271 * Creates a dialog box window
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)
277 static HWND DIALOG_CreateIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
278 HWND owner, DLGPROC16 dlgProc, LPARAM param,
279 BOOL modal )
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();
290 /* Parse dialog template */
292 dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
294 /* Initialise dialog extra data */
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;
306 /* Load menu */
308 if (template.menuName)
310 dlgInfo->hMenu = HMENU_32(LoadMenu16( hInst, template.menuName ));
313 /* Create custom font if needed */
315 if (template.style & DS_SETFONT)
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)
329 SIZE charSize;
330 if (DIALOG_GetCharSize( dlgInfo->hUserFont, &charSize ))
332 dlgInfo->xBaseUnit = charSize.cx;
333 dlgInfo->yBaseUnit = charSize.cy;
336 TRACE("units = %d,%d\n", dlgInfo->xBaseUnit, dlgInfo->yBaseUnit );
339 /* Create dialog main window */
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;
349 if (template.x == CW_USEDEFAULT16)
351 rect.left = rect.top = CW_USEDEFAULT16;
353 else
355 if (template.style & DS_CENTER)
357 rect.left = (GetSystemMetrics(SM_CXSCREEN) - rect.right) / 2;
358 rect.top = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / 2;
360 else
362 rect.left += MulDiv(template.x, dlgInfo->xBaseUnit, 4);
363 rect.top += MulDiv(template.y, dlgInfo->yBaseUnit, 8);
365 if ( !(template.style & WS_CHILD) )
367 INT16 dX, dY;
369 if( !(template.style & DS_ABSALIGN) )
370 ClientToScreen( owner, (POINT *)&rect );
372 /* try to fit it into the desktop */
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;
383 if (modal)
385 ownerEnabled = DIALOG_DisableOwner( owner );
386 if (ownerEnabled) dlgInfo->flags |= DF_OWNERENABLED;
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)
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;
402 wndPtr = WIN_GetPtr( hwnd );
403 wndPtr->flags |= WIN_ISDIALOG;
404 WIN_ReleasePtr( wndPtr );
406 SetWindowLongW( hwnd, DWL_WINE_DIALOGINFO, (LONG)dlgInfo );
407 SetWindowLong16( HWND_16(hwnd), DWL_DLGPROC, (LONG)dlgProc );
409 if (dlgInfo->hUserFont)
410 SendMessageA( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
412 /* Create controls */
414 if (DIALOG_CreateControls16( hwnd, dlgTemplate, &template, hInst ))
416 HWND hwndPreInitFocus;
418 /* Send initialisation messages and set focus */
420 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
422 hwndPreInitFocus = GetFocus();
423 if (SendMessageA( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ))
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 );
431 else
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))
438 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
439 if( dlgInfo->hwndFocus )
440 SetFocus( dlgInfo->hwndFocus );
444 if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
446 ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
448 return hwnd;
450 if( IsWindow(hwnd) ) DestroyWindow( hwnd );
451 if (modal && ownerEnabled) DIALOG_EnableOwner(owner);
452 return 0;
456 /***********************************************************************
457 * DialogBox (USER.87)
459 INT16 WINAPI DialogBox16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
460 HWND16 owner, DLGPROC16 dlgProc )
462 return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
466 /**************************************************************************
467 * EndDialog (USER.88)
469 BOOL16 WINAPI EndDialog16( HWND16 hwnd, INT16 retval )
471 return EndDialog( WIN_Handle32(hwnd), retval );
475 /***********************************************************************
476 * CreateDialog (USER.89)
478 HWND16 WINAPI CreateDialog16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
479 HWND16 owner, DLGPROC16 dlgProc )
481 return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
485 /**************************************************************************
486 * GetDlgItem (USER.91)
488 HWND16 WINAPI GetDlgItem16( HWND16 hwndDlg, INT16 id )
490 return HWND_16( GetDlgItem( WIN_Handle32(hwndDlg), (UINT16) id ));
494 /**************************************************************************
495 * SetDlgItemText (USER.92)
497 void WINAPI SetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR lpString )
499 SendDlgItemMessage16( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
503 /**************************************************************************
504 * GetDlgItemText (USER.93)
506 INT16 WINAPI GetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR str, UINT16 len )
508 return (INT16)SendDlgItemMessage16( hwnd, id, WM_GETTEXT, len, (LPARAM)str );
512 /**************************************************************************
513 * SetDlgItemInt (USER.94)
515 void WINAPI SetDlgItemInt16( HWND16 hwnd, INT16 id, UINT16 value, BOOL16 fSigned )
517 SetDlgItemInt( WIN_Handle32(hwnd), (UINT)(UINT16)id,
518 (UINT)(fSigned ? (INT16) value : (UINT16) value), fSigned );
522 /**************************************************************************
523 * GetDlgItemInt (USER.95)
525 UINT16 WINAPI GetDlgItemInt16( HWND16 hwnd, INT16 id, BOOL16 *translated, BOOL16 fSigned )
527 UINT result;
528 BOOL ok;
530 if (translated) *translated = FALSE;
531 result = GetDlgItemInt( WIN_Handle32(hwnd), (UINT)(UINT16)id, &ok, fSigned );
532 if (!ok) return 0;
533 if (fSigned)
535 if (((INT)result < -32767) || ((INT)result > 32767)) return 0;
537 else
539 if (result > 65535) return 0;
541 if (translated) *translated = TRUE;
542 return (UINT16)result;
546 /**************************************************************************
547 * CheckRadioButton (USER.96)
549 BOOL16 WINAPI CheckRadioButton16( HWND16 hwndDlg, UINT16 firstID,
550 UINT16 lastID, UINT16 checkID )
552 return CheckRadioButton( WIN_Handle32(hwndDlg), firstID, lastID, checkID );
556 /**************************************************************************
557 * CheckDlgButton (USER.97)
559 BOOL16 WINAPI CheckDlgButton16( HWND16 hwnd, INT16 id, UINT16 check )
561 SendDlgItemMessage16( hwnd, id, BM_SETCHECK16, check, 0 );
562 return TRUE;
566 /**************************************************************************
567 * IsDlgButtonChecked (USER.98)
569 UINT16 WINAPI IsDlgButtonChecked16( HWND16 hwnd, UINT16 id )
571 return (UINT16)SendDlgItemMessage16( hwnd, id, BM_GETCHECK16, 0, 0 );
575 /**************************************************************************
576 * DlgDirSelect (USER.99)
578 BOOL16 WINAPI DlgDirSelect16( HWND16 hwnd, LPSTR str, INT16 id )
580 return DlgDirSelectEx16( hwnd, str, 128, id );
584 /**************************************************************************
585 * DlgDirList (USER.100)
587 INT16 WINAPI DlgDirList16( HWND16 hDlg, LPSTR spec, INT16 idLBox,
588 INT16 idStatic, UINT16 attrib )
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 );
599 /**************************************************************************
600 * SendDlgItemMessage (USER.101)
602 LRESULT WINAPI SendDlgItemMessage16( HWND16 hwnd, INT16 id, UINT16 msg,
603 WPARAM16 wParam, LPARAM lParam )
605 HWND16 hwndCtrl = GetDlgItem16( hwnd, id );
606 if (hwndCtrl) return SendMessage16( hwndCtrl, msg, wParam, lParam );
607 else return 0;
611 /**************************************************************************
612 * MapDialogRect (USER.103)
614 void WINAPI MapDialogRect16( HWND16 hwnd, LPRECT16 rect )
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;
625 /**************************************************************************
626 * DlgDirSelectComboBox (USER.194)
628 BOOL16 WINAPI DlgDirSelectComboBox16( HWND16 hwnd, LPSTR str, INT16 id )
630 return DlgDirSelectComboBoxEx16( hwnd, str, 128, id );
634 /**************************************************************************
635 * DlgDirListComboBox (USER.195)
637 INT16 WINAPI DlgDirListComboBox16( HWND16 hDlg, LPSTR spec, INT16 idCBox,
638 INT16 idStatic, UINT16 attrib )
640 return DlgDirListComboBoxA( WIN_Handle32(hDlg), spec, idCBox, idStatic, attrib );
644 /***********************************************************************
645 * DialogBoxIndirect (USER.218)
647 INT16 WINAPI DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
648 HWND16 owner, DLGPROC16 dlgProc )
650 return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
654 /***********************************************************************
655 * CreateDialogIndirect (USER.219)
657 HWND16 WINAPI CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
658 HWND16 owner, DLGPROC16 dlgProc )
660 return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
664 /**************************************************************************
665 * GetNextDlgGroupItem (USER.227)
667 HWND16 WINAPI GetNextDlgGroupItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
668 BOOL16 fPrevious )
670 return HWND_16( GetNextDlgGroupItem( WIN_Handle32(hwndDlg), WIN_Handle32(hwndCtrl), fPrevious ));
674 /**************************************************************************
675 * GetNextDlgTabItem (USER.228)
677 HWND16 WINAPI GetNextDlgTabItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
678 BOOL16 fPrevious )
680 return HWND_16( GetNextDlgTabItem( WIN_Handle32(hwndDlg), WIN_Handle32(hwndCtrl), fPrevious ));
684 /***********************************************************************
685 * DialogBoxParam (USER.239)
687 INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, LPCSTR template,
688 HWND16 owner16, DLGPROC16 dlgProc, LPARAM param )
690 HWND hwnd = 0;
691 HRSRC16 hRsrc;
692 HGLOBAL16 hmem;
693 LPCVOID data;
694 int ret = -1;
696 if (!(hRsrc = FindResource16( hInst, template, RT_DIALOGA ))) return 0;
697 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
698 if ((data = LockResource16( hmem )))
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 );
705 FreeResource16( hmem );
706 return ret;
710 /***********************************************************************
711 * DialogBoxIndirectParam (USER.240)
713 INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
714 HWND16 owner16, DLGPROC16 dlgProc, LPARAM param )
716 HWND hwnd, owner = WIN_Handle32( owner16 );
717 LPCVOID ptr;
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;
727 /***********************************************************************
728 * CreateDialogParam (USER.241)
730 HWND16 WINAPI CreateDialogParam16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
731 HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
733 HWND16 hwnd = 0;
734 HRSRC16 hRsrc;
735 HGLOBAL16 hmem;
736 LPCVOID data;
738 TRACE("%04x,%s,%04x,%08lx,%ld\n",
739 hInst, debugstr_a(dlgTemplate), owner, (DWORD)dlgProc, param );
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;
750 /***********************************************************************
751 * CreateDialogIndirectParam (USER.242)
753 HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
754 HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
756 if (!dlgTemplate) return 0;
757 return HWND_16( DIALOG_CreateIndirect16( hInst, dlgTemplate, WIN_Handle32(owner),
758 dlgProc, param, FALSE ));
762 /**************************************************************************
763 * DlgDirSelectEx (USER.422)
765 BOOL16 WINAPI DlgDirSelectEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id )
767 return DlgDirSelectExA( WIN_Handle32(hwnd), str, len, id );
771 /**************************************************************************
772 * DlgDirSelectComboBoxEx (USER.423)
774 BOOL16 WINAPI DlgDirSelectComboBoxEx16( HWND16 hwnd, LPSTR str, INT16 len,
775 INT16 id )
777 return DlgDirSelectComboBoxExA( WIN_Handle32(hwnd), str, len, id );