4 * Copyright 1993, 1994, 1996 Alexandre Julliard
23 #include "sysmetrics.h"
28 /* Dialog control information */
60 /* Dialog base units */
61 static WORD xBaseUnit = 0, yBaseUnit = 0;
64 /***********************************************************************
67 * Initialisation of the dialog manager.
74 /* Calculate the dialog base units */
76 if (!(hdc = CreateDC16( "DISPLAY", NULL, NULL, NULL ))) return FALSE;
77 GetTextMetrics16( hdc, &tm );
79 xBaseUnit = tm.tmAveCharWidth;
80 yBaseUnit = tm.tmHeight;
82 /* Dialog units are based on a proportional system font */
83 /* so we adjust them a bit for a fixed font. */
84 if (!(tm.tmPitchAndFamily & TMPF_FIXED_PITCH))
85 xBaseUnit = xBaseUnit * 5 / 4;
87 dprintf_dialog( stddeb, "DIALOG_Init: base units = %d,%d\n",
88 xBaseUnit, yBaseUnit );
93 /***********************************************************************
96 * Return the class and text of the control pointed to by ptr,
97 * fill the header structure and return a pointer to the next control.
99 static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info )
101 static char buffer[10];
103 info->x = GET_WORD(p); p += sizeof(WORD);
104 info->y = GET_WORD(p); p += sizeof(WORD);
105 info->cx = GET_WORD(p); p += sizeof(WORD);
106 info->cy = GET_WORD(p); p += sizeof(WORD);
107 info->id = GET_WORD(p); p += sizeof(WORD);
108 info->style = GET_DWORD(p); p += sizeof(DWORD);
115 case 0x80: strcpy( buffer, "BUTTON" ); break;
116 case 0x81: strcpy( buffer, "EDIT" ); break;
117 case 0x82: strcpy( buffer, "STATIC" ); break;
118 case 0x83: strcpy( buffer, "LISTBOX" ); break;
119 case 0x84: strcpy( buffer, "SCROLLBAR" ); break;
120 case 0x85: strcpy( buffer, "COMBOBOX" ); break;
121 default: buffer[0] = '\0'; break;
123 info->className = buffer;
131 dprintf_dialog(stddeb, " %s ", info->className );
133 if ((BYTE)*p == 0xff)
135 /* Integer id, not documented (?). Only works for SS_ICON controls */
136 info->windowName = (LPCSTR)(UINT32)GET_WORD(p+1);
138 dprintf_dialog( stddeb,"%04x", LOWORD(info->windowName) );
142 info->windowName = p;
144 dprintf_dialog(stddeb,"'%s'", info->windowName );
147 info->data = (LPVOID)(*p ? p + 1 : NULL); /* FIXME: should be a segptr */
150 dprintf_dialog( stddeb," %d, %d, %d, %d, %d, %08lx, %08lx\n",
151 info->id, info->x, info->y, info->cx, info->cy,
152 info->style, (DWORD)info->data);
157 /***********************************************************************
158 * DIALOG_GetControl32
160 * Return the class and text of the control pointed to by ptr,
161 * fill the header structure and return a pointer to the next control.
163 static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info )
165 static WCHAR buffer[10];
167 info->style = GET_DWORD(p); p += 2;
168 info->exStyle = GET_DWORD(p); p += 2;
169 info->x = GET_WORD(p); p++;
170 info->y = GET_WORD(p); p++;
171 info->cx = GET_WORD(p); p++;
172 info->cy = GET_WORD(p); p++;
173 info->id = GET_WORD(p); p++;
175 if (GET_WORD(p) == 0xffff)
177 switch(GET_WORD(p+1))
179 case 0x80: lstrcpyAtoW( buffer, "Button" ); break;
180 case 0x81: lstrcpyAtoW( buffer, "Edit" ); break;
181 case 0x82: lstrcpyAtoW( buffer, "Static" ); break;
182 case 0x83: lstrcpyAtoW( buffer, "ListBox" ); break;
183 case 0x84: lstrcpyAtoW( buffer, "ScrollBar" ); break;
184 case 0x85: lstrcpyAtoW( buffer, "ComboBox" ); break;
185 default: buffer[0] = '\0'; break;
187 info->className = (LPCSTR)buffer;
192 info->className = (LPCSTR)p;
193 p += lstrlen32W( (LPCWSTR)p ) + 1;
195 dprintf_dialog(stddeb, " %p ", info->className );
197 if (GET_WORD(p) == 0xffff)
199 info->windowName = (LPCSTR)(p + 1);
201 dprintf_dialog( stddeb,"%04x", LOWORD(info->windowName) );
205 info->windowName = (LPCSTR)p;
206 p += lstrlen32W( (LPCWSTR)p ) + 1;
207 dprintf_dialog(stddeb,"'%p'", info->windowName );
212 info->data = (LPVOID)(p + 1);
213 p += GET_WORD(p) / sizeof(WORD);
215 else info->data = NULL;
218 dprintf_dialog( stddeb," %d, %d, %d, %d, %d, %08lx, %08lx, %08lx\n",
219 info->id, info->x, info->y, info->cx, info->cy,
220 info->style, info->exStyle, (DWORD)info->data);
221 /* Next control is on dword boundary */
222 return (const WORD *)((((int)p) + 3) & ~3);
226 /***********************************************************************
227 * DIALOG_CreateControls
229 * Create the control windows for a dialog.
231 static BOOL32 DIALOG_CreateControls( WND *pWnd, LPCSTR template, INT32 items,
232 HINSTANCE32 hInst, BOOL32 win32 )
234 DIALOGINFO *dlgInfo = (DIALOGINFO *)pWnd->wExtra;
235 DLG_CONTROL_INFO info;
236 HWND32 hwndCtrl, hwndDefButton = 0;
238 dprintf_dialog(stddeb, " BEGIN\n" );
243 HINSTANCE16 instance;
244 template = DIALOG_GetControl16( template, &info );
245 if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
246 ((pWnd->dwStyle & DS_LOCALEDIT) != DS_LOCALEDIT))
248 if (!dlgInfo->hDialogHeap)
250 dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000);
251 if (!dlgInfo->hDialogHeap)
253 fprintf( stderr, "CreateDialogIndirectParam: Insufficient memory to create heap for edit control\n" );
256 LocalInit(dlgInfo->hDialogHeap, 0, 0xffff);
258 instance = dlgInfo->hDialogHeap;
260 else instance = (HINSTANCE16)hInst;
262 hwndCtrl = CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY,
263 info.className, info.windowName,
264 info.style | WS_CHILD,
265 info.x * dlgInfo->xBaseUnit / 4,
266 info.y * dlgInfo->yBaseUnit / 8,
267 info.cx * dlgInfo->xBaseUnit / 4,
268 info.cy * dlgInfo->yBaseUnit / 8,
269 pWnd->hwndSelf, (HMENU16)info.id,
270 instance, info.data );
274 template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info );
275 hwndCtrl = CreateWindowEx32W( info.exStyle | WS_EX_NOPARENTNOTIFY,
276 (LPCWSTR)info.className,
277 (LPCWSTR)info.windowName,
278 info.style | WS_CHILD,
279 info.x * dlgInfo->xBaseUnit / 4,
280 info.y * dlgInfo->yBaseUnit / 8,
281 info.cx * dlgInfo->xBaseUnit / 4,
282 info.cy * dlgInfo->yBaseUnit / 8,
283 pWnd->hwndSelf, (HMENU32)info.id,
286 if (!hwndCtrl) return FALSE;
288 /* Send initialisation messages to the control */
289 if (dlgInfo->hUserFont) SendMessage32A( hwndCtrl, WM_SETFONT,
290 (WPARAM32)dlgInfo->hUserFont, 0 );
291 if (SendMessage32A(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
293 /* If there's already a default push-button, set it back */
294 /* to normal and use this one instead. */
296 SendMessage32A( hwndDefButton, BM_SETSTYLE32,
297 BS_PUSHBUTTON,FALSE );
298 hwndDefButton = hwndCtrl;
299 dlgInfo->idResult = GetWindowWord32( hwndCtrl, GWW_ID );
302 dprintf_dialog(stddeb, " END\n" );
307 /***********************************************************************
308 * DIALOG_ParseTemplate16
310 * Fill a DLG_TEMPLATE structure from the dialog template, and return
311 * a pointer to the first control.
313 static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result )
315 result->style = GET_DWORD(p); p += sizeof(DWORD);
317 result->nbItems = *p++;
318 result->x = GET_WORD(p); p += sizeof(WORD);
319 result->y = GET_WORD(p); p += sizeof(WORD);
320 result->cx = GET_WORD(p); p += sizeof(WORD);
321 result->cy = GET_WORD(p); p += sizeof(WORD);
322 dprintf_dialog( stddeb, "DIALOG %d, %d, %d, %d\n",
323 result->x, result->y, result->cx, result->cy );
324 dprintf_dialog( stddeb, " STYLE %08lx\n", result->style );
326 /* Get the menu name */
331 result->menuName = 0;
335 result->menuName = (LPCSTR)(UINT32)GET_WORD( p + 1 );
337 dprintf_dialog(stddeb, " MENU %04x\n", LOWORD(result->menuName) );
340 result->menuName = p;
341 dprintf_dialog( stddeb, " MENU '%s'\n", p );
346 /* Get the class name */
350 result->className = p;
351 dprintf_dialog( stddeb, " CLASS '%s'\n", result->className );
353 else result->className = DIALOG_CLASS_ATOM;
356 /* Get the window caption */
360 dprintf_dialog( stddeb, " CAPTION '%s'\n", result->caption );
362 /* Get the font name */
364 if (result->style & DS_SETFONT)
366 result->pointSize = GET_WORD(p);
368 result->faceName = p;
370 dprintf_dialog( stddeb, " FONT %d,'%s'\n",
371 result->pointSize, result->faceName );
377 /***********************************************************************
378 * DIALOG_ParseTemplate32
380 * Fill a DLG_TEMPLATE structure from the dialog template, and return
381 * a pointer to the first control.
383 static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result )
385 const WORD *p = (const WORD *)template;
387 result->style = GET_DWORD(p); p += 2;
388 result->exStyle = GET_DWORD(p); p += 2;
389 result->nbItems = GET_WORD(p); p++;
390 result->x = GET_WORD(p); p++;
391 result->y = GET_WORD(p); p++;
392 result->cx = GET_WORD(p); p++;
393 result->cy = GET_WORD(p); p++;
394 dprintf_dialog( stddeb, "DIALOG %d, %d, %d, %d\n",
395 result->x, result->y, result->cx, result->cy );
396 dprintf_dialog( stddeb, " STYLE %08lx\n", result->style );
397 dprintf_dialog( stddeb, " EXSTYLE %08lx\n", result->exStyle );
399 /* Get the menu name */
404 result->menuName = NULL;
408 result->menuName = (LPCSTR)(UINT32)GET_WORD( p + 1 );
410 dprintf_dialog(stddeb, " MENU %04x\n", LOWORD(result->menuName) );
413 result->menuName = (LPCSTR)p;
414 dprintf_dialog( stddeb, " MENU '%p'\n", p );
415 p += lstrlen32W( (LPCWSTR)p ) + 1;
419 /* Get the class name */
424 result->className = DIALOG_CLASS_ATOM;
428 result->className = (LPCSTR)(UINT32)GET_WORD( p + 1 );
430 dprintf_dialog(stddeb, " CLASS %04x\n", LOWORD(result->className) );
433 result->className = (LPCSTR)p;
434 dprintf_dialog( stddeb, " CLASS '%p'\n", p );
435 p += lstrlen32W( (LPCWSTR)p ) + 1;
439 /* Get the window caption */
441 result->caption = (LPCSTR)p;
442 p += lstrlen32W( (LPCWSTR)p ) + 1;
443 dprintf_dialog( stddeb, " CAPTION '%p'\n", result->caption );
445 /* Get the font name */
447 if (result->style & DS_SETFONT)
449 result->pointSize = GET_WORD(p);
451 result->faceName = (LPCSTR)p;
452 p += lstrlen32W( (LPCWSTR)p ) + 1;
453 dprintf_dialog( stddeb, " FONT %d,'%p'\n",
454 result->pointSize, result->faceName );
456 /* First control is on dword boundary */
457 return (LPCSTR)((((int)p) + 3) & ~3);
461 /***********************************************************************
462 * DIALOG_CreateIndirect
464 HWND32 DIALOG_CreateIndirect( HINSTANCE32 hInst, LPCSTR dlgTemplate,
465 BOOL32 win32Template, HWND32 owner,
466 DLGPROC16 dlgProc, LPARAM param,
467 WINDOWPROCTYPE procType )
474 DLG_TEMPLATE template;
475 DIALOGINFO * dlgInfo;
476 WORD xUnit = xBaseUnit;
477 WORD yUnit = yBaseUnit;
479 /* Parse dialog template */
481 if (!dlgTemplate) return 0;
483 dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template );
485 dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
489 if (template.menuName)
491 LPSTR str = SEGPTR_STRDUP( template.menuName ); /* FIXME: win32 */
492 hMenu = LoadMenu16( hInst, SEGPTR_GET(str) );
496 /* Create custom font if needed */
498 if (template.style & DS_SETFONT)
500 /* The font height must be negative as it is a point size */
501 /* (see CreateFont() documentation in the Windows SDK). */
502 hFont = CreateFont16( -template.pointSize, 0, 0, 0, FW_DONTCARE,
503 FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
504 DEFAULT_QUALITY, FF_DONTCARE,
505 template.faceName ); /* FIXME: win32 */
511 HDC32 hdc = GetDC32(0);
512 oldFont = SelectObject32( hdc, hFont );
513 GetTextMetrics16( hdc, &tm );
514 SelectObject32( hdc, oldFont );
515 ReleaseDC32( 0, hdc );
516 xUnit = tm.tmAveCharWidth;
518 if (!(tm.tmPitchAndFamily & TMPF_FIXED_PITCH))
519 xBaseUnit = xBaseUnit * 5 / 4; /* See DIALOG_Init() */
523 /* Create dialog main window */
525 rect.left = rect.top = 0;
526 rect.right = template.cx * xUnit / 4;
527 rect.bottom = template.cy * yUnit / 8;
528 if (template.style & DS_MODALFRAME)
529 template.exStyle |= WS_EX_DLGMODALFRAME;
530 AdjustWindowRectEx32( &rect, template.style,
531 hMenu ? TRUE : FALSE , template.exStyle );
532 rect.right -= rect.left;
533 rect.bottom -= rect.top;
535 if ((INT16)template.x == CW_USEDEFAULT16)
537 rect.left = rect.top = (procType == WIN_PROC_16) ? CW_USEDEFAULT16
542 rect.left += template.x * xUnit / 4;
543 rect.top += template.y * yUnit / 8;
544 if ( !(template.style & WS_CHILD) )
548 if( !(template.style & DS_ABSALIGN) )
549 ClientToScreen32( owner, (POINT32 *)&rect );
551 /* try to fit it into the desktop */
553 if( (dX = rect.left + rect.right + SYSMETRICS_CXDLGFRAME
554 - SYSMETRICS_CXSCREEN) > 0 ) rect.left -= dX;
555 if( (dY = rect.top + rect.bottom + SYSMETRICS_CYDLGFRAME
556 - SYSMETRICS_CYSCREEN) > 0 ) rect.top -= dY;
557 if( rect.left < 0 ) rect.left = 0;
558 if( rect.top < 0 ) rect.top = 0;
562 if (procType != WIN_PROC_16)
563 hwnd = CreateWindowEx32W(template.exStyle, (LPCWSTR)template.className,
564 (LPCWSTR)template.caption,
565 template.style & ~WS_VISIBLE,
566 rect.left, rect.top, rect.right, rect.bottom,
567 owner, hMenu, hInst, NULL );
569 hwnd = CreateWindowEx16(template.exStyle, template.className,
570 template.caption, template.style & ~WS_VISIBLE,
571 rect.left, rect.top, rect.right, rect.bottom,
572 owner, hMenu, hInst, NULL );
575 if (hFont) DeleteObject32( hFont );
576 if (hMenu) DestroyMenu32( hMenu );
579 wndPtr = WIN_FindWndPtr( hwnd );
580 wndPtr->flags |= WIN_ISDIALOG;
582 /* Initialise dialog extra data */
584 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
585 WINPROC_SetProc( &dlgInfo->dlgProc, dlgProc, procType, WIN_PROC_WINDOW );
586 dlgInfo->hUserFont = hFont;
587 dlgInfo->hMenu = hMenu;
588 dlgInfo->xBaseUnit = xUnit;
589 dlgInfo->yBaseUnit = yUnit;
590 dlgInfo->msgResult = 0;
591 dlgInfo->idResult = 0;
593 dlgInfo->hDialogHeap = 0;
595 if (dlgInfo->hUserFont)
596 SendMessage32A( hwnd, WM_SETFONT, (WPARAM32)dlgInfo->hUserFont, 0 );
598 /* Create controls */
600 if (DIALOG_CreateControls( wndPtr, dlgTemplate, template.nbItems,
601 hInst, win32Template ))
603 /* Send initialisation messages and set focus */
605 dlgInfo->hwndFocus = GetNextDlgTabItem32( hwnd, 0, FALSE );
606 if (SendMessage32A( hwnd, WM_INITDIALOG,
607 (WPARAM32)dlgInfo->hwndFocus, param ))
608 SetFocus32( dlgInfo->hwndFocus );
609 if (template.style & WS_VISIBLE) ShowWindow32( hwnd, SW_SHOW );
613 if( IsWindow32(hwnd) ) DestroyWindow32( hwnd );
618 /***********************************************************************
619 * CreateDialog16 (USER.89)
621 HWND16 CreateDialog16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
622 HWND16 owner, DLGPROC16 dlgProc )
624 return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
628 /***********************************************************************
629 * CreateDialogParam16 (USER.241)
631 HWND16 CreateDialogParam16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
632 HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
639 dprintf_dialog(stddeb, "CreateDialogParam16: %04x,%08lx,%04x,%08lx,%ld\n",
640 hInst, (DWORD)dlgTemplate, owner, (DWORD)dlgProc, param );
642 if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOG ))) return 0;
643 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
644 if (!(data = LockResource16( hmem ))) hwnd = 0;
645 else hwnd = CreateDialogIndirectParam16( hInst, data, owner,
647 FreeResource16( hmem );
652 /***********************************************************************
653 * CreateDialogParam32A (USER32.72)
655 HWND32 CreateDialogParam32A( HINSTANCE32 hInst, LPCSTR name,
656 HWND32 owner, DLGPROC32 dlgProc, LPARAM param )
660 LPWSTR str = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
661 HWND32 hwnd = CreateDialogParam32W( hInst, str, owner, dlgProc, param);
662 HeapFree( GetProcessHeap(), 0, str );
665 return CreateDialogParam32W( hInst, (LPCWSTR)name, owner, dlgProc, param );
669 /***********************************************************************
670 * CreateDialogParam32W (USER32.73)
672 HWND32 CreateDialogParam32W( HINSTANCE32 hInst, LPCWSTR name,
673 HWND32 owner, DLGPROC32 dlgProc, LPARAM param )
675 HANDLE32 hrsrc = FindResource32W( hInst, name, (LPWSTR)RT_DIALOG );
676 if (!hrsrc) return 0;
677 return CreateDialogIndirectParam32W( hInst,
678 (LPVOID)LoadResource32(hInst, hrsrc),
679 owner, dlgProc, param );
683 /***********************************************************************
684 * CreateDialogIndirect16 (USER.219)
686 HWND16 CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
687 HWND16 owner, DLGPROC16 dlgProc )
689 return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
693 /***********************************************************************
694 * CreateDialogIndirectParam16 (USER.242)
696 HWND16 CreateDialogIndirectParam16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
697 HWND16 owner, DLGPROC16 dlgProc,
700 return DIALOG_CreateIndirect( hInst, dlgTemplate, FALSE, owner,
701 dlgProc, param, WIN_PROC_16 );
705 /***********************************************************************
706 * CreateDialogIndirectParam32A (USER32.69)
708 HWND32 CreateDialogIndirectParam32A( HINSTANCE32 hInst, LPCVOID dlgTemplate,
709 HWND32 owner, DLGPROC32 dlgProc,
712 return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
713 (DLGPROC16)dlgProc, param, WIN_PROC_32A );
717 /***********************************************************************
718 * CreateDialogIndirectParam32W (USER32.71)
720 HWND32 CreateDialogIndirectParam32W( HINSTANCE32 hInst, LPCVOID dlgTemplate,
721 HWND32 owner, DLGPROC32 dlgProc,
724 return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
725 (DLGPROC16)dlgProc, param, WIN_PROC_32W );
729 /***********************************************************************
732 INT32 DIALOG_DoDialogBox( HWND32 hwnd, HWND32 owner )
735 DIALOGINFO * dlgInfo;
739 /* Owner must be a top-level window */
740 owner = WIN_GetTopParent( owner );
741 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return -1;
742 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
743 EnableWindow32( owner, FALSE );
744 ShowWindow32( hwnd, SW_SHOW );
746 while (MSG_InternalGetMessage(&msg, hwnd, owner, MSGF_DIALOGBOX, PM_REMOVE,
747 !(wndPtr->dwStyle & DS_NOIDLEMSG) ))
749 if (!IsDialogMessage16( hwnd, &msg))
751 TranslateMessage16( &msg );
752 DispatchMessage16( &msg );
754 if (dlgInfo->flags & DF_END) break;
756 retval = dlgInfo->idResult;
757 EnableWindow32( owner, TRUE );
758 DestroyWindow32( hwnd );
763 /***********************************************************************
764 * DialogBox16 (USER.87)
766 INT16 DialogBox16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
767 HWND16 owner, DLGPROC16 dlgProc )
769 return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
773 /***********************************************************************
774 * DialogBoxParam16 (USER.239)
776 INT16 DialogBoxParam16( HINSTANCE16 hInst, SEGPTR template,
777 HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
779 HWND16 hwnd = CreateDialogParam16( hInst, template, owner, dlgProc, param);
780 if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner );
785 /***********************************************************************
786 * DialogBoxParam32A (USER32.138)
788 INT32 DialogBoxParam32A( HINSTANCE32 hInst, LPCSTR name,
789 HWND32 owner, DLGPROC32 dlgProc, LPARAM param )
791 HWND32 hwnd = CreateDialogParam32A( hInst, name, owner, dlgProc, param );
792 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
797 /***********************************************************************
798 * DialogBoxParam32W (USER32.139)
800 INT32 DialogBoxParam32W( HINSTANCE32 hInst, LPCWSTR name,
801 HWND32 owner, DLGPROC32 dlgProc, LPARAM param )
803 HWND32 hwnd = CreateDialogParam32W( hInst, name, owner, dlgProc, param );
804 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
809 /***********************************************************************
810 * DialogBoxIndirect16 (USER.218)
812 INT16 DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
813 HWND16 owner, DLGPROC16 dlgProc )
815 return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
819 /***********************************************************************
820 * DialogBoxIndirectParam16 (USER.240)
822 INT16 DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
823 HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
828 if (!(ptr = GlobalLock16( dlgTemplate ))) return -1;
829 hwnd = CreateDialogIndirectParam16( hInst, ptr, owner, dlgProc, param );
830 GlobalUnlock16( dlgTemplate );
831 if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner );
836 /***********************************************************************
837 * DialogBoxIndirectParam32A (USER32.135)
839 INT32 DialogBoxIndirectParam32A( HINSTANCE32 hInstance, LPCVOID template,
840 HWND32 owner, DLGPROC32 dlgProc, LPARAM param)
842 HWND32 hwnd = CreateDialogIndirectParam32A( hInstance, template,
843 owner, dlgProc, param );
844 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
849 /***********************************************************************
850 * DialogBoxIndirectParam32W (USER32.137)
852 INT32 DialogBoxIndirectParam32W( HINSTANCE32 hInstance, LPCVOID template,
853 HWND32 owner, DLGPROC32 dlgProc, LPARAM param)
855 HWND32 hwnd = CreateDialogIndirectParam32W( hInstance, template,
856 owner, dlgProc, param );
857 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
862 /***********************************************************************
863 * EndDialog16 (USER32.173)
865 BOOL16 EndDialog16( HWND16 hwnd, INT16 retval )
867 return EndDialog32( hwnd, retval );
871 /***********************************************************************
872 * EndDialog32 (USER32.173)
874 BOOL32 EndDialog32( HWND32 hwnd, INT32 retval )
876 WND * wndPtr = WIN_FindWndPtr( hwnd );
877 DIALOGINFO * dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
879 dprintf_dialog(stddeb, "EndDialog: %04x %d\n", hwnd, retval );
883 dlgInfo->idResult = retval;
884 dlgInfo->flags |= DF_END;
890 /***********************************************************************
891 * DIALOG_IsDialogMessage
893 static BOOL32 DIALOG_IsDialogMessage( HWND32 hwnd, HWND32 hwndDlg,
894 UINT32 message, WPARAM32 wParam,
895 LPARAM lParam, BOOL32 *translate,
900 *translate = *dispatch = FALSE;
902 /* Only the key messages get special processing */
903 if ((message != WM_KEYDOWN) &&
904 (message != WM_SYSCHAR) &&
905 (message != WM_CHAR))
908 dlgCode = SendMessage32A( hwnd, WM_GETDLGCODE, 0, 0 );
909 if (dlgCode & DLGC_WANTMESSAGE)
918 if (dlgCode & DLGC_WANTALLKEYS) break;
922 if (!(dlgCode & DLGC_WANTTAB))
924 SendMessage32A( hwndDlg, WM_NEXTDLGCTL,
925 (GetKeyState32(VK_SHIFT) & 0x8000), 0 );
932 if (!(dlgCode & DLGC_WANTARROWS))
934 SetFocus32( GetNextDlgGroupItem32( hwndDlg, GetFocus32(),
942 if (!(dlgCode & DLGC_WANTARROWS))
944 SetFocus32( GetNextDlgGroupItem32( hwndDlg, GetFocus32(),
951 SendMessage32A( hwndDlg, WM_COMMAND, IDCANCEL,
952 (LPARAM)GetDlgItem32( hwndDlg, IDCANCEL ) );
957 DWORD dw = SendMessage16( hwndDlg, DM_GETDEFID, 0, 0 );
958 if (HIWORD(dw) == DC_HASDEFID)
959 SendMessage32A( hwndDlg, WM_COMMAND,
960 MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
961 (LPARAM)GetDlgItem32(hwndDlg, LOWORD(dw)));
963 SendMessage32A( hwndDlg, WM_COMMAND, IDOK,
964 (LPARAM)GetDlgItem32( hwndDlg, IDOK ) );
972 break; /* case WM_KEYDOWN */
976 if (dlgCode & (DLGC_WANTALLKEYS | DLGC_WANTCHARS)) break;
980 if (dlgCode & DLGC_WANTALLKEYS) break;
984 /* If we get here, the message has not been treated specially */
985 /* and can be sent to its destination window. */
991 /***********************************************************************
992 * IsDialogMessage16 (USER.90)
994 BOOL16 IsDialogMessage16( HWND16 hwndDlg, LPMSG16 msg )
996 BOOL32 ret, translate, dispatch;
998 if ((hwndDlg != msg->hwnd) && !IsChild16( hwndDlg, msg->hwnd ))
1001 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1002 msg->wParam, msg->lParam,
1003 &translate, &dispatch );
1004 if (translate) TranslateMessage16( msg );
1005 if (dispatch) DispatchMessage16( msg );
1010 /***********************************************************************
1011 * IsDialogMessage32A (USER32.341)
1013 BOOL32 IsDialogMessage32A( HWND32 hwndDlg, LPMSG32 msg )
1015 BOOL32 ret, translate, dispatch;
1017 if ((hwndDlg != msg->hwnd) && !IsChild32( hwndDlg, msg->hwnd ))
1020 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1021 msg->wParam, msg->lParam,
1022 &translate, &dispatch );
1023 if (translate) TranslateMessage32( msg );
1024 if (dispatch) DispatchMessage32A( msg );
1029 /***********************************************************************
1030 * IsDialogMessage32W (USER32.342)
1032 BOOL32 IsDialogMessage32W( HWND32 hwndDlg, LPMSG32 msg )
1034 BOOL32 ret, translate, dispatch;
1036 if ((hwndDlg != msg->hwnd) && !IsChild32( hwndDlg, msg->hwnd ))
1039 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1040 msg->wParam, msg->lParam,
1041 &translate, &dispatch );
1042 if (translate) TranslateMessage32( msg );
1043 if (dispatch) DispatchMessage32W( msg );
1048 /****************************************************************
1049 * GetDlgCtrlID16 (USER.277)
1051 INT16 GetDlgCtrlID16( HWND16 hwnd )
1053 WND *wndPtr = WIN_FindWndPtr(hwnd);
1054 if (wndPtr) return wndPtr->wIDmenu;
1059 /****************************************************************
1060 * GetDlgCtrlID32 (USER32.233)
1062 INT32 GetDlgCtrlID32( HWND32 hwnd )
1064 WND *wndPtr = WIN_FindWndPtr(hwnd);
1065 if (wndPtr) return wndPtr->wIDmenu;
1070 /***********************************************************************
1071 * GetDlgItem16 (USER.91)
1073 HWND16 GetDlgItem16( HWND16 hwndDlg, INT16 id )
1077 if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0;
1078 for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next)
1079 if (pWnd->wIDmenu == (UINT16)id) return pWnd->hwndSelf;
1084 /***********************************************************************
1085 * GetDlgItem32 (USER32.234)
1087 HWND32 GetDlgItem32( HWND32 hwndDlg, INT32 id )
1091 if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0;
1092 for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next)
1093 if (pWnd->wIDmenu == (UINT16)id) return pWnd->hwndSelf;
1098 /*******************************************************************
1099 * SendDlgItemMessage16 (USER.101)
1101 LRESULT SendDlgItemMessage16( HWND16 hwnd, INT16 id, UINT16 msg,
1102 WPARAM16 wParam, LPARAM lParam )
1104 HWND16 hwndCtrl = GetDlgItem16( hwnd, id );
1105 if (hwndCtrl) return SendMessage16( hwndCtrl, msg, wParam, lParam );
1110 /*******************************************************************
1111 * SendDlgItemMessage32A (USER32.451)
1113 LRESULT SendDlgItemMessage32A( HWND32 hwnd, INT32 id, UINT32 msg,
1114 WPARAM32 wParam, LPARAM lParam )
1116 HWND32 hwndCtrl = GetDlgItem32( hwnd, id );
1117 if (hwndCtrl) return SendMessage32A( hwndCtrl, msg, wParam, lParam );
1122 /*******************************************************************
1123 * SendDlgItemMessage32W (USER32.452)
1125 LRESULT SendDlgItemMessage32W( HWND32 hwnd, INT32 id, UINT32 msg,
1126 WPARAM32 wParam, LPARAM lParam )
1128 HWND32 hwndCtrl = GetDlgItem32( hwnd, id );
1129 if (hwndCtrl) return SendMessage32W( hwndCtrl, msg, wParam, lParam );
1134 /*******************************************************************
1135 * SetDlgItemText16 (USER.92)
1137 void SetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR lpString )
1139 SendDlgItemMessage16( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1143 /*******************************************************************
1144 * SetDlgItemText32A (USER32.477)
1146 void SetDlgItemText32A( HWND32 hwnd, INT32 id, LPCSTR lpString )
1148 SendDlgItemMessage32A( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1152 /*******************************************************************
1153 * SetDlgItemText32W (USER32.478)
1155 void SetDlgItemText32W( HWND32 hwnd, INT32 id, LPCWSTR lpString )
1157 SendDlgItemMessage32W( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1161 /***********************************************************************
1162 * GetDlgItemText16 (USER.93)
1164 INT16 GetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR str, UINT16 len )
1166 return (INT16)SendDlgItemMessage16( hwnd, id, WM_GETTEXT,
1171 /***********************************************************************
1172 * GetDlgItemText32A (USER32.236)
1174 INT32 GetDlgItemText32A( HWND32 hwnd, INT32 id, LPSTR str, UINT32 len )
1176 return (INT32)SendDlgItemMessage32A( hwnd, id, WM_GETTEXT,
1181 /***********************************************************************
1182 * GetDlgItemText32W (USER32.237)
1184 INT32 GetDlgItemText32W( HWND32 hwnd, INT32 id, LPWSTR str, UINT32 len )
1186 return (INT32)SendDlgItemMessage32W( hwnd, id, WM_GETTEXT,
1191 /*******************************************************************
1192 * SetDlgItemInt16 (USER.94)
1194 void SetDlgItemInt16( HWND16 hwnd, INT16 id, UINT16 value, BOOL16 fSigned )
1196 return SetDlgItemInt32( hwnd, (UINT32)(UINT16)id, value, fSigned );
1200 /*******************************************************************
1201 * SetDlgItemInt32 (USER32.476)
1203 void SetDlgItemInt32( HWND32 hwnd, INT32 id, UINT32 value, BOOL32 fSigned )
1207 if (fSigned) sprintf( str, "%d", (INT32)value );
1208 else sprintf( str, "%u", value );
1209 SendDlgItemMessage32A( hwnd, id, WM_SETTEXT, 0, (LPARAM)str );
1213 /***********************************************************************
1214 * GetDlgItemInt16 (USER.95)
1216 UINT16 GetDlgItemInt16( HWND16 hwnd, INT16 id, BOOL16 *translated,
1222 if (translated) *translated = FALSE;
1223 result = GetDlgItemInt32( hwnd, (UINT32)(UINT16)id, &ok, fSigned );
1227 if (((INT32)result < -32767) || ((INT32)result > 32767)) return 0;
1231 if (result > 65535) return 0;
1233 if (translated) *translated = TRUE;
1234 return (UINT16)result;
1238 /***********************************************************************
1239 * GetDlgItemInt32 (USER32.235)
1241 UINT32 GetDlgItemInt32( HWND32 hwnd, INT32 id, BOOL32 *translated,
1248 if (translated) *translated = FALSE;
1249 if (!SendDlgItemMessage32A(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str))
1253 result = strtol( str, &endptr, 10 );
1254 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1256 if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE))
1261 result = strtoul( str, &endptr, 10 );
1262 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1264 if ((result == ULONG_MAX) && (errno == ERANGE)) return 0;
1266 if (translated) *translated = TRUE;
1267 return (UINT32)result;
1271 /***********************************************************************
1272 * CheckDlgButton16 (USER.97)
1274 BOOL16 CheckDlgButton16( HWND16 hwnd, INT16 id, UINT16 check )
1276 SendDlgItemMessage32A( hwnd, id, BM_SETCHECK32, check, 0 );
1281 /***********************************************************************
1282 * CheckDlgButton32 (USER32.44)
1284 BOOL32 CheckDlgButton32( HWND32 hwnd, INT32 id, UINT32 check )
1286 SendDlgItemMessage32A( hwnd, id, BM_SETCHECK32, check, 0 );
1291 /***********************************************************************
1292 * IsDlgButtonChecked16 (USER.98)
1294 UINT16 IsDlgButtonChecked16( HWND16 hwnd, UINT16 id )
1296 return (UINT16)SendDlgItemMessage32A( hwnd, id, BM_GETCHECK32, 0, 0 );
1300 /***********************************************************************
1301 * IsDlgButtonChecked32 (USER32.343)
1303 UINT32 IsDlgButtonChecked32( HWND32 hwnd, UINT32 id )
1305 return (UINT32)SendDlgItemMessage32A( hwnd, id, BM_GETCHECK32, 0, 0 );
1309 /***********************************************************************
1310 * CheckRadioButton16 (USER.96)
1312 BOOL16 CheckRadioButton16( HWND16 hwndDlg, UINT16 firstID, UINT16 lastID,
1315 return CheckRadioButton32( hwndDlg, firstID, lastID, checkID );
1319 /***********************************************************************
1320 * CheckRadioButton32 (USER32.47)
1322 BOOL32 CheckRadioButton32( HWND32 hwndDlg, UINT32 firstID, UINT32 lastID,
1325 WND *pWnd = WIN_FindWndPtr( hwndDlg );
1326 if (!pWnd) return FALSE;
1328 for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next)
1329 if ((pWnd->wIDmenu == firstID) || (pWnd->wIDmenu == lastID)) break;
1330 if (!pWnd) return FALSE;
1332 if (pWnd->wIDmenu == lastID)
1333 lastID = firstID; /* Buttons are in reverse order */
1336 SendMessage32A( pWnd->hwndSelf, BM_SETCHECK32,
1337 (pWnd->wIDmenu == checkID), 0 );
1338 if (pWnd->wIDmenu == lastID) break;
1345 /***********************************************************************
1346 * GetDialogBaseUnits (USER.243) (USER32.232)
1348 DWORD GetDialogBaseUnits(void)
1350 return MAKELONG( xBaseUnit, yBaseUnit );
1354 /***********************************************************************
1355 * MapDialogRect16 (USER.103)
1357 void MapDialogRect16( HWND16 hwnd, LPRECT16 rect )
1359 DIALOGINFO * dlgInfo;
1360 WND * wndPtr = WIN_FindWndPtr( hwnd );
1361 if (!wndPtr) return;
1362 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
1363 rect->left = (rect->left * dlgInfo->xBaseUnit) / 4;
1364 rect->right = (rect->right * dlgInfo->xBaseUnit) / 4;
1365 rect->top = (rect->top * dlgInfo->yBaseUnit) / 8;
1366 rect->bottom = (rect->bottom * dlgInfo->yBaseUnit) / 8;
1370 /***********************************************************************
1371 * MapDialogRect32 (USER32.381)
1373 void MapDialogRect32( HWND32 hwnd, LPRECT32 rect )
1375 DIALOGINFO * dlgInfo;
1376 WND * wndPtr = WIN_FindWndPtr( hwnd );
1377 if (!wndPtr) return;
1378 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
1379 rect->left = (rect->left * dlgInfo->xBaseUnit) / 4;
1380 rect->right = (rect->right * dlgInfo->xBaseUnit) / 4;
1381 rect->top = (rect->top * dlgInfo->yBaseUnit) / 8;
1382 rect->bottom = (rect->bottom * dlgInfo->yBaseUnit) / 8;
1386 /***********************************************************************
1387 * GetNextDlgGroupItem16 (USER.227)
1389 HWND16 GetNextDlgGroupItem16(HWND16 hwndDlg, HWND16 hwndCtrl, BOOL16 fPrevious)
1391 return (HWND16)GetNextDlgGroupItem32( hwndDlg, hwndCtrl, fPrevious );
1395 /***********************************************************************
1396 * GetNextDlgGroupItem32 (USER32.274)
1398 HWND32 GetNextDlgGroupItem32(HWND32 hwndDlg, HWND32 hwndCtrl, BOOL32 fPrevious)
1400 WND *pWnd, *pWndLast, *pWndCtrl, *pWndDlg;
1402 if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0;
1405 if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl ))) return 0;
1406 /* Make sure hwndCtrl is a top-level child */
1407 while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg))
1408 pWndCtrl = pWndCtrl->parent;
1409 if (pWndCtrl->parent != pWndDlg) return 0;
1413 /* No ctrl specified -> start from the beginning */
1414 if (!(pWndCtrl = pWndDlg->child)) return 0;
1415 if (fPrevious) while (pWndCtrl->next) pWndCtrl = pWndCtrl->next;
1418 pWndLast = pWndCtrl;
1419 pWnd = pWndCtrl->next;
1422 if (!pWnd || (pWnd->dwStyle & WS_GROUP))
1424 /* Wrap-around to the beginning of the group */
1425 WND *pWndStart = pWndDlg->child;
1426 for (pWnd = pWndStart; pWnd; pWnd = pWnd->next)
1428 if (pWnd->dwStyle & WS_GROUP) pWndStart = pWnd;
1429 if (pWnd == pWndCtrl) break;
1433 if (pWnd == pWndCtrl) break;
1434 if ((pWnd->dwStyle & WS_VISIBLE) && !(pWnd->dwStyle & WS_DISABLED))
1437 if (!fPrevious) break;
1441 return pWndLast->hwndSelf;
1445 /***********************************************************************
1446 * GetNextDlgTabItem16 (USER.228)
1448 HWND16 GetNextDlgTabItem16( HWND16 hwndDlg, HWND16 hwndCtrl, BOOL16 fPrevious )
1450 return (HWND16)GetNextDlgTabItem32( hwndDlg, hwndCtrl, fPrevious );
1454 /***********************************************************************
1455 * GetNextDlgTabItem32 (USER32.275)
1457 HWND32 GetNextDlgTabItem32( HWND32 hwndDlg, HWND32 hwndCtrl, BOOL32 fPrevious )
1459 WND *pWnd, *pWndLast, *pWndCtrl, *pWndDlg;
1461 if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0;
1464 if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl ))) return 0;
1465 /* Make sure hwndCtrl is a top-level child */
1466 while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg))
1467 pWndCtrl = pWndCtrl->parent;
1468 if (pWndCtrl->parent != pWndDlg) return 0;
1472 /* No ctrl specified -> start from the beginning */
1473 if (!(pWndCtrl = pWndDlg->child)) return 0;
1474 if (fPrevious) while (pWndCtrl->next) pWndCtrl = pWndCtrl->next;
1477 pWndLast = pWndCtrl;
1478 pWnd = pWndCtrl->next;
1481 if (!pWnd) pWnd = pWndDlg->child;
1482 if (pWnd == pWndCtrl) break;
1483 if ((pWnd->dwStyle & WS_TABSTOP) && (pWnd->dwStyle & WS_VISIBLE) &&
1484 !(pWnd->dwStyle & WS_DISABLED))
1487 if (!fPrevious) break;
1491 return pWndLast->hwndSelf;
1495 /**********************************************************************
1496 * DIALOG_DlgDirSelect
1498 * Helper function for DlgDirSelect*
1500 static BOOL32 DIALOG_DlgDirSelect( HWND32 hwnd, LPSTR str, INT32 len,
1501 INT32 id, BOOL32 win32, BOOL32 unicode,
1507 HWND32 listbox = GetDlgItem32( hwnd, id );
1509 dprintf_dialog( stddeb, "DlgDirSelect: %04x '%s' %d\n", hwnd, str, id );
1510 if (!listbox) return FALSE;
1513 item = SendMessage32A(listbox, combo ? CB_GETCURSEL32
1514 : LB_GETCURSEL32, 0, 0 );
1515 if (item == LB_ERR) return FALSE;
1516 size = SendMessage32A(listbox, combo ? CB_GETLBTEXTLEN32
1517 : LB_GETTEXTLEN32, 0, 0 );
1518 if (size == LB_ERR) return FALSE;
1522 item = SendMessage32A(listbox, combo ? CB_GETCURSEL16
1523 : LB_GETCURSEL16, 0, 0 );
1524 if (item == LB_ERR) return FALSE;
1525 size = SendMessage32A(listbox, combo ? CB_GETLBTEXTLEN16
1526 : LB_GETTEXTLEN16, 0, 0 );
1527 if (size == LB_ERR) return FALSE;
1530 if (!(buffer = SEGPTR_ALLOC( size+1 ))) return FALSE;
1533 SendMessage32A( listbox, combo ? CB_GETLBTEXT32 : LB_GETTEXT32,
1534 item, (LPARAM)buffer );
1536 SendMessage16( listbox, combo ? CB_GETLBTEXT16 : LB_GETTEXT16,
1537 item, (LPARAM)SEGPTR_GET(buffer) );
1539 if ((ret = (buffer[0] == '['))) /* drive or directory */
1541 if (buffer[1] == '-') /* drive */
1549 buffer[strlen(buffer)-1] = '\\';
1555 if (unicode) lstrcpynAtoW( (LPWSTR)str, ptr, len );
1556 else lstrcpyn32A( str, ptr, len );
1557 SEGPTR_FREE( buffer );
1558 dprintf_dialog( stddeb, "Returning %d '%s'\n", ret, str );
1563 /**********************************************************************
1566 * Helper function for DlgDirList*
1568 static INT32 DIALOG_DlgDirList( HWND32 hDlg, LPCSTR spec, INT32 idLBox,
1569 INT32 idStatic, UINT32 attrib, BOOL32 combo )
1574 #define SENDMSG(msg,wparam,lparam) \
1575 ((attrib & DDL_POSTMSGS) ? PostMessage32A( hwnd, msg, wparam, lparam ) \
1576 : SendMessage32A( hwnd, msg, wparam, lparam ))
1578 dprintf_dialog( stddeb, "DlgDirList: %04x '%s' %d %d %04x\n",
1579 hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
1581 if (spec && spec[0] && (spec[1] == ':'))
1583 drive = toupper( spec[0] ) - 'A';
1585 if (!DRIVE_SetCurrentDrive( drive )) return FALSE;
1587 else drive = DRIVE_GetCurrentDrive();
1589 if (idLBox && ((hwnd = GetDlgItem32( hDlg, idLBox )) != 0))
1591 /* If the path exists and is a directory, chdir to it */
1592 if (!spec || !spec[0] || DRIVE_Chdir( drive, spec )) spec = "*.*";
1597 if ((p2 = strrchr( p, '\\' ))) p = p2 + 1;
1598 if ((p2 = strrchr( p, '/' ))) p = p2 + 1;
1602 char *dir = HeapAlloc( SystemHeap, 0, p - spec );
1605 lstrcpyn32A( dir, spec, p - spec );
1606 ret = DRIVE_Chdir( drive, dir );
1607 HeapFree( SystemHeap, 0, dir );
1609 if (!ret) return FALSE;
1614 dprintf_dialog( stddeb, "ListBoxDirectory: path=%c:\\%s mask=%s\n",
1615 'A' + drive, DRIVE_GetDosCwd(drive), spec );
1617 SENDMSG( combo ? CB_RESETCONTENT32 : LB_RESETCONTENT32, 0, 0 );
1618 if ((attrib & DDL_DIRECTORY) && !(attrib & DDL_EXCLUSIVE))
1620 if (SENDMSG( combo ? CB_DIR32 : LB_DIR32,
1621 attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
1622 (LPARAM)spec ) == LB_ERR)
1624 if (SENDMSG( combo ? CB_DIR32 : LB_DIR32,
1625 (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
1626 (LPARAM)"*.*" ) == LB_ERR)
1631 if (SENDMSG( combo ? CB_DIR32 : LB_DIR32, attrib,
1632 (LPARAM)spec ) == LB_ERR)
1637 if (idStatic && ((hwnd = GetDlgItem32( hDlg, idStatic )) != 0))
1640 int drive = DRIVE_GetCurrentDrive();
1641 strcpy( temp, "A:\\" );
1643 lstrcpyn32A( temp + 3, DRIVE_GetDosCwd(drive), sizeof(temp)-3 );
1644 CharLower32A( temp );
1645 /* Can't use PostMessage() here, because the string is on the stack */
1646 SetDlgItemText32A( hDlg, idStatic, temp );
1653 /**********************************************************************
1654 * DlgDirSelect (USER.99)
1656 BOOL16 DlgDirSelect( HWND16 hwnd, LPSTR str, INT16 id )
1658 return DlgDirSelectEx16( hwnd, str, 128, id );
1662 /**********************************************************************
1663 * DlgDirSelectComboBox (USER.194)
1665 BOOL16 DlgDirSelectComboBox( HWND16 hwnd, LPSTR str, INT16 id )
1667 return DlgDirSelectComboBoxEx16( hwnd, str, 128, id );
1671 /**********************************************************************
1672 * DlgDirSelectEx16 (USER.422)
1674 BOOL16 DlgDirSelectEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id )
1676 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE, FALSE );
1680 /**********************************************************************
1681 * DlgDirSelectEx32A (USER32.148)
1683 BOOL32 DlgDirSelectEx32A( HWND32 hwnd, LPSTR str, INT32 len, INT32 id )
1685 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, FALSE );
1689 /**********************************************************************
1690 * DlgDirSelectEx32W (USER32.149)
1692 BOOL32 DlgDirSelectEx32W( HWND32 hwnd, LPWSTR str, INT32 len, INT32 id )
1694 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, FALSE );
1698 /**********************************************************************
1699 * DlgDirSelectComboBoxEx16 (USER.423)
1701 BOOL16 DlgDirSelectComboBoxEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id )
1703 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE, TRUE );
1707 /**********************************************************************
1708 * DlgDirSelectComboBoxEx32A (USER32.146)
1710 BOOL32 DlgDirSelectComboBoxEx32A( HWND32 hwnd, LPSTR str, INT32 len, INT32 id )
1712 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, TRUE );
1716 /**********************************************************************
1717 * DlgDirSelectComboBoxEx32W (USER32.147)
1719 BOOL32 DlgDirSelectComboBoxEx32W( HWND32 hwnd, LPWSTR str, INT32 len, INT32 id)
1721 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, TRUE );
1725 /**********************************************************************
1726 * DlgDirList16 (USER.100)
1728 INT16 DlgDirList16( HWND16 hDlg, LPCSTR spec, INT16 idLBox, INT16 idStatic,
1731 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
1735 /**********************************************************************
1736 * DlgDirList32A (USER32.142)
1738 INT32 DlgDirList32A( HWND32 hDlg, LPCSTR spec, INT32 idLBox, INT32 idStatic,
1741 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
1745 /**********************************************************************
1746 * DlgDirList32W (USER32.145)
1748 INT32 DlgDirList32W( HWND32 hDlg, LPCWSTR spec, INT32 idLBox, INT32 idStatic,
1752 LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
1753 ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic, attrib, FALSE );
1754 HeapFree( GetProcessHeap(), 0, specA );
1759 /**********************************************************************
1760 * DlgDirListComboBox16 (USER.195)
1762 INT16 DlgDirListComboBox16( HWND16 hDlg, LPCSTR spec, INT16 idCBox,
1763 INT16 idStatic, UINT16 attrib )
1765 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
1769 /**********************************************************************
1770 * DlgDirListComboBox32A (USER32.143)
1772 INT32 DlgDirListComboBox32A( HWND32 hDlg, LPCSTR spec, INT32 idCBox,
1773 INT32 idStatic, UINT32 attrib )
1775 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
1779 /**********************************************************************
1780 * DlgDirListComboBox32W (USER32.144)
1782 INT32 DlgDirListComboBox32W( HWND32 hDlg, LPCWSTR spec, INT32 idCBox,
1783 INT32 idStatic, UINT32 attrib )
1786 LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
1787 ret = DIALOG_DlgDirList( hDlg, specA, idCBox, idStatic, attrib, FALSE );
1788 HeapFree( GetProcessHeap(), 0, specA );