source: trunk/src/user32/windlg.cpp@ 5087

Last change on this file since 5087 was 5065, checked in by sandervl, 25 years ago

GetDlgItem error fix

File size: 23.6 KB
Line 
1/* $Id: windlg.cpp,v 1.20 2001-02-05 18:49:30 sandervl Exp $ */
2/*
3 * Win32 dialog apis for OS/2
4 *
5 * Copyright 1999 Sander van Leeuwen
6 *
7 * Parts based on Wine code (990815; window\dialog.c)
8 *
9 * Copyright 1993, 1994, 1996 Alexandre Julliard
10 *
11 * Project Odin Software License can be found in LICENSE.TXT
12 *
13 */
14#include <ctype.h>
15#include <wchar.h>
16#include <os2win.h>
17#include <misc.h>
18#include <stdio.h>
19#include <string.h>
20#include <stdlib.h>
21#include <limits.h>
22#include <errno.h>
23#include "win32wbase.h"
24#include "win32dlg.h"
25#include <heapstring.h>
26#include <win\drive.h>
27
28#define DBG_LOCALLOG DBG_windlg
29#include "dbglocal.h"
30
31static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox, INT idStatic, UINT attrib, BOOL combo );
32static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox, INT idStatic, UINT attrib, BOOL combo );
33static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len, INT id, BOOL win32, BOOL unicode, BOOL combo );
34
35//******************************************************************************
36//******************************************************************************
37HWND WIN32API CreateDialogParamA(HINSTANCE hInst, LPCSTR lpszTemplate,
38 HWND hwndOwner, DLGPROC dlgproc,
39 LPARAM lParamInit)
40{
41 HANDLE hrsrc = FindResourceA( hInst, lpszTemplate, RT_DIALOGA );
42
43 if (!hrsrc) {
44 dprintf(("WARNING: CreateDialogParamA: Dialog %x not found!!", lpszTemplate));
45 return 0;
46 }
47
48 return CreateDialogIndirectParamA(hInst, (LPCDLGTEMPLATEA)LoadResource(hInst, hrsrc),
49 hwndOwner, dlgproc, lParamInit);
50}
51//******************************************************************************
52//******************************************************************************
53HWND WIN32API CreateDialogParamW(HINSTANCE hInst, LPCWSTR lpszTemplate,
54 HWND hwndOwner, DLGPROC dlgproc,
55 LPARAM lParamInit)
56{
57 HANDLE hrsrc = FindResourceW( hInst, lpszTemplate, RT_DIALOGW );
58
59 if (!hrsrc) {
60 dprintf(("WARNING: CreateDialogParamW: Dialog %x not found!!", lpszTemplate));
61 return 0;
62 }
63 return CreateDialogIndirectParamW(hInst, (LPCDLGTEMPLATEW)LoadResource(hInst, hrsrc),
64 hwndOwner, dlgproc, lParamInit);
65}
66//******************************************************************************
67//******************************************************************************
68HWND WIN32API CreateDialogIndirectParamA(HINSTANCE hInst,
69 LPCDLGTEMPLATEA dlgtemplate,
70 HWND hwndParent, DLGPROC dlgproc,
71 LPARAM lParamInit)
72{
73 Win32Dialog *dialog;
74
75 dprintf(("CreateDialogIndirectParamA: %x %x %x %x %x", hInst, dlgtemplate, hwndParent, dlgproc, lParamInit));
76
77 if (!dlgtemplate) return 0;
78
79 dialog = new Win32Dialog(hInst, (LPCSTR)dlgtemplate, hwndParent, dlgproc, lParamInit, FALSE);
80
81 if(dialog == NULL)
82 {
83 dprintf(("Win32Dialog creation failed!!"));
84 return 0;
85 }
86 if(GetLastError() != 0)
87 {
88 dprintf(("Win32Dialog error found (%0x)!!", GetLastError()));
89 delete dialog;
90 return 0;
91 }
92 return dialog->getWindowHandle();
93}
94//******************************************************************************
95//******************************************************************************
96HWND WIN32API CreateDialogIndirectParamW(HINSTANCE hInst,
97 LPCDLGTEMPLATEW dlgtemplate,
98 HWND hwndParent, DLGPROC dlgproc,
99 LPARAM lParamInit)
100{
101 Win32Dialog *dialog;
102
103 dprintf(("CreateDialogIndirectParamW: %x %x %x %x %x", hInst, dlgtemplate, hwndParent, dlgproc, lParamInit));
104
105 if (!dlgtemplate) return 0;
106
107 dialog = new Win32Dialog(hInst, (LPCSTR)dlgtemplate, hwndParent, dlgproc, lParamInit, TRUE);
108
109 if(dialog == NULL)
110 {
111 dprintf(("Win32Dialog creation failed!!"));
112 return 0;
113 }
114 if(GetLastError() != 0)
115 {
116 dprintf(("Win32Dialog error found!!"));
117 delete dialog;
118 return 0;
119 }
120 return dialog->getWindowHandle();
121}
122//******************************************************************************
123//******************************************************************************
124INT WIN32API DialogBoxIndirectParamA(HINSTANCE hInst,
125 LPCDLGTEMPLATEA dlgtemplate,
126 HWND hwndParent, DLGPROC dlgproc,
127 LPARAM lParamInit)
128{
129 HWND hwnd = CreateDialogIndirectParamA(hInst, dlgtemplate, hwndParent, dlgproc,
130 lParamInit);
131 if (hwnd)
132 {
133 Win32Dialog *dialog;
134
135 dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
136 if(!dialog || !dialog->IsDialog()) {
137 dprintf(("DialogBoxIndirectParamA, dialog %x not found", hwnd));
138 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
139 return 0;
140 }
141 return dialog->doDialogBox();
142 }
143 return -1;
144}
145//******************************************************************************
146//******************************************************************************
147INT WIN32API DialogBoxIndirectParamW(HINSTANCE hInst, LPCDLGTEMPLATEW dlgtemplate,
148 HWND hwndParent, DLGPROC dlgproc,
149 LPARAM lParamInit)
150{
151 HWND hwnd = CreateDialogIndirectParamW(hInst, dlgtemplate, hwndParent, dlgproc,
152 lParamInit);
153 if (hwnd)
154 {
155 Win32Dialog *dialog;
156
157 dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
158 if(!dialog || !dialog->IsDialog()) {
159 dprintf(("DialogBoxIndirectParamW, dialog %x not found", hwnd));
160 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
161 return 0;
162 }
163 return dialog->doDialogBox();
164 }
165 return -1;
166}
167//******************************************************************************
168//******************************************************************************
169int WIN32API DialogBoxParamA(HINSTANCE hInst, LPCSTR lpszTemplate, HWND hwndOwner,
170 DLGPROC dlgproc, LPARAM lParamInit)
171{
172 HWND hwnd = CreateDialogParamA( hInst, lpszTemplate, hwndOwner, dlgproc, lParamInit);
173
174 if (hwnd)
175 {
176 Win32Dialog *dialog;
177
178 dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
179 if(!dialog || !dialog->IsDialog()) {
180 dprintf(("DialogBoxParamA, dialog %x not found", hwnd));
181 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
182 return 0;
183 }
184 return dialog->doDialogBox();
185 }
186 return -1;
187}
188//******************************************************************************
189//******************************************************************************
190int WIN32API DialogBoxParamW(HINSTANCE hInst, LPCWSTR lpszTemplate, HWND hwndOwner,
191 DLGPROC dlgproc, LPARAM lParamInit)
192{
193 HWND hwnd = CreateDialogParamW( hInst, lpszTemplate, hwndOwner, dlgproc, lParamInit);
194
195 if (hwnd)
196 {
197 Win32Dialog *dialog;
198
199 dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
200 if(!dialog || !dialog->IsDialog()) {
201 dprintf(("DialogBoxParamW, dialog %x not found", hwnd));
202 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
203 return 0;
204 }
205 return dialog->doDialogBox();
206 }
207 return -1;
208}
209/***********************************************************************
210 * MapDialogRect32 (USER32.382)
211 */
212BOOL WIN32API MapDialogRect(HWND hwndDlg, LPRECT rect)
213{
214 Win32Dialog *dialog;
215#ifdef DEBUG
216 BOOL rc;
217 RECT dlgRect = *rect;
218#endif
219
220 dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwndDlg);
221 if(!dialog || !dialog->IsDialog()) {
222 dprintf(("MapDialogRect, window %x not found", hwndDlg));
223 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
224 return 0;
225 }
226#ifdef DEBUG
227 rc = dialog->MapDialogRect(rect);
228 dprintf(("USER32: MapDialogRect %x (%d,%d)(%d,%d) -> (%d,%d)(%d,%d)", hwndDlg, dlgRect.left, dlgRect.top, dlgRect.right, dlgRect.bottom, rect->left, rect->top, rect->right, rect->bottom));
229 return rc;
230#else
231 dprintf(("USER32: MapDialogRect %x (%d,%d)(%d,%d)", hwndDlg, rect->left, rect->top, rect->right, rect->bottom));
232 return dialog->MapDialogRect(rect);
233#endif
234}
235//******************************************************************************
236//******************************************************************************
237BOOL WIN32API IsDlgButtonChecked( HWND hwnd, UINT id)
238{
239 dprintf(("USER32: IsDlgButtonChecked\n"));
240
241 return (BOOL)SendDlgItemMessageA(hwnd, id,BM_GETCHECK,0,0);
242}
243//******************************************************************************
244//******************************************************************************
245HWND WIN32API GetNextDlgTabItem(HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious)
246{
247 Win32BaseWindow *window;
248
249 window = (Win32BaseWindow*)Win32BaseWindow::GetWindowFromHandle(hwndDlg);
250 if(!window) {
251 dprintf(("GetNextDlgTabItem, window %x not found", hwndDlg));
252 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
253 return 0;
254 }
255 dprintf(("USER32: GetNextDlgTabItem\n"));
256 return window->getNextDlgTabItem(hwndCtrl, fPrevious);
257}
258//******************************************************************************
259//Can be used for any parent-child pair
260//NOTE: Returns ERROR_CONTROL_ID_NOT_FOUND when child with id not found
261// Does not change last error if successful
262//******************************************************************************
263HWND WIN32API GetDlgItem(HWND hwnd, int id)
264{
265 Win32BaseWindow *dlgcontrol, *window;
266
267 window = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
268 if(!window) {
269 dprintf(("GetDlgItem, window %x not found", hwnd));
270 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
271 return 0;
272 }
273 dlgcontrol = window->FindWindowById(id);
274 if(dlgcontrol) {
275 dprintf(("USER32: GetDlgItem %x %d returned %x\n", hwnd, id, dlgcontrol->getWindowHandle()));
276 return dlgcontrol->getWindowHandle();
277 }
278 dprintf(("USER32: GetDlgItem %x %d NOT FOUND!\n", hwnd, id));
279 SetLastError(ERROR_CONTROL_ID_NOT_FOUND); //verified in NT4, SP6
280 return 0;
281}
282//******************************************************************************
283//******************************************************************************
284int WIN32API GetDlgCtrlID(HWND hwnd)
285{
286 Win32BaseWindow *dlgcontrol;
287
288 dlgcontrol = Win32BaseWindow::GetWindowFromHandle(hwnd);
289 if(!dlgcontrol) {
290 dprintf(("GetDlgCtrlID, control %x not found", hwnd));
291 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
292 return 0;
293 }
294 dprintf(("USER32: GetDlgCtrlID %x", hwnd));
295 return dlgcontrol->getWindowId();
296}
297//******************************************************************************
298//******************************************************************************
299BOOL WIN32API EndDialog(HWND hwnd, int retval)
300{
301 Win32Dialog *dialog;
302
303 dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
304 if(!dialog || !dialog->IsDialog()) {
305 dprintf(("GetDlgItem, window %x not found", hwnd));
306 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
307 return 0;
308 }
309 dprintf(("USER32: EndDialog %x %d", hwnd, retval));
310 return dialog->endDialog(retval);
311}
312//******************************************************************************
313//******************************************************************************
314BOOL WIN32API CheckDlgButton( HWND hwnd, int id, UINT check)
315{
316 dprintf(("USER32: CheckDlgButton %x %d %d", hwnd, id, check));
317
318 return (BOOL)SendDlgItemMessageA(hwnd, id, BM_SETCHECK, check,0);
319}
320//******************************************************************************
321//******************************************************************************
322BOOL WIN32API CheckRadioButton( HWND hDlg, UINT nIDFirstButton, UINT nIDLastButton, UINT nIDCheckButton)
323{
324 dprintf(("USER32: CheckRadioButton %x %d %d %d", hDlg, nIDFirstButton, nIDLastButton, nIDCheckButton));
325
326 //CB: check radio buttons in interval
327 if (nIDFirstButton > nIDLastButton)
328 {
329 SetLastError(ERROR_INVALID_PARAMETER);
330 return (FALSE);
331 }
332
333 for (UINT x = nIDFirstButton;x <= nIDLastButton;x++)
334 {
335 SendDlgItemMessageA(hDlg,x,BM_SETCHECK,(x == nIDCheckButton) ? BST_CHECKED : BST_UNCHECKED,0);
336 }
337
338 return (TRUE);
339}
340//******************************************************************************
341//******************************************************************************
342UINT WIN32API GetDlgItemTextA(HWND hwnd, int id, LPSTR lpszName, UINT cch)
343{
344 return SendDlgItemMessageA( hwnd, id, WM_GETTEXT, cch, (LPARAM)lpszName);
345}
346//*****************************************************************************
347//*****************************************************************************
348UINT WIN32API GetDlgItemTextW(HWND hwnd, int id, LPWSTR lpszName, UINT cch)
349{
350 return SendDlgItemMessageW( hwnd, id, WM_GETTEXT, cch, (LPARAM)lpszName);
351}
352//******************************************************************************
353//******************************************************************************
354BOOL WIN32API SetDlgItemInt( HWND hwnd, int idControl, UINT uValue, BOOL fSigned)
355{
356 char str[20];
357
358 dprintf(("USER32: SetDlgItemInt\n"));
359
360 if (fSigned)
361 sprintf( str, "%d", (INT)uValue );
362 else sprintf( str, "%u", uValue );
363
364 return SendDlgItemMessageA( hwnd, idControl, WM_SETTEXT, 0, (LPARAM)str );
365}
366//******************************************************************************
367//******************************************************************************
368BOOL WIN32API SetDlgItemTextA( HWND hwnd, int id, LPCSTR lpszName)
369{
370 return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpszName );
371}
372//******************************************************************************
373//******************************************************************************
374BOOL WIN32API SetDlgItemTextW( HWND hwnd, int id, LPCWSTR lpszName)
375{
376 return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpszName );
377}
378//******************************************************************************
379//******************************************************************************
380UINT WIN32API GetDlgItemInt(HWND hwnd, INT id, BOOL *translated, BOOL fSigned)
381{
382 char str[30];
383 char * endptr;
384 long result = 0;
385
386 dprintf(("USER32: GetDlgItemInt\n"));
387 if (translated) *translated = FALSE;
388
389 if (!SendDlgItemMessageA(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str))
390 return 0;
391
392 if (fSigned)
393 {
394 result = strtol( str, &endptr, 10 );
395 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
396 return 0;
397 if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE))
398 return 0;
399 }
400 else
401 {
402 result = strtoul( str, &endptr, 10 );
403 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
404 return 0;
405 if ((result == ULONG_MAX) && (errno == ERANGE)) return 0;
406 }
407 if (translated) *translated = TRUE;
408 return (UINT)result;
409}
410//******************************************************************************
411//******************************************************************************
412HWND WIN32API GetNextDlgGroupItem( HWND hwnd, HWND hwndCtrl, BOOL fPrevious)
413{
414 Win32BaseWindow *window;
415
416 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
417 if(!window) {
418 dprintf(("GetNextDlgGroupItem, window %x not found", hwnd));
419 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
420 return 0;
421 }
422 dprintf(("USER32: GetNextDlgGroupItem\n"));
423 return window->getNextDlgGroupItem(hwndCtrl, fPrevious);
424}
425/***********************************************************************
426 * GetDialogBaseUnits (USER.243) (USER32.233)
427 */
428DWORD WIN32API GetDialogBaseUnits(void)
429{
430 return Win32Dialog::GetDialogBaseUnits();
431}
432//******************************************************************************
433//******************************************************************************
434INT WIN32API DlgDirListA(HWND hDlg, LPSTR spec, INT idLBox, INT idStatic, UINT attrib )
435{
436 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
437}
438//******************************************************************************
439//******************************************************************************
440int WIN32API DlgDirListW(HWND hDlg, LPWSTR spec, INT idLBox, INT idStatic, UINT attrib )
441{
442 return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
443}
444//******************************************************************************
445//******************************************************************************
446INT WIN32API DlgDirListComboBoxA(HWND hDlg, LPSTR spec, INT idCBox, INT idStatic, UINT attrib )
447{
448 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
449}
450//******************************************************************************
451//******************************************************************************
452INT WIN32API DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox, INT idStatic, UINT attrib )
453{
454 return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );
455}
456//******************************************************************************
457//******************************************************************************
458BOOL WIN32API DlgDirSelectComboBoxExA(HWND hwnd, LPSTR str, INT len, INT id )
459{
460 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, TRUE );
461}
462//******************************************************************************
463//******************************************************************************
464BOOL WIN32API DlgDirSelectComboBoxExW(HWND hwnd, LPWSTR str, INT len, INT id)
465{
466 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, TRUE );
467}
468//******************************************************************************
469//******************************************************************************
470BOOL WIN32API DlgDirSelectExA(HWND hwnd, LPSTR str, INT len, INT id)
471{
472 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, FALSE );
473}
474//******************************************************************************
475//******************************************************************************
476BOOL WIN32API DlgDirSelectExW(HWND hwnd, LPWSTR str, INT len, INT id)
477{
478 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, FALSE );
479}
480/**********************************************************************
481 * DIALOG_DlgDirSelect
482 *
483 * Helper function for DlgDirSelect*
484 */
485static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len,
486 INT id, BOOL win32, BOOL unicode,
487 BOOL combo )
488{
489 char *buffer, *ptr;
490 INT item, size;
491 BOOL ret;
492 HWND listbox = GetDlgItem( hwnd, id );
493
494 if (!listbox) return FALSE;
495
496 item = SendMessageA(listbox, combo ? CB_GETCURSEL
497 : LB_GETCURSEL, 0, 0 );
498 if (item == LB_ERR) return FALSE;
499 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN
500 : LB_GETTEXTLEN, 0, 0 );
501 if (size == LB_ERR) return FALSE;
502
503 if (!(buffer = (char *)malloc( size+1 ))) return FALSE;
504
505 SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT,
506 item, (LPARAM)buffer );
507
508 if ((ret = (buffer[0] == '[')) != 0) /* drive or directory */
509 {
510 if (buffer[1] == '-') /* drive */
511 {
512 buffer[3] = ':';
513 buffer[4] = 0;
514 ptr = buffer + 2;
515 }
516 else
517 {
518 buffer[strlen(buffer)-1] = '\\';
519 ptr = buffer + 1;
520 }
521 }
522 else ptr = buffer;
523
524 if (unicode) lstrcpynAtoW( (LPWSTR)str, ptr, len );
525 else lstrcpynA( str, ptr, len );
526
527 free( buffer );
528 return ret;
529}
530
531
532/**********************************************************************
533 * DIALOG_DlgDirList
534 *
535 * Helper function for DlgDirList*
536 */
537static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox,
538 INT idStatic, UINT attrib, BOOL combo )
539{
540 int drive;
541 HWND hwnd;
542 LPSTR orig_spec = spec;
543
544#define SENDMSG(msg,wparam,lparam) \
545 ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \
546 : SendMessageA( hwnd, msg, wparam, lparam ))
547
548 if (spec && spec[0] && (spec[1] == ':'))
549 {
550 drive = _toupper( spec[0] ) - 'A';
551 spec += 2;
552 if (!DRIVE_SetCurrentDrive( drive )) return FALSE;
553 }
554 else drive = DRIVE_GetCurrentDrive();
555
556 /* If the path exists and is a directory, chdir to it */
557 if (!spec || !spec[0] || DRIVE_Chdir( drive, spec )) spec = "*.*";
558 else
559 {
560 char *p, *p2;
561 p = spec;
562 if ((p2 = strrchr( p, '\\' )) != 0) p = p2;
563 if ((p2 = strrchr( p, '/' )) != 0) p = p2;
564 if (p != spec)
565 {
566 char sep = *p;
567 *p = 0;
568 if (!DRIVE_Chdir( drive, spec ))
569 {
570 *p = sep; /* Restore the original spec */
571 return FALSE;
572 }
573 spec = p + 1;
574 }
575 }
576
577 if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0))
578 {
579 SENDMSG( combo ? CB_RESETCONTENT : LB_RESETCONTENT, 0, 0 );
580 if (attrib & DDL_DIRECTORY)
581 {
582 if (!(attrib & DDL_EXCLUSIVE))
583 {
584 if (SENDMSG( combo ? CB_DIR : LB_DIR,
585 attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
586 (LPARAM)spec ) == LB_ERR)
587 return FALSE;
588 }
589 if (SENDMSG( combo ? CB_DIR : LB_DIR,
590 (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
591 (LPARAM)"*.*" ) == LB_ERR)
592 return FALSE;
593 }
594 else
595 {
596 if (SENDMSG( combo ? CB_DIR : LB_DIR, attrib,
597 (LPARAM)spec ) == LB_ERR)
598 return FALSE;
599 }
600 }
601
602 if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
603 {
604 char temp[512], curpath[512];
605 int drive = DRIVE_GetCurrentDrive();
606 strcpy( temp, "A:\\" );
607 temp[0] += drive;
608 lstrcpynA( temp + 3, DRIVE_GetDosCwd(curpath, drive), sizeof(temp)-3 );
609 CharLowerA( temp );
610 /* Can't use PostMessage() here, because the string is on the stack */
611 SetDlgItemTextA( hDlg, idStatic, temp );
612 }
613
614 if (orig_spec && (spec != orig_spec))
615 {
616 /* Update the original file spec */
617 char *p = spec;
618 while ((*orig_spec++ = *p++) != 0);
619 }
620
621 return TRUE;
622#undef SENDMSG
623}
624
625
626/**********************************************************************
627 * DIALOG_DlgDirListW
628 *
629 * Helper function for DlgDirList*32W
630 */
631static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
632 INT idStatic, UINT attrib, BOOL combo )
633{
634 if (spec)
635 {
636 LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
637 INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
638 attrib, combo );
639 lstrcpyAtoW( spec, specA );
640 HeapFree( GetProcessHeap(), 0, specA );
641 return ret;
642 }
643 return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
644}
645//******************************************************************************
646//******************************************************************************
647
Note: See TracBrowser for help on using the repository browser.