1 | /* $Id: windlg.cpp,v 1.3 1999-09-05 12:03:34 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 <string.h>
|
---|
19 | #include <stdlib.h>
|
---|
20 | #include "win32wbase.h"
|
---|
21 | #include "win32dlg.h"
|
---|
22 | #include <heapstring.h>
|
---|
23 | #include <win\drive.h>
|
---|
24 |
|
---|
25 | static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox, INT idStatic, UINT attrib, BOOL combo );
|
---|
26 | static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox, INT idStatic, UINT attrib, BOOL combo );
|
---|
27 | static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len, INT id, BOOL win32, BOOL unicode, BOOL combo );
|
---|
28 |
|
---|
29 | //******************************************************************************
|
---|
30 | //******************************************************************************
|
---|
31 | HWND WIN32API CreateDialogParamA(HINSTANCE hInst, LPCSTR lpszTemplate,
|
---|
32 | HWND hwndOwner, DLGPROC dlgproc,
|
---|
33 | LPARAM lParamInit)
|
---|
34 | {
|
---|
35 | HANDLE hrsrc = FindResourceA( hInst, lpszTemplate, RT_DIALOGA );
|
---|
36 |
|
---|
37 | if (!hrsrc)
|
---|
38 | return 0;
|
---|
39 |
|
---|
40 | return CreateDialogIndirectParamA(hInst, (DLGTEMPLATE*)LoadResource(hInst, hrsrc),
|
---|
41 | hwndOwner, dlgproc, lParamInit);
|
---|
42 | }
|
---|
43 | //******************************************************************************
|
---|
44 | //******************************************************************************
|
---|
45 | HWND WIN32API CreateDialogParamW(HINSTANCE hInst, LPCWSTR lpszTemplate,
|
---|
46 | HWND hwndOwner, DLGPROC dlgproc,
|
---|
47 | LPARAM lParamInit)
|
---|
48 | {
|
---|
49 | HANDLE hrsrc = FindResourceW( hInst, lpszTemplate, RT_DIALOGW );
|
---|
50 |
|
---|
51 | if (!hrsrc)
|
---|
52 | return 0;
|
---|
53 |
|
---|
54 | return CreateDialogIndirectParamW(hInst, (DLGTEMPLATE*)LoadResource(hInst, hrsrc),
|
---|
55 | hwndOwner, dlgproc, lParamInit);
|
---|
56 | }
|
---|
57 | //******************************************************************************
|
---|
58 | //******************************************************************************
|
---|
59 | HWND WIN32API CreateDialogIndirectParamA(HINSTANCE hInst,
|
---|
60 | DLGTEMPLATE *dlgtemplate,
|
---|
61 | HWND hwndParent, DLGPROC dlgproc,
|
---|
62 | LPARAM lParamInit)
|
---|
63 | {
|
---|
64 | Win32Dialog *dialog;
|
---|
65 |
|
---|
66 | dprintf(("CreateDialogIndirectParamA: %x %x %x %x %x", hInst, dlgtemplate, hwndParent, dlgproc, lParamInit));
|
---|
67 |
|
---|
68 | if (!dlgtemplate) return 0;
|
---|
69 |
|
---|
70 | dialog = new Win32Dialog(hInst, (LPCSTR)dlgtemplate, hwndParent, dlgproc, lParamInit, FALSE);
|
---|
71 |
|
---|
72 | if(dialog == NULL)
|
---|
73 | {
|
---|
74 | dprintf(("Win32Dialog creation failed!!"));
|
---|
75 | return 0;
|
---|
76 | }
|
---|
77 | if(GetLastError() != 0)
|
---|
78 | {
|
---|
79 | dprintf(("Win32Dialog error found!!"));
|
---|
80 | delete dialog;
|
---|
81 | return 0;
|
---|
82 | }
|
---|
83 | return dialog->getWindowHandle();
|
---|
84 | }
|
---|
85 | //******************************************************************************
|
---|
86 | //******************************************************************************
|
---|
87 | HWND WIN32API CreateDialogIndirectParamW(HINSTANCE hInst,
|
---|
88 | DLGTEMPLATE *dlgtemplate,
|
---|
89 | HWND hwndParent, DLGPROC dlgproc,
|
---|
90 | LPARAM lParamInit)
|
---|
91 | {
|
---|
92 | Win32Dialog *dialog;
|
---|
93 |
|
---|
94 | dprintf(("CreateDialogIndirectParamW: %x %x %x %x %x", hInst, dlgtemplate, hwndParent, dlgproc, lParamInit));
|
---|
95 |
|
---|
96 | if (!dlgtemplate) return 0;
|
---|
97 |
|
---|
98 | dialog = new Win32Dialog(hInst, (LPCSTR)dlgtemplate, hwndParent, dlgproc, lParamInit, TRUE);
|
---|
99 |
|
---|
100 | if(dialog == NULL)
|
---|
101 | {
|
---|
102 | dprintf(("Win32Dialog creation failed!!"));
|
---|
103 | return 0;
|
---|
104 | }
|
---|
105 | if(GetLastError() != 0)
|
---|
106 | {
|
---|
107 | dprintf(("Win32Dialog error found!!"));
|
---|
108 | delete dialog;
|
---|
109 | return 0;
|
---|
110 | }
|
---|
111 | return dialog->getWindowHandle();
|
---|
112 | }
|
---|
113 | //******************************************************************************
|
---|
114 | //******************************************************************************
|
---|
115 | INT WIN32API DialogBoxIndirectParamA(HINSTANCE hInst,
|
---|
116 | DLGTEMPLATE *dlgtemplate,
|
---|
117 | HWND hwndParent, DLGPROC dlgproc,
|
---|
118 | LPARAM lParamInit)
|
---|
119 | {
|
---|
120 | HWND hwnd = CreateDialogIndirectParamA(hInst, dlgtemplate, hwndParent, dlgproc,
|
---|
121 | lParamInit);
|
---|
122 | //TODO:
|
---|
123 | if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner );
|
---|
124 | return -1;
|
---|
125 | }
|
---|
126 | //******************************************************************************
|
---|
127 | //******************************************************************************
|
---|
128 | INT WIN32API DialogBoxIndirectParamW(HINSTANCE hInst, DLGTEMPLATE *dlgtemplate,
|
---|
129 | HWND hwndParent, DLGPROC dlgproc,
|
---|
130 | LPARAM lParamInit)
|
---|
131 | {
|
---|
132 | HWND hwnd = CreateDialogIndirectParamW(hInst, dlgtemplate, hwndParent, dlgproc,
|
---|
133 | lParamInit);
|
---|
134 | //TODO:
|
---|
135 | if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner );
|
---|
136 | return -1;
|
---|
137 | }
|
---|
138 | //******************************************************************************
|
---|
139 | //******************************************************************************
|
---|
140 | int WIN32API DialogBoxParamA(HINSTANCE hInst, LPCSTR lpszTemplate, HWND hwndOwner,
|
---|
141 | DLGPROC dlgproc, LPARAM lParamInit)
|
---|
142 | {
|
---|
143 | HWND hwnd = CreateDialogParamA( hInst, lpszTemplate, hwndOwner, dlgproc, lParamInit);
|
---|
144 | //TODO:
|
---|
145 | if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner );
|
---|
146 | return -1;
|
---|
147 | }
|
---|
148 | //******************************************************************************
|
---|
149 | //******************************************************************************
|
---|
150 | int WIN32API DialogBoxParamW(HINSTANCE hInst, LPCWSTR lpszTemplate, HWND hwndOwner,
|
---|
151 | DLGPROC dlgproc, LPARAM lParamInit)
|
---|
152 | {
|
---|
153 | HWND hwnd = CreateDialogParamW( hInst, lpszTemplate, hwndOwner, dlgproc, lParamInit);
|
---|
154 | //TODO:
|
---|
155 | if (hwnd) return 1; //return DIALOG_DoDialogBox( hwnd, owner );
|
---|
156 | return -1;
|
---|
157 | }
|
---|
158 | //******************************************************************************
|
---|
159 | //******************************************************************************
|
---|
160 | BOOL WIN32API IsDlgButtonChecked( HWND hwnd, UINT id)
|
---|
161 | {
|
---|
162 | dprintf(("USER32: IsDlgButtonChecked\n"));
|
---|
163 | //CB: get button state
|
---|
164 | return (BOOL)SendDlgItemMessageA(hwnd, id,BM_GETCHECK,0,0);
|
---|
165 | }
|
---|
166 | //******************************************************************************
|
---|
167 | //******************************************************************************
|
---|
168 | HWND WIN32API GetNextDlgTabItem(HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious)
|
---|
169 | {
|
---|
170 | Win32Dialog *dialog;
|
---|
171 |
|
---|
172 | dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwndDlg);
|
---|
173 | if(!dialog || !dialog->IsDialog()) {
|
---|
174 | dprintf(("GetNextDlgTabItem, window %x not found", hwndDlg));
|
---|
175 | return 0;
|
---|
176 | }
|
---|
177 | dprintf(("USER32: GetNextDlgTabItem\n"));
|
---|
178 | return dialog->getNextDlgTabItem(hwndCtrl, fPrevious);
|
---|
179 | }
|
---|
180 | //******************************************************************************
|
---|
181 | //******************************************************************************
|
---|
182 | HWND WIN32API GetDlgItem(HWND hwnd, int id)
|
---|
183 | {
|
---|
184 | Win32Dialog *dialog;
|
---|
185 | Win32BaseWindow *dlgcontrol;
|
---|
186 |
|
---|
187 | dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
188 | if(!dialog || !dialog->IsDialog()) {
|
---|
189 | dprintf(("GetDlgItem, window %x not found", hwnd));
|
---|
190 | return 0;
|
---|
191 | }
|
---|
192 | dprintf(("USER32: GetDlgItem\n"));
|
---|
193 | dlgcontrol = dialog->getDlgItem(id);
|
---|
194 | if(dlgcontrol) {
|
---|
195 | return dlgcontrol->getWindowHandle();
|
---|
196 | }
|
---|
197 | return 0;
|
---|
198 | }
|
---|
199 | //******************************************************************************
|
---|
200 | //******************************************************************************
|
---|
201 | int WIN32API GetDlgCtrlID(HWND hwnd)
|
---|
202 | {
|
---|
203 | Win32BaseWindow *dlgcontrol;
|
---|
204 |
|
---|
205 | dlgcontrol = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
206 | if(!dlgcontrol) {
|
---|
207 | dprintf(("GetDlgCtrlID, control %x not found", hwnd));
|
---|
208 | return 0;
|
---|
209 | }
|
---|
210 | dprintf(("USER32: GetDlgCtrlID\n"));
|
---|
211 | return dlgcontrol->getWindowId();
|
---|
212 | }
|
---|
213 | //******************************************************************************
|
---|
214 | //******************************************************************************
|
---|
215 | BOOL WIN32API EndDialog(HWND hwnd, int retval)
|
---|
216 | {
|
---|
217 | Win32Dialog *dialog;
|
---|
218 |
|
---|
219 | dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
220 | if(!dialog || !dialog->IsDialog()) {
|
---|
221 | dprintf(("GetDlgItem, window %x not found", hwnd));
|
---|
222 | return 0;
|
---|
223 | }
|
---|
224 | dprintf(("USER32: EndDialog\n"));
|
---|
225 | return dialog->endDialog(retval);
|
---|
226 | }
|
---|
227 | //******************************************************************************
|
---|
228 | //******************************************************************************
|
---|
229 | BOOL WIN32API CheckDlgButton( HWND hwnd, int id, UINT check)
|
---|
230 | {
|
---|
231 | dprintf(("USER32: CheckDlgButton\n"));
|
---|
232 | //CB: set button state
|
---|
233 | return (BOOL)SendDlgItemMessageA(hwnd, id, BM_SETCHECK, check,0);
|
---|
234 | }
|
---|
235 | //******************************************************************************
|
---|
236 | //******************************************************************************
|
---|
237 | UINT WIN32API GetDlgItemTextA(HWND hwnd, int id, LPSTR lpszName, UINT cch)
|
---|
238 | {
|
---|
239 | return SendDlgItemMessageA( hwnd, id, WM_GETTEXT, cch, (LPARAM)lpszName);
|
---|
240 | }
|
---|
241 | //*****************************************************************************
|
---|
242 | //*****************************************************************************
|
---|
243 | UINT WIN32API GetDlgItemTextW(HWND hwnd, int id, LPWSTR lpszName, UINT cch)
|
---|
244 | {
|
---|
245 | return SendDlgItemMessageW( hwnd, id, WM_GETTEXT, cch, (LPARAM)lpszName);
|
---|
246 | }
|
---|
247 | //******************************************************************************
|
---|
248 | //******************************************************************************
|
---|
249 | BOOL WIN32API SetDlgItemInt( HWND hwnd, int idControl, UINT uValue, BOOL fSigned)
|
---|
250 | {
|
---|
251 | char str[20];
|
---|
252 |
|
---|
253 | dprintf(("USER32: SetDlgItemInt\n"));
|
---|
254 |
|
---|
255 | if (fSigned)
|
---|
256 | sprintf( str, "%d", (INT)uValue );
|
---|
257 | else sprintf( str, "%u", uValue );
|
---|
258 |
|
---|
259 | return SendDlgItemMessageA( hwnd, idControl, WM_SETTEXT, 0, (LPARAM)str );
|
---|
260 | }
|
---|
261 | //******************************************************************************
|
---|
262 | //******************************************************************************
|
---|
263 | BOOL WIN32API SetDlgItemTextA( HWND hwnd, int id, LPCSTR lpszName)
|
---|
264 | {
|
---|
265 | return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpszName );
|
---|
266 | }
|
---|
267 | //******************************************************************************
|
---|
268 | //******************************************************************************
|
---|
269 | BOOL WIN32API SetDlgItemTextW( HWND hwnd, int id, LPCWSTR lpszName)
|
---|
270 | {
|
---|
271 | return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpszName );
|
---|
272 | }
|
---|
273 | //******************************************************************************
|
---|
274 | //******************************************************************************
|
---|
275 | UINT WIN32API GetDlgItemInt( HWND arg1, int arg2, PBOOL arg3, BOOL arg4)
|
---|
276 | {
|
---|
277 | #ifdef DEBUG
|
---|
278 | WriteLog("USER32: GetDlgItemInt\n");
|
---|
279 | #endif
|
---|
280 | return O32_GetDlgItemInt(arg1, arg2, arg3, arg4);
|
---|
281 | }
|
---|
282 | //******************************************************************************
|
---|
283 | //******************************************************************************
|
---|
284 | HWND WIN32API GetNextDlgGroupItem( HWND arg1, HWND arg2, BOOL arg3)
|
---|
285 | {
|
---|
286 | #ifdef DEBUG
|
---|
287 | WriteLog("USER32: GetNextDlgGroupItem\n");
|
---|
288 | #endif
|
---|
289 | return O32_GetNextDlgGroupItem(arg1, arg2, arg3);
|
---|
290 | }
|
---|
291 | /***********************************************************************
|
---|
292 | * GetDialogBaseUnits (USER.243) (USER32.233)
|
---|
293 | */
|
---|
294 | DWORD WIN32API GetDialogBaseUnits(void)
|
---|
295 | {
|
---|
296 | return Win32Dialog::GetDialogBaseUnits();
|
---|
297 | }
|
---|
298 | //******************************************************************************
|
---|
299 | //******************************************************************************
|
---|
300 | INT WIN32API DlgDirListA(HWND hDlg, LPSTR spec, INT idLBox, INT idStatic, UINT attrib )
|
---|
301 | {
|
---|
302 | return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
|
---|
303 | }
|
---|
304 | //******************************************************************************
|
---|
305 | //******************************************************************************
|
---|
306 | int WIN32API DlgDirListW(HWND hDlg, LPWSTR spec, INT idLBox, INT idStatic, UINT attrib )
|
---|
307 | {
|
---|
308 | return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
|
---|
309 | }
|
---|
310 | //******************************************************************************
|
---|
311 | //******************************************************************************
|
---|
312 | INT WIN32API DlgDirListComboBoxA(HWND hDlg, LPSTR spec, INT idCBox, INT idStatic, UINT attrib )
|
---|
313 | {
|
---|
314 | return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
|
---|
315 | }
|
---|
316 | //******************************************************************************
|
---|
317 | //******************************************************************************
|
---|
318 | INT WIN32API DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox, INT idStatic, UINT attrib )
|
---|
319 | {
|
---|
320 | return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );
|
---|
321 | }
|
---|
322 | //******************************************************************************
|
---|
323 | //******************************************************************************
|
---|
324 | BOOL WIN32API DlgDirSelectComboBoxExA(HWND hwnd, LPSTR str, INT len, INT id )
|
---|
325 | {
|
---|
326 | return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, TRUE );
|
---|
327 | }
|
---|
328 | //******************************************************************************
|
---|
329 | //******************************************************************************
|
---|
330 | BOOL WIN32API DlgDirSelectComboBoxExW(HWND hwnd, LPWSTR str, INT len, INT id)
|
---|
331 | {
|
---|
332 | return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, TRUE );
|
---|
333 | }
|
---|
334 | //******************************************************************************
|
---|
335 | //******************************************************************************
|
---|
336 | BOOL WIN32API DlgDirSelectExA(HWND hwnd, LPSTR str, INT len, INT id)
|
---|
337 | {
|
---|
338 | return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, FALSE );
|
---|
339 | }
|
---|
340 | //******************************************************************************
|
---|
341 | //******************************************************************************
|
---|
342 | BOOL WIN32API DlgDirSelectExW(HWND hwnd, LPWSTR str, INT len, INT id)
|
---|
343 | {
|
---|
344 | return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, FALSE );
|
---|
345 | }
|
---|
346 | /**********************************************************************
|
---|
347 | * DIALOG_DlgDirSelect
|
---|
348 | *
|
---|
349 | * Helper function for DlgDirSelect*
|
---|
350 | */
|
---|
351 | static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len,
|
---|
352 | INT id, BOOL win32, BOOL unicode,
|
---|
353 | BOOL combo )
|
---|
354 | {
|
---|
355 | char *buffer, *ptr;
|
---|
356 | INT item, size;
|
---|
357 | BOOL ret;
|
---|
358 | HWND listbox = GetDlgItem( hwnd, id );
|
---|
359 |
|
---|
360 | if (!listbox) return FALSE;
|
---|
361 |
|
---|
362 | item = SendMessageA(listbox, combo ? CB_GETCURSEL
|
---|
363 | : LB_GETCURSEL, 0, 0 );
|
---|
364 | if (item == LB_ERR) return FALSE;
|
---|
365 | size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN
|
---|
366 | : LB_GETTEXTLEN, 0, 0 );
|
---|
367 | if (size == LB_ERR) return FALSE;
|
---|
368 |
|
---|
369 | if (!(buffer = (char *)malloc( size+1 ))) return FALSE;
|
---|
370 |
|
---|
371 | SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT,
|
---|
372 | item, (LPARAM)buffer );
|
---|
373 |
|
---|
374 | if ((ret = (buffer[0] == '['))) /* drive or directory */
|
---|
375 | {
|
---|
376 | if (buffer[1] == '-') /* drive */
|
---|
377 | {
|
---|
378 | buffer[3] = ':';
|
---|
379 | buffer[4] = 0;
|
---|
380 | ptr = buffer + 2;
|
---|
381 | }
|
---|
382 | else
|
---|
383 | {
|
---|
384 | buffer[strlen(buffer)-1] = '\\';
|
---|
385 | ptr = buffer + 1;
|
---|
386 | }
|
---|
387 | }
|
---|
388 | else ptr = buffer;
|
---|
389 |
|
---|
390 | if (unicode) lstrcpynAtoW( (LPWSTR)str, ptr, len );
|
---|
391 | else lstrcpynA( str, ptr, len );
|
---|
392 |
|
---|
393 | free( buffer );
|
---|
394 | return ret;
|
---|
395 | }
|
---|
396 |
|
---|
397 |
|
---|
398 | /**********************************************************************
|
---|
399 | * DIALOG_DlgDirList
|
---|
400 | *
|
---|
401 | * Helper function for DlgDirList*
|
---|
402 | */
|
---|
403 | static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox,
|
---|
404 | INT idStatic, UINT attrib, BOOL combo )
|
---|
405 | {
|
---|
406 | int drive;
|
---|
407 | HWND hwnd;
|
---|
408 | LPSTR orig_spec = spec;
|
---|
409 |
|
---|
410 | #define SENDMSG(msg,wparam,lparam) \
|
---|
411 | ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \
|
---|
412 | : SendMessageA( hwnd, msg, wparam, lparam ))
|
---|
413 |
|
---|
414 | if (spec && spec[0] && (spec[1] == ':'))
|
---|
415 | {
|
---|
416 | drive = _toupper( spec[0] ) - 'A';
|
---|
417 | spec += 2;
|
---|
418 | if (!DRIVE_SetCurrentDrive( drive )) return FALSE;
|
---|
419 | }
|
---|
420 | else drive = DRIVE_GetCurrentDrive();
|
---|
421 |
|
---|
422 | /* If the path exists and is a directory, chdir to it */
|
---|
423 | if (!spec || !spec[0] || DRIVE_Chdir( drive, spec )) spec = "*.*";
|
---|
424 | else
|
---|
425 | {
|
---|
426 | char *p, *p2;
|
---|
427 | p = spec;
|
---|
428 | if ((p2 = strrchr( p, '\\' ))) p = p2;
|
---|
429 | if ((p2 = strrchr( p, '/' ))) p = p2;
|
---|
430 | if (p != spec)
|
---|
431 | {
|
---|
432 | char sep = *p;
|
---|
433 | *p = 0;
|
---|
434 | if (!DRIVE_Chdir( drive, spec ))
|
---|
435 | {
|
---|
436 | *p = sep; /* Restore the original spec */
|
---|
437 | return FALSE;
|
---|
438 | }
|
---|
439 | spec = p + 1;
|
---|
440 | }
|
---|
441 | }
|
---|
442 |
|
---|
443 | if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0))
|
---|
444 | {
|
---|
445 | SENDMSG( combo ? CB_RESETCONTENT : LB_RESETCONTENT, 0, 0 );
|
---|
446 | if (attrib & DDL_DIRECTORY)
|
---|
447 | {
|
---|
448 | if (!(attrib & DDL_EXCLUSIVE))
|
---|
449 | {
|
---|
450 | if (SENDMSG( combo ? CB_DIR : LB_DIR,
|
---|
451 | attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
|
---|
452 | (LPARAM)spec ) == LB_ERR)
|
---|
453 | return FALSE;
|
---|
454 | }
|
---|
455 | if (SENDMSG( combo ? CB_DIR : LB_DIR,
|
---|
456 | (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
|
---|
457 | (LPARAM)"*.*" ) == LB_ERR)
|
---|
458 | return FALSE;
|
---|
459 | }
|
---|
460 | else
|
---|
461 | {
|
---|
462 | if (SENDMSG( combo ? CB_DIR : LB_DIR, attrib,
|
---|
463 | (LPARAM)spec ) == LB_ERR)
|
---|
464 | return FALSE;
|
---|
465 | }
|
---|
466 | }
|
---|
467 |
|
---|
468 | if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
|
---|
469 | {
|
---|
470 | char temp[512], curpath[512];
|
---|
471 | int drive = DRIVE_GetCurrentDrive();
|
---|
472 | strcpy( temp, "A:\\" );
|
---|
473 | temp[0] += drive;
|
---|
474 | lstrcpynA( temp + 3, DRIVE_GetDosCwd(curpath, drive), sizeof(temp)-3 );
|
---|
475 | CharLowerA( temp );
|
---|
476 | /* Can't use PostMessage() here, because the string is on the stack */
|
---|
477 | SetDlgItemTextA( hDlg, idStatic, temp );
|
---|
478 | }
|
---|
479 |
|
---|
480 | if (orig_spec && (spec != orig_spec))
|
---|
481 | {
|
---|
482 | /* Update the original file spec */
|
---|
483 | char *p = spec;
|
---|
484 | while ((*orig_spec++ = *p++));
|
---|
485 | }
|
---|
486 |
|
---|
487 | return TRUE;
|
---|
488 | #undef SENDMSG
|
---|
489 | }
|
---|
490 |
|
---|
491 |
|
---|
492 | /**********************************************************************
|
---|
493 | * DIALOG_DlgDirListW
|
---|
494 | *
|
---|
495 | * Helper function for DlgDirList*32W
|
---|
496 | */
|
---|
497 | static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
|
---|
498 | INT idStatic, UINT attrib, BOOL combo )
|
---|
499 | {
|
---|
500 | if (spec)
|
---|
501 | {
|
---|
502 | LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
|
---|
503 | INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
|
---|
504 | attrib, combo );
|
---|
505 | lstrcpyAtoW( spec, specA );
|
---|
506 | HeapFree( GetProcessHeap(), 0, specA );
|
---|
507 | return ret;
|
---|
508 | }
|
---|
509 | return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
|
---|
510 | }
|
---|
511 | //******************************************************************************
|
---|
512 | //******************************************************************************
|
---|
513 |
|
---|