1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: walkem.c 1027 2008-06-20 03:04:46Z jbs $
|
---|
5 |
|
---|
6 | Copyright (c) 1993-98 M. Kimes
|
---|
7 | Copyright (c) 2005, 2007 Steven H. Levine
|
---|
8 |
|
---|
9 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
10 | 05 Jun 05 SHL Use QWL_USER
|
---|
11 | 13 Aug 05 SHL Run through indent
|
---|
12 | 13 Aug 05 SHL remove_udir - avoid corrupting last dirs list
|
---|
13 | 17 Jul 06 SHL Use Runtime_Error
|
---|
14 | 29 Jul 06 SHL Use xfgets
|
---|
15 | 20 Oct 06 SHL Correct . .. check
|
---|
16 | 06 Nov 06 SHL Oops - need to allow .. here
|
---|
17 | 14 Nov 06 SHL Correct FillPathListBox regression
|
---|
18 | 22 Mar 07 GKY Use QWL_USER
|
---|
19 | 20 Apr 07 SHL Avoid spurious add_udir error reports
|
---|
20 | 16 Aug 07 SHL Update add_setups for ticket# 109
|
---|
21 | 19 Aug 07 SHL Correct load_setups error reporting
|
---|
22 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
23 | 25 Aug 07 SHL Correct #pragma alloc_text typos
|
---|
24 | 11 Nov 07 GKY Cancel now directly closes dialog even if directory path text has changed
|
---|
25 | 20 Jan 08 GKY Walk & walk2 dialogs now save and restore size and position
|
---|
26 | 19 Feb 08 JBS Add "State at last FM/2 close" to the states combo box
|
---|
27 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
28 | 29 Feb 08 GKY Refactor global command line variables to notebook.h
|
---|
29 | 19 Jun 08 JBS Ticket 227: Allow temporary saving/deleting of the shutdown state of directory containers
|
---|
30 |
|
---|
31 | ***********************************************************************/
|
---|
32 |
|
---|
33 | #include <stdlib.h>
|
---|
34 | #include <string.h>
|
---|
35 | #include <ctype.h>
|
---|
36 | #include <share.h>
|
---|
37 |
|
---|
38 | #define INCL_WIN
|
---|
39 | #define INCL_DOS
|
---|
40 | #define INCL_DOSERRORS
|
---|
41 | #define INCL_SHLERRORS // PMERR_NOT_IN_IDX
|
---|
42 | #define INCL_LONGLONG
|
---|
43 |
|
---|
44 | #include "fm3dlg.h"
|
---|
45 | #include "fm3str.h"
|
---|
46 | #include "errutil.h" // Dos_Error...
|
---|
47 | #include "strutil.h" // GetPString
|
---|
48 | #include "notebook.h" // targetdirectory
|
---|
49 | #include "fm3dll.h"
|
---|
50 |
|
---|
51 | #pragma data_seg(DATA1)
|
---|
52 |
|
---|
53 | static PSZ pszSrcFile = __FILE__;
|
---|
54 |
|
---|
55 |
|
---|
56 | typedef struct
|
---|
57 | {
|
---|
58 | USHORT size;
|
---|
59 | USHORT changed;
|
---|
60 | BOOL nounwriteable;
|
---|
61 | CHAR szCurrentPath[CCHMAXPATH];
|
---|
62 | CHAR *szReturnPath;
|
---|
63 | }
|
---|
64 | WALKER;
|
---|
65 |
|
---|
66 | static CHAR WalkFont[CCHMAXPATH] = "";
|
---|
67 | static ULONG WalkFontSize = sizeof(WalkFont);
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * States names management
|
---|
71 | */
|
---|
72 |
|
---|
73 | static BOOL fSetupsLoaded;
|
---|
74 | static LINKDIRS *pFirstSetup;
|
---|
75 | static const PSZ pszLastSetups = "LastSetups";
|
---|
76 | // 18 Aug 07 SHL fixme to stop supporting old style 1 year from now?
|
---|
77 | static const ULONG ulOldSetupsBytes = 100 * 13; // Prior to 3.0.7
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Fill States drop down list with known state names
|
---|
81 | */
|
---|
82 |
|
---|
83 | VOID fill_setups_list(VOID)
|
---|
84 | {
|
---|
85 | WinSendMsg(hwndStatelist, LM_DELETEALL, MPVOID, MPVOID);
|
---|
86 | if (fUserComboBox) {
|
---|
87 | LINKDIRS *pld;
|
---|
88 | load_setups();
|
---|
89 | for (pld = pFirstSetup; pld; pld = pld->next) {
|
---|
90 | // DbgMsg(pszSrcFile, __LINE__, "Inserted %s", pld->path);
|
---|
91 | WinSendMsg(hwndStatelist,
|
---|
92 | LM_INSERTITEM,
|
---|
93 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
94 | MPFROMP(pld->path));
|
---|
95 | }
|
---|
96 | WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * Lookup setup and do requested action
|
---|
102 | * @param - action, Support old/new style storage method
|
---|
103 | * @return 1 if found and action OK, 0 if not found and action OK, -1 if error during action
|
---|
104 | */
|
---|
105 |
|
---|
106 | #define LS_FIND 0
|
---|
107 | #define LS_ADD 1
|
---|
108 | #define LS_DELETE 2
|
---|
109 |
|
---|
110 | static INT lookup_setup(PSZ name, UINT action)
|
---|
111 | {
|
---|
112 | LINKDIRS *pld;
|
---|
113 | LINKDIRS *pldLast = NULL;
|
---|
114 |
|
---|
115 | if (!name || !*name) {
|
---|
116 | Runtime_Error(pszSrcFile, __LINE__, "no data");
|
---|
117 | return -1;
|
---|
118 | }
|
---|
119 |
|
---|
120 | load_setups();
|
---|
121 |
|
---|
122 | for (pld = pFirstSetup; pld; pld = pld->next) {
|
---|
123 | if (!stricmp(pld->path, name)) {
|
---|
124 | if (action == LS_DELETE) {
|
---|
125 | if (pldLast)
|
---|
126 | pldLast->next = pld->next;
|
---|
127 | else
|
---|
128 | pFirstSetup = pld->next;
|
---|
129 | xfree(pld->path, pszSrcFile, __LINE__);
|
---|
130 | xfree(pld, pszSrcFile, __LINE__);
|
---|
131 | }
|
---|
132 | return 1; // Found or added
|
---|
133 | }
|
---|
134 | pldLast = pld; // In case deleting
|
---|
135 | } // for
|
---|
136 |
|
---|
137 | // Not found
|
---|
138 | if (action == LS_ADD) {
|
---|
139 | pld = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
---|
140 | if (!pld)
|
---|
141 | return -1;
|
---|
142 | pld->path = xstrdup(name, pszSrcFile, __LINE__);
|
---|
143 | if (!pld->path) {
|
---|
144 | xfree(pld, pszSrcFile, __LINE__);
|
---|
145 | return -1;
|
---|
146 | }
|
---|
147 | // Insert at front of list - drop down will sort
|
---|
148 | pld->next = pFirstSetup;
|
---|
149 | pFirstSetup = pld;
|
---|
150 | return 0;
|
---|
151 | }
|
---|
152 |
|
---|
153 | return FALSE; // Not found
|
---|
154 | }
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * Load state names from ini
|
---|
158 | * Support old/new style storage method
|
---|
159 | */
|
---|
160 |
|
---|
161 | VOID load_setups(VOID)
|
---|
162 | {
|
---|
163 | ULONG ulDataBytes;
|
---|
164 | ULONG l;
|
---|
165 | PSZ pszBuf;
|
---|
166 | PSZ psz;
|
---|
167 | LINKDIRS *pld;
|
---|
168 |
|
---|
169 | if (fSetupsLoaded)
|
---|
170 | return;
|
---|
171 |
|
---|
172 | if (!PrfQueryProfileSize(fmprof, FM3Str, pszLastSetups, &ulDataBytes)) {
|
---|
173 | // fixme to use generic hab
|
---|
174 | ERRORID eid = WinGetLastError((HAB)0);
|
---|
175 | if ((eid & 0xffff) != PMERR_NOT_IN_IDX) {
|
---|
176 | // Get error info back
|
---|
177 | PrfQueryProfileSize(fmprof, FM3Str, pszLastSetups, &ulDataBytes);
|
---|
178 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, "PrfQueryProfileSize");
|
---|
179 | }
|
---|
180 | else
|
---|
181 | fSetupsLoaded = TRUE; // Nothing saved
|
---|
182 | return;
|
---|
183 | }
|
---|
184 |
|
---|
185 | if (ulDataBytes == 0) {
|
---|
186 | Runtime_Error(pszSrcFile, __LINE__, "PrfQueryProfileSize reported 0 bytes");
|
---|
187 | return;
|
---|
188 | }
|
---|
189 |
|
---|
190 | pszBuf = xmalloc(ulDataBytes + 1, pszSrcFile, __LINE__); // One extra for end marker
|
---|
191 | if (!pszBuf)
|
---|
192 | return;
|
---|
193 | l = ulDataBytes;
|
---|
194 | if (!PrfQueryProfileData(fmprof, FM3Str, pszLastSetups, pszBuf, &l)) {
|
---|
195 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, "PrfQueryProfileData");
|
---|
196 | xfree(pszBuf, pszSrcFile, __LINE__);
|
---|
197 | return;
|
---|
198 | }
|
---|
199 |
|
---|
200 | if (ulDataBytes != l) {
|
---|
201 | Runtime_Error(pszSrcFile, __LINE__, "PrfQueryProfileData reported %u expected %u", l, ulDataBytes);
|
---|
202 | xfree(pszBuf, pszSrcFile, __LINE__);
|
---|
203 | return;
|
---|
204 | }
|
---|
205 |
|
---|
206 | *(pszBuf + ulDataBytes) = 0; // Insert end marker
|
---|
207 |
|
---|
208 | psz = pszBuf;
|
---|
209 | if (!*psz && ulDataBytes == ulOldSetupsBytes)
|
---|
210 | psz += 13; // Rarely used 1st fixed width entry prior to 3.0.7
|
---|
211 |
|
---|
212 | while (*psz) {
|
---|
213 | pld = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
---|
214 | if (!pld) {
|
---|
215 | xfree(pszBuf, pszSrcFile, __LINE__);
|
---|
216 | return;
|
---|
217 | }
|
---|
218 | pld->path = xstrdup(psz, pszSrcFile, __LINE__);
|
---|
219 | if (!pld->path) {
|
---|
220 | xfree(pszBuf, pszSrcFile, __LINE__);
|
---|
221 | xfree(pld, pszSrcFile, __LINE__);
|
---|
222 | return;
|
---|
223 | }
|
---|
224 |
|
---|
225 | // Insert at front of list - drop down will sort
|
---|
226 | pld->next = pFirstSetup;
|
---|
227 | pFirstSetup = pld;
|
---|
228 | // DbgMsg(pszSrcFile, __LINE__, "Inserted %s", pld->path);
|
---|
229 |
|
---|
230 | if (ulDataBytes == ulOldSetupsBytes)
|
---|
231 | psz += 13; // Buffers fixed width prior to 3.0.7
|
---|
232 | else
|
---|
233 | psz += strlen(psz) + 1;
|
---|
234 | } // while
|
---|
235 |
|
---|
236 | xfree(pszBuf, pszSrcFile, __LINE__);
|
---|
237 |
|
---|
238 | fSetupsLoaded = TRUE;
|
---|
239 | }
|
---|
240 |
|
---|
241 | VOID save_setups(VOID)
|
---|
242 | {
|
---|
243 | ULONG ulBufBytes;
|
---|
244 | ULONG ulFillBytes;
|
---|
245 | ULONG l;
|
---|
246 | PSZ pszBuf;
|
---|
247 | PSZ psz;
|
---|
248 | LINKDIRS *pld;
|
---|
249 |
|
---|
250 | if (!fSetupsLoaded)
|
---|
251 | return;
|
---|
252 |
|
---|
253 | ulBufBytes = 0;
|
---|
254 | for (pld = pFirstSetup; pld; pld = pld->next) {
|
---|
255 | ulBufBytes += strlen(pld->path) + 1;
|
---|
256 | } // for
|
---|
257 |
|
---|
258 | if (!ulBufBytes)
|
---|
259 | pszBuf = NULL;
|
---|
260 | else {
|
---|
261 | // Ensure different than size prior to 3.0.7
|
---|
262 | ulFillBytes = ulBufBytes == ulOldSetupsBytes ? 1 : 0;
|
---|
263 | pszBuf = xmalloc(ulBufBytes + ulFillBytes, pszSrcFile, __LINE__);
|
---|
264 | if (!pszBuf)
|
---|
265 | return;
|
---|
266 |
|
---|
267 | psz = pszBuf;
|
---|
268 | for (pld = pFirstSetup; pld; pld = pld->next) {
|
---|
269 | l = strlen(pld->path) + 1;
|
---|
270 | memcpy(psz, pld->path, l);
|
---|
271 | psz += l;
|
---|
272 | } // for
|
---|
273 | if (ulFillBytes)
|
---|
274 | *psz = 0;
|
---|
275 | }
|
---|
276 |
|
---|
277 | if (!PrfWriteProfileData(fmprof,
|
---|
278 | FM3Str,
|
---|
279 | pszLastSetups, pszBuf, ulBufBytes)) {
|
---|
280 | // Win_Error(pszSrcFile, __LINE__, HWND_DESKTOP, HWND_DESKTOP, "PrfWriteProfileData");
|
---|
281 | ERRORID eid = WinGetLastError((HAB)0);
|
---|
282 | if ((eid & 0xffff) != PMERR_NOT_IN_IDX)
|
---|
283 | Runtime_Error(pszSrcFile, __LINE__, "PrfWriteProfileData returned %u", eid);
|
---|
284 | }
|
---|
285 |
|
---|
286 | // Delete obsolete INI entry
|
---|
287 | PrfWriteProfileData(fmprof, FM3Str, "LastSetup", NULL, 0);
|
---|
288 | }
|
---|
289 |
|
---|
290 | /**
|
---|
291 | * Add named state to setups list
|
---|
292 | * @return same as lookup_setup
|
---|
293 | */
|
---|
294 |
|
---|
295 | INT add_setup(PSZ name)
|
---|
296 | {
|
---|
297 | return lookup_setup(name, LS_ADD);
|
---|
298 | }
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * Delete named state from setups list
|
---|
302 | * @return same as lookup_setup
|
---|
303 | */
|
---|
304 |
|
---|
305 | INT remove_setup(PSZ name)
|
---|
306 | {
|
---|
307 | return lookup_setup(name, LS_DELETE);
|
---|
308 | }
|
---|
309 |
|
---|
310 | VOID load_udirs(VOID)
|
---|
311 | {
|
---|
312 | /* load linked list of user directories from USERDIRS.DAT file */
|
---|
313 |
|
---|
314 | FILE *fp;
|
---|
315 | LINKDIRS *info;
|
---|
316 | LINKDIRS *last = NULL;
|
---|
317 | CHAR s[CCHMAXPATH + 24];
|
---|
318 |
|
---|
319 | loadedudirs = TRUE;
|
---|
320 | fUdirsChanged = FALSE;
|
---|
321 | save_dir2(s);
|
---|
322 | if (s[strlen(s) - 1] != '\\')
|
---|
323 | strcat(s, "\\");
|
---|
324 | strcat(s, "USERDIRS.DAT");
|
---|
325 | fp = _fsopen(s, "r", SH_DENYWR);
|
---|
326 | if (fp) {
|
---|
327 | while (!feof(fp)) {
|
---|
328 | if (!xfgets(s, CCHMAXPATH + 24, fp, pszSrcFile, __LINE__))
|
---|
329 | break;
|
---|
330 | s[CCHMAXPATH] = 0;
|
---|
331 | bstripcr(s);
|
---|
332 | if (*s && *s != ';') {
|
---|
333 | info = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
---|
334 | if (info) {
|
---|
335 | info->path = xstrdup(s, pszSrcFile, __LINE__);
|
---|
336 | if (!info->path)
|
---|
337 | xfree(info, pszSrcFile, __LINE__);
|
---|
338 | else {
|
---|
339 | info->next = NULL;
|
---|
340 | if (!udirhead)
|
---|
341 | udirhead = info;
|
---|
342 | else
|
---|
343 | last->next = info;
|
---|
344 | last = info;
|
---|
345 | }
|
---|
346 | }
|
---|
347 | }
|
---|
348 | }
|
---|
349 | fclose(fp);
|
---|
350 | }
|
---|
351 | }
|
---|
352 |
|
---|
353 | VOID save_udirs(VOID)
|
---|
354 | {
|
---|
355 | FILE *fp;
|
---|
356 | LINKDIRS *info;
|
---|
357 | CHAR s[CCHMAXPATH + 14];
|
---|
358 |
|
---|
359 | if (loadedudirs) {
|
---|
360 | fUdirsChanged = FALSE;
|
---|
361 | if (udirhead) {
|
---|
362 | save_dir2(s);
|
---|
363 | if (s[strlen(s) - 1] != '\\')
|
---|
364 | strcat(s, "\\");
|
---|
365 | strcat(s, "USERDIRS.DAT");
|
---|
366 | fp = xfopen(s, "w", pszSrcFile, __LINE__);
|
---|
367 | if (fp) {
|
---|
368 | fputs(GetPString(IDS_USERDEFDIRSTEXT), fp);
|
---|
369 | info = udirhead;
|
---|
370 | while (info) {
|
---|
371 | fprintf(fp, "%0.*s\n", CCHMAXPATH, info->path);
|
---|
372 | info = info->next;
|
---|
373 | }
|
---|
374 | fclose(fp);
|
---|
375 | }
|
---|
376 | }
|
---|
377 | }
|
---|
378 | }
|
---|
379 |
|
---|
380 | /**
|
---|
381 | * Add path to user directory list or last used directory list.
|
---|
382 | * Callers need to check fUdirsChanged to know if user dirs change occured.
|
---|
383 | * Callers need to check return code to know if last dirs change occured.
|
---|
384 | * @param userdirs TRUE to process user directory list. Otherwise last used list.
|
---|
385 | * @return TRUE if added, FALSE if already in list or error.
|
---|
386 | */
|
---|
387 |
|
---|
388 | BOOL add_udir(BOOL userdirs, CHAR *inpath)
|
---|
389 | {
|
---|
390 | CHAR path[CCHMAXPATH];
|
---|
391 | LINKDIRS *info;
|
---|
392 | LINKDIRS *last = NULL;
|
---|
393 | LINKDIRS *temp;
|
---|
394 |
|
---|
395 | if (inpath && *inpath) {
|
---|
396 | if (DosQueryPathInfo(inpath, FIL_QUERYFULLNAME, path, sizeof(path)))
|
---|
397 | strcpy(path, inpath);
|
---|
398 | if (!userdirs && IsRoot(path))
|
---|
399 | return FALSE;
|
---|
400 | if (IsFullName(path)) {
|
---|
401 | if (!loadedudirs)
|
---|
402 | load_udirs();
|
---|
403 | // Search user dir list first unless doing last dirs
|
---|
404 | info = userdirs ? udirhead : ldirhead;
|
---|
405 | while (info) {
|
---|
406 | if (!stricmp(info->path, path))
|
---|
407 | return FALSE; // Already in list
|
---|
408 | last = info; // Remember append to location
|
---|
409 | info = info->next;
|
---|
410 | }
|
---|
411 | // Search last dir list unless doing just last dirs
|
---|
412 | if (!userdirs) {
|
---|
413 | info = udirhead;
|
---|
414 | while (info) {
|
---|
415 | if (!stricmp(info->path, path))
|
---|
416 | return FALSE;
|
---|
417 | info = info->next;
|
---|
418 | }
|
---|
419 | }
|
---|
420 | else {
|
---|
421 | /* if adding manual directory, remove from auto list if present */
|
---|
422 | info = ldirhead;
|
---|
423 | temp = NULL;
|
---|
424 | while (info) {
|
---|
425 | if (!stricmp(info->path, path)) {
|
---|
426 | if (temp)
|
---|
427 | temp->next = info->next;
|
---|
428 | else
|
---|
429 | ldirhead = info->next;
|
---|
430 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
431 | xfree(info, pszSrcFile, __LINE__);
|
---|
432 | break;
|
---|
433 | }
|
---|
434 | temp = info;
|
---|
435 | info = info->next;
|
---|
436 | }
|
---|
437 | }
|
---|
438 | // Append entry to end of user dirs list
|
---|
439 | info = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
---|
440 | if (info) {
|
---|
441 | info->path = xstrdup(path, pszSrcFile, __LINE__);
|
---|
442 | if (!info->path)
|
---|
443 | xfree(info, pszSrcFile, __LINE__);
|
---|
444 | else {
|
---|
445 | info->next = NULL;
|
---|
446 | if (userdirs) {
|
---|
447 | fUdirsChanged = TRUE;
|
---|
448 | if (!udirhead)
|
---|
449 | udirhead = info;
|
---|
450 | else
|
---|
451 | last->next = info;
|
---|
452 | }
|
---|
453 | else {
|
---|
454 | if (!ldirhead)
|
---|
455 | ldirhead = info;
|
---|
456 | else
|
---|
457 | last->next = info;
|
---|
458 | }
|
---|
459 | return TRUE;
|
---|
460 | }
|
---|
461 | }
|
---|
462 | }
|
---|
463 | }
|
---|
464 | return FALSE;
|
---|
465 | }
|
---|
466 |
|
---|
467 | //=== remove_udir - remove path from user dir list or last directory list ===
|
---|
468 |
|
---|
469 | BOOL remove_udir(CHAR * path)
|
---|
470 | {
|
---|
471 | LINKDIRS *info;
|
---|
472 | LINKDIRS *last = NULL;
|
---|
473 |
|
---|
474 | if (path && *path) {
|
---|
475 | if (!loadedudirs)
|
---|
476 | load_udirs();
|
---|
477 | info = udirhead;
|
---|
478 | while (info) {
|
---|
479 | if (!stricmp(info->path, path)) {
|
---|
480 | if (last)
|
---|
481 | last->next = info->next;
|
---|
482 | else
|
---|
483 | udirhead = info->next;
|
---|
484 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
485 | xfree(info, pszSrcFile, __LINE__);
|
---|
486 | fUdirsChanged = TRUE;
|
---|
487 | return TRUE;
|
---|
488 | }
|
---|
489 | last = info;
|
---|
490 | info = info->next;
|
---|
491 | }
|
---|
492 |
|
---|
493 | info = ldirhead;
|
---|
494 | last = NULL;
|
---|
495 | while (info) {
|
---|
496 | if (!stricmp(info->path, path)) {
|
---|
497 | if (last)
|
---|
498 | last->next = info->next;
|
---|
499 | else
|
---|
500 | ldirhead = info->next;
|
---|
501 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
502 | xfree(info, pszSrcFile, __LINE__);
|
---|
503 | return TRUE;
|
---|
504 | }
|
---|
505 | last = info;
|
---|
506 | info = info->next;
|
---|
507 | }
|
---|
508 | }
|
---|
509 | return FALSE;
|
---|
510 | }
|
---|
511 |
|
---|
512 | BOOL remove_ldir(CHAR * path)
|
---|
513 | {
|
---|
514 | LINKDIRS *info;
|
---|
515 | LINKDIRS *last = NULL;
|
---|
516 |
|
---|
517 | if (path && *path) {
|
---|
518 | info = ldirhead;
|
---|
519 | while (info) {
|
---|
520 | if (!stricmp(info->path, path)) {
|
---|
521 | if (last)
|
---|
522 | last->next = info->next;
|
---|
523 | else
|
---|
524 | ldirhead = info->next;
|
---|
525 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
526 | xfree(info, pszSrcFile, __LINE__);
|
---|
527 | return TRUE;
|
---|
528 | }
|
---|
529 | last = info;
|
---|
530 | info = info->next;
|
---|
531 | }
|
---|
532 | }
|
---|
533 | return FALSE;
|
---|
534 | }
|
---|
535 |
|
---|
536 | VOID FillPathListBox(HWND hwnd, HWND hwnddrive, HWND hwnddir, CHAR * pszPath,
|
---|
537 | BOOL nounwriteable)
|
---|
538 | {
|
---|
539 | /*
|
---|
540 | * this function fills one or two list boxes with drive and directory
|
---|
541 | * information showing all available drives and all directories off of
|
---|
542 | * the directory represented by path. This works independently of the
|
---|
543 | * current directory.
|
---|
544 | */
|
---|
545 |
|
---|
546 | CHAR szDrive[] = " :", szTemp[1032];
|
---|
547 | FILEFINDBUF3 findbuf;
|
---|
548 | HDIR hDir = HDIR_CREATE;
|
---|
549 | SHORT sDrive;
|
---|
550 | ULONG ulDriveNum, ulSearchCount = 1, ulDriveMap;
|
---|
551 |
|
---|
552 | DosError(FERR_DISABLEHARDERR);
|
---|
553 | DosQCurDisk(&ulDriveNum, &ulDriveMap);
|
---|
554 | if (hwnddrive)
|
---|
555 | WinSendMsg(hwnddrive, LM_DELETEALL, MPVOID, MPVOID);
|
---|
556 | if (hwnddrive != hwnddir && hwnddir)
|
---|
557 | WinSendMsg(hwnddir, LM_DELETEALL, MPVOID, MPVOID);
|
---|
558 |
|
---|
559 | if (hwnddrive) {
|
---|
560 | // Fill drive listbox
|
---|
561 | for (sDrive = 0; sDrive < 26; sDrive++) {
|
---|
562 | if (ulDriveMap & (1 << sDrive)) {
|
---|
563 | *szDrive = (CHAR) (sDrive + 'A');
|
---|
564 | if ((!nounwriteable || !(driveflags[sDrive] & DRIVE_NOTWRITEABLE)) &&
|
---|
565 | !(driveflags[sDrive] & (DRIVE_IGNORE | DRIVE_INVALID)))
|
---|
566 | WinSendMsg(hwnddrive, LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
|
---|
567 | MPFROMP(szDrive));
|
---|
568 | }
|
---|
569 | }
|
---|
570 | if (hwnddrive != hwnddir && pszPath && isalpha(*pszPath)
|
---|
571 | && pszPath[1] == ':') {
|
---|
572 | *szDrive = toupper(*pszPath);
|
---|
573 | WinSetWindowText(hwnddrive, szDrive);
|
---|
574 | }
|
---|
575 | }
|
---|
576 |
|
---|
577 | if (hwnddir) {
|
---|
578 | // Fill directory listbox
|
---|
579 | sprintf(szTemp,
|
---|
580 | "%s%s*",
|
---|
581 | pszPath, (pszPath[strlen(pszPath) - 1] == '\\') ? "" : "\\");
|
---|
582 | DosError(FERR_DISABLEHARDERR);
|
---|
583 | if (!DosFindFirst(szTemp,
|
---|
584 | &hDir,
|
---|
585 | FILE_DIRECTORY | MUST_HAVE_DIRECTORY |
|
---|
586 | FILE_READONLY | FILE_ARCHIVED | FILE_SYSTEM |
|
---|
587 | FILE_HIDDEN,
|
---|
588 | &findbuf,
|
---|
589 | sizeof(FILEFINDBUF3), &ulSearchCount, FIL_STANDARD)) {
|
---|
590 | do {
|
---|
591 | if (findbuf.attrFile & FILE_DIRECTORY) {
|
---|
592 | // Skip .. unless full path supplied
|
---|
593 | if (strcmp(findbuf.achName, "..") ||
|
---|
594 | strlen(pszPath) > 3 || pszPath[1] != ':') {
|
---|
595 | // Skip . allow ..
|
---|
596 | if (findbuf.achName[0] != '.' || findbuf.achName[1]) {
|
---|
597 | WinSendMsg(hwnddir,
|
---|
598 | LM_INSERTITEM,
|
---|
599 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
600 | MPFROMP(findbuf.achName));
|
---|
601 | }
|
---|
602 | }
|
---|
603 | }
|
---|
604 | ulSearchCount = 1;
|
---|
605 | } while (!DosFindNext(hDir,
|
---|
606 | &findbuf, sizeof(FILEFINDBUF3), &ulSearchCount));
|
---|
607 | DosFindClose(hDir);
|
---|
608 | }
|
---|
609 | DosError(FERR_DISABLEHARDERR);
|
---|
610 | }
|
---|
611 | }
|
---|
612 |
|
---|
613 | MRESULT EXPENTRY TextSubProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
614 | {
|
---|
615 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
616 |
|
---|
617 | switch (msg) {
|
---|
618 | case WM_CHAR:
|
---|
619 | if (SHORT1FROMMP(mp1) & KC_KEYUP) {
|
---|
620 | if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) &&
|
---|
621 | (SHORT1FROMMP(mp2) & 255) == '\r')
|
---|
622 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND,
|
---|
623 | MPFROM2SHORT(DID_OK, 0), MPVOID);
|
---|
624 | }
|
---|
625 | break;
|
---|
626 | }
|
---|
627 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
628 | }
|
---|
629 |
|
---|
630 | MRESULT EXPENTRY WalkDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
631 | {
|
---|
632 | WALKER *wa;
|
---|
633 | CHAR szBuff[CCHMAXPATH + 1], szBuffer[CCHMAXPATH + 1], *p;
|
---|
634 | SHORT sSelect;
|
---|
635 | static BOOL okay; /* avoid combobox selecting as filled */
|
---|
636 | static CHAR lastdir[CCHMAXPATH + 1];
|
---|
637 |
|
---|
638 | switch (msg) {
|
---|
639 | case UM_SETUP2:
|
---|
640 | case WM_INITDLG:
|
---|
641 | okay = FALSE;
|
---|
642 | *lastdir = 0;
|
---|
643 | if (!mp2) {
|
---|
644 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
645 | WinDismissDlg(hwnd, 0);
|
---|
646 | break;
|
---|
647 | }
|
---|
648 | wa = xmallocz(sizeof(WALKER), pszSrcFile, __LINE__);
|
---|
649 | if (!wa) {
|
---|
650 | WinDismissDlg(hwnd, 0);
|
---|
651 | break;
|
---|
652 | }
|
---|
653 | wa->size = (USHORT) sizeof(WALKER);
|
---|
654 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) wa);
|
---|
655 | wa->szReturnPath = (CHAR *)mp2;
|
---|
656 | {
|
---|
657 | PFNWP oldproc;
|
---|
658 |
|
---|
659 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK_PATH),
|
---|
660 | (PFNWP) TextSubProc);
|
---|
661 | if (oldproc)
|
---|
662 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK_PATH),
|
---|
663 | QWL_USER, (PVOID) oldproc);
|
---|
664 | WinSendDlgItemMsg(WinWindowFromID(hwnd, WALK_RECENT),
|
---|
665 | CBID_EDIT,
|
---|
666 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
667 | WinSendDlgItemMsg(WinWindowFromID(hwnd, WALK_RECENT),
|
---|
668 | CBID_EDIT,
|
---|
669 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
|
---|
670 | }
|
---|
671 | {
|
---|
672 | SWP swp;
|
---|
673 | ULONG size = sizeof(SWP);
|
---|
674 |
|
---|
675 | PrfQueryProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp, &size);
|
---|
676 | WinSetWindowPos(hwnd,
|
---|
677 | HWND_TOP,
|
---|
678 | swp.x,
|
---|
679 | swp.y,
|
---|
680 | swp.cx,
|
---|
681 | swp.cy,
|
---|
682 | swp.fl);
|
---|
683 | }
|
---|
684 | PosOverOkay(hwnd);
|
---|
685 | if (msg == UM_SETUP2)
|
---|
686 | wa->nounwriteable = FALSE;
|
---|
687 | else
|
---|
688 | wa->nounwriteable = TRUE;
|
---|
689 | if (!*wa->szReturnPath)
|
---|
690 | save_dir2(wa->szCurrentPath);
|
---|
691 | else {
|
---|
692 | strcpy(wa->szCurrentPath, wa->szReturnPath);
|
---|
693 | MakeFullName(wa->szCurrentPath);
|
---|
694 | }
|
---|
695 | if (wa->nounwriteable &&
|
---|
696 | (driveflags[toupper(*wa->szCurrentPath) - 'A'] &
|
---|
697 | DRIVE_NOTWRITEABLE)) {
|
---|
698 |
|
---|
699 | ULONG bd;
|
---|
700 |
|
---|
701 | strcpy(wa->szCurrentPath, "C:\\");
|
---|
702 | if (DosQuerySysInfo(QSV_BOOT_DRIVE,
|
---|
703 | QSV_BOOT_DRIVE,
|
---|
704 | (PVOID) & bd, (ULONG) sizeof(ULONG)))
|
---|
705 | bd = 3;
|
---|
706 | *wa->szCurrentPath = (CHAR) bd + '@';
|
---|
707 | }
|
---|
708 | WinSendDlgItemMsg(hwnd,
|
---|
709 | WALK_PATH,
|
---|
710 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
711 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
712 | if (!loadedudirs)
|
---|
713 | load_udirs();
|
---|
714 | { /* fill user list box */
|
---|
715 | ULONG ulDriveNum, ulDriveMap;
|
---|
716 | ULONG ulSearchCount;
|
---|
717 | FILEFINDBUF3 findbuf;
|
---|
718 | HDIR hDir;
|
---|
719 | APIRET rc;
|
---|
720 | LINKDIRS *info, *temp;
|
---|
721 |
|
---|
722 | DosError(FERR_DISABLEHARDERR);
|
---|
723 | DosQCurDisk(&ulDriveNum, &ulDriveMap);
|
---|
724 | info = udirhead;
|
---|
725 | while (info) {
|
---|
726 | if (IsFullName(info->path) &&
|
---|
727 | !(driveflags[toupper(*info->path) - 'A'] &
|
---|
728 | (DRIVE_IGNORE | DRIVE_INVALID))) {
|
---|
729 | DosError(FERR_DISABLEHARDERR);
|
---|
730 | hDir = HDIR_CREATE;
|
---|
731 | ulSearchCount = 1;
|
---|
732 | if (!IsRoot(info->path))
|
---|
733 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
|
---|
734 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
735 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
736 | &findbuf, sizeof(FILEFINDBUF3),
|
---|
737 | &ulSearchCount, FIL_STANDARD);
|
---|
738 | else {
|
---|
739 | rc = 0;
|
---|
740 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
741 | }
|
---|
742 | if (!rc) {
|
---|
743 | if (!IsRoot(info->path))
|
---|
744 | DosFindClose(hDir);
|
---|
745 | if (findbuf.attrFile & FILE_DIRECTORY)
|
---|
746 | WinSendDlgItemMsg(hwnd, WALK_USERLIST, LM_INSERTITEM,
|
---|
747 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
748 | MPFROMP(info->path));
|
---|
749 | else {
|
---|
750 | temp = info->next;
|
---|
751 | remove_udir(info->path);
|
---|
752 | info = temp;
|
---|
753 | continue;
|
---|
754 | }
|
---|
755 | }
|
---|
756 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
|
---|
757 | temp = info->next;
|
---|
758 | remove_udir(info->path);
|
---|
759 | info = temp;
|
---|
760 | continue;
|
---|
761 | }
|
---|
762 | }
|
---|
763 | info = info->next;
|
---|
764 | }
|
---|
765 | info = ldirhead;
|
---|
766 | while (info) {
|
---|
767 | if (IsFullName(info->path) &&
|
---|
768 | !(driveflags[toupper(*info->path) - 'A'] &
|
---|
769 | (DRIVE_IGNORE | DRIVE_INVALID))) {
|
---|
770 | DosError(FERR_DISABLEHARDERR);
|
---|
771 | hDir = HDIR_CREATE;
|
---|
772 | ulSearchCount = 1;
|
---|
773 | if (!IsRoot(info->path))
|
---|
774 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
|
---|
775 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
776 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
777 | &findbuf, sizeof(FILEFINDBUF3),
|
---|
778 | &ulSearchCount, FIL_STANDARD);
|
---|
779 | else {
|
---|
780 | rc = 0;
|
---|
781 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
782 | }
|
---|
783 | if (!rc) {
|
---|
784 | if (!IsRoot(info->path))
|
---|
785 | DosFindClose(hDir);
|
---|
786 | if (findbuf.attrFile & FILE_DIRECTORY)
|
---|
787 | WinSendDlgItemMsg(hwnd, WALK_RECENT, LM_INSERTITEM,
|
---|
788 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
789 | MPFROMP(info->path));
|
---|
790 | else {
|
---|
791 | temp = info->next;
|
---|
792 | remove_ldir(info->path);
|
---|
793 | info = temp;
|
---|
794 | continue;
|
---|
795 | }
|
---|
796 | WinSetDlgItemText(hwnd, WALK_RECENT,
|
---|
797 | GetPString(IDS_WALKRECENTDIRSTEXT));
|
---|
798 | }
|
---|
799 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
|
---|
800 | temp = info->next;
|
---|
801 | remove_ldir(info->path);
|
---|
802 | info = temp;
|
---|
803 | continue;
|
---|
804 | }
|
---|
805 | }
|
---|
806 | info = info->next;
|
---|
807 | }
|
---|
808 | }
|
---|
809 | FillPathListBox(hwnd,
|
---|
810 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
811 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
812 | wa->szCurrentPath, wa->nounwriteable);
|
---|
813 | if (!PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID))
|
---|
814 | okay = TRUE;
|
---|
815 | {
|
---|
816 | MRESULT ret;
|
---|
817 |
|
---|
818 | ret = WinDefDlgProc(hwnd, WM_INITDLG, mp1, mp2);
|
---|
819 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
820 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
---|
821 | return ret;
|
---|
822 | }
|
---|
823 |
|
---|
824 | case UM_SETUP4:
|
---|
825 | okay = TRUE;
|
---|
826 | return 0;
|
---|
827 |
|
---|
828 | case WM_ADJUSTWINDOWPOS:
|
---|
829 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
830 | break;
|
---|
831 |
|
---|
832 | case UM_SETDIR:
|
---|
833 | PaintRecessedWindow(WinWindowFromID(hwnd, WALK_HELP), (HPS) 0, FALSE,
|
---|
834 | TRUE);
|
---|
835 | return 0;
|
---|
836 |
|
---|
837 | case WM_PRESPARAMCHANGED:
|
---|
838 | {
|
---|
839 | ULONG AttrFound, AttrValue[64], cbRetLen;
|
---|
840 |
|
---|
841 | cbRetLen = WinQueryPresParam(hwnd, (ULONG) mp1, 0, &AttrFound,
|
---|
842 | (ULONG) sizeof(AttrValue), &AttrValue, 0);
|
---|
843 | if (cbRetLen) {
|
---|
844 | switch (AttrFound) {
|
---|
845 | case PP_FONTNAMESIZE:
|
---|
846 | PrfWriteProfileData(fmprof,
|
---|
847 | appname,
|
---|
848 | "WalkFont", (PVOID) AttrValue, cbRetLen);
|
---|
849 | *WalkFont = 0;
|
---|
850 | WalkFontSize = sizeof(WalkFont);
|
---|
851 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
---|
852 | break;
|
---|
853 | }
|
---|
854 | }
|
---|
855 | }
|
---|
856 | break;
|
---|
857 |
|
---|
858 | case UM_SETUP3:
|
---|
859 | save_udirs();
|
---|
860 | if (hwndMain)
|
---|
861 | PostMsg(hwndMain, UM_FILLUSERLIST, MPVOID, MPVOID);
|
---|
862 | return 0;
|
---|
863 |
|
---|
864 | case UM_SETUP:
|
---|
865 | {
|
---|
866 | INT x;
|
---|
867 | USHORT id[] = { WALK_PATH, WALK_DIRLIST, WALK_USERLIST,
|
---|
868 | WALK_RECENT, 0
|
---|
869 | };
|
---|
870 |
|
---|
871 | if (*WalkFont ||
|
---|
872 | (PrfQueryProfileData(fmprof,
|
---|
873 | appname,
|
---|
874 | "WalkFont",
|
---|
875 | (PVOID) WalkFont,
|
---|
876 | &WalkFontSize) && WalkFontSize)) {
|
---|
877 | for (x = 0; id[x]; x++)
|
---|
878 | WinSetPresParam(WinWindowFromID(hwnd, id[x]),
|
---|
879 | PP_FONTNAMESIZE, WalkFontSize, (PVOID) WalkFont);
|
---|
880 | }
|
---|
881 | }
|
---|
882 | return 0;
|
---|
883 |
|
---|
884 | case UM_CONTROL:
|
---|
885 | case WM_CONTROL:
|
---|
886 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
887 | if (SHORT1FROMMP(mp1) == WALK_DRIVELIST ||
|
---|
888 | SHORT1FROMMP(mp1) == WALK_DIRLIST ||
|
---|
889 | SHORT1FROMMP(mp1) == WALK_USERLIST ||
|
---|
890 | SHORT1FROMMP(mp1) == WALK_RECENT) {
|
---|
891 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
|
---|
892 | SHORT1FROMMP(mp1),
|
---|
893 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
---|
894 | *szBuffer = 0;
|
---|
895 | if (sSelect >= 0)
|
---|
896 | WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
|
---|
897 | MPFROM2SHORT(sSelect, CCHMAXPATH),
|
---|
898 | MPFROMP(szBuffer));
|
---|
899 | }
|
---|
900 | switch (SHORT1FROMMP(mp1)) {
|
---|
901 | case WALK_PATH:
|
---|
902 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
903 | WinSetDlgItemText(hwnd, WALK_HELP, GetPString(IDS_WALKCURRDIRTEXT));
|
---|
904 | else if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
905 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
906 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
907 | break;
|
---|
908 |
|
---|
909 | case WALK_RECENT:
|
---|
910 | if (okay && SHORT2FROMMP(mp1) == CBN_LBSELECT) {
|
---|
911 |
|
---|
912 | ULONG ulSearchCount;
|
---|
913 | FILEFINDBUF3 findbuf;
|
---|
914 | HDIR hDir;
|
---|
915 | APIRET rc;
|
---|
916 |
|
---|
917 | // *szBuffer = 0;
|
---|
918 | // WinQueryDlgItemText(hwnd,WALK_RECENT,CCHMAXPATH,szBuffer);
|
---|
919 | if (!*szBuffer)
|
---|
920 | break;
|
---|
921 | DosError(FERR_DISABLEHARDERR);
|
---|
922 | hDir = HDIR_CREATE;
|
---|
923 | ulSearchCount = 1;
|
---|
924 | if (!IsRoot(szBuffer)) {
|
---|
925 | rc = DosFindFirst(szBuffer, &hDir, FILE_DIRECTORY |
|
---|
926 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
927 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
928 | &findbuf, sizeof(FILEFINDBUF3),
|
---|
929 | &ulSearchCount, FIL_STANDARD);
|
---|
930 | if (!rc)
|
---|
931 | DosFindClose(hDir);
|
---|
932 | }
|
---|
933 | else {
|
---|
934 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
935 | rc = 0;
|
---|
936 | }
|
---|
937 | if (rc)
|
---|
938 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
---|
939 | "xDosFindFirst");
|
---|
940 | else if (~findbuf.attrFile & FILE_DIRECTORY)
|
---|
941 | Runtime_Error(pszSrcFile, __LINE__, "not a directory");
|
---|
942 | else {
|
---|
943 | strcpy(wa->szCurrentPath, szBuffer);
|
---|
944 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
945 | WinSetDlgItemText(hwnd, WALK_RECENT, wa->szCurrentPath);
|
---|
946 | FillPathListBox(hwnd,
|
---|
947 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
948 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
949 | wa->szCurrentPath, FALSE);
|
---|
950 | }
|
---|
951 | }
|
---|
952 | else if (SHORT2FROMMP(mp1) == CBN_ENTER)
|
---|
953 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
---|
954 | else if (SHORT2FROMMP(mp1) == CBN_SHOWLIST)
|
---|
955 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
956 | GetPString(IDS_WALKRECENTDIRSHELPTEXT));
|
---|
957 | break;
|
---|
958 |
|
---|
959 | case WALK_USERLIST:
|
---|
960 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_SELECT) {
|
---|
961 |
|
---|
962 | ULONG ulSearchCount;
|
---|
963 | FILEFINDBUF3 findbuf;
|
---|
964 | HDIR hDir;
|
---|
965 | APIRET rc;
|
---|
966 |
|
---|
967 | DosError(FERR_DISABLEHARDERR);
|
---|
968 | hDir = HDIR_CREATE;
|
---|
969 | ulSearchCount = 1;
|
---|
970 | if (!IsRoot(szBuffer)) {
|
---|
971 | rc = DosFindFirst(szBuffer,
|
---|
972 | &hDir,
|
---|
973 | FILE_DIRECTORY |
|
---|
974 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
975 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
976 | &findbuf,
|
---|
977 | sizeof(FILEFINDBUF3),
|
---|
978 | &ulSearchCount, FIL_STANDARD);
|
---|
979 | if (!rc)
|
---|
980 | DosFindClose(hDir);
|
---|
981 | }
|
---|
982 | else {
|
---|
983 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
984 | rc = 0;
|
---|
985 | }
|
---|
986 | if (rc)
|
---|
987 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
---|
988 | "xDosFindFirst");
|
---|
989 | else if (~findbuf.attrFile & FILE_DIRECTORY)
|
---|
990 | Runtime_Error(pszSrcFile, __LINE__, "not a directory");
|
---|
991 | else {
|
---|
992 | strcpy(wa->szCurrentPath, szBuffer);
|
---|
993 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
994 | FillPathListBox(hwnd,
|
---|
995 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
996 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
997 | wa->szCurrentPath, FALSE);
|
---|
998 | }
|
---|
999 | }
|
---|
1000 | else if (SHORT2FROMMP(mp1) == LN_ENTER)
|
---|
1001 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
---|
1002 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
---|
1003 | WinSetDlgItemText(hwnd,
|
---|
1004 | WALK_HELP, GetPString(IDS_WALKUSERDIRSHELPTEXT));
|
---|
1005 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
---|
1006 | WinSetDlgItemText(hwnd,
|
---|
1007 | WALK_HELP, GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
1008 | break;
|
---|
1009 |
|
---|
1010 | case WALK_DRIVELIST:
|
---|
1011 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
1012 |
|
---|
1013 | ULONG ulDirLen = CCHMAXPATH;
|
---|
1014 | APIRET rc;
|
---|
1015 |
|
---|
1016 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
---|
1017 | if (!rc) {
|
---|
1018 | strcpy(wa->szCurrentPath, "C:\\");
|
---|
1019 | *wa->szCurrentPath = toupper(*szBuffer);
|
---|
1020 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
1021 | FillPathListBox(hwnd,
|
---|
1022 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
1023 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
1024 | wa->szCurrentPath, FALSE);
|
---|
1025 | }
|
---|
1026 | }
|
---|
1027 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
---|
1028 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
1029 | GetPString(IDS_WALKDRIVELISTHELPTEXT));
|
---|
1030 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
---|
1031 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
1032 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
1033 | break;
|
---|
1034 |
|
---|
1035 | case WALK_DIRLIST:
|
---|
1036 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
1037 |
|
---|
1038 | ULONG ulSearchCount;
|
---|
1039 | FILEFINDBUF3 findbuf;
|
---|
1040 | HDIR hDir;
|
---|
1041 | APIRET rc;
|
---|
1042 |
|
---|
1043 | bstrip(szBuffer);
|
---|
1044 | if (*szBuffer) {
|
---|
1045 | strcpy(szBuff, wa->szCurrentPath);
|
---|
1046 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
---|
1047 | strcat(szBuff, "\\");
|
---|
1048 | strcat(szBuff, szBuffer);
|
---|
1049 | MakeFullName(szBuff);
|
---|
1050 | DosError(FERR_DISABLEHARDERR);
|
---|
1051 | hDir = HDIR_CREATE;
|
---|
1052 | ulSearchCount = 1;
|
---|
1053 | if (!IsRoot(szBuff)) {
|
---|
1054 | rc = DosFindFirst(szBuff,
|
---|
1055 | &hDir,
|
---|
1056 | FILE_DIRECTORY |
|
---|
1057 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
1058 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
1059 | &findbuf,
|
---|
1060 | sizeof(FILEFINDBUF3),
|
---|
1061 | &ulSearchCount, FIL_STANDARD);
|
---|
1062 | if (!rc)
|
---|
1063 | DosFindClose(hDir);
|
---|
1064 | }
|
---|
1065 | else {
|
---|
1066 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
1067 | rc = 0;
|
---|
1068 | }
|
---|
1069 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
---|
1070 | strcpy(wa->szCurrentPath, szBuff);
|
---|
1071 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
1072 | FillPathListBox(hwnd,
|
---|
1073 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
1074 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
1075 | wa->szCurrentPath, FALSE);
|
---|
1076 | }
|
---|
1077 | }
|
---|
1078 | }
|
---|
1079 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
---|
1080 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
1081 | GetPString(IDS_WALKDIRLISTHELPTEXT));
|
---|
1082 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
---|
1083 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
1084 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
1085 | break;
|
---|
1086 | }
|
---|
1087 | return 0;
|
---|
1088 |
|
---|
1089 | case WM_COMMAND:
|
---|
1090 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
1091 | if (!wa)
|
---|
1092 | WinDismissDlg(hwnd, 0);
|
---|
1093 | *szBuff = 0;
|
---|
1094 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
---|
1095 | bstrip(szBuff);
|
---|
1096 | while ((p = strchr(szBuff, '/')) != NULL)
|
---|
1097 | *p = '\\';
|
---|
1098 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
---|
1099 | szBuff[strlen(szBuff) - 1] = 0;
|
---|
1100 | MakeFullName(szBuff);
|
---|
1101 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
---|
1102 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
1103 | QW_OWNER), hwnd, szBuff, 0))
|
---|
1104 | strcpy(wa->szCurrentPath, szBuff);
|
---|
1105 | else
|
---|
1106 | return 0;
|
---|
1107 | }
|
---|
1108 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
1109 | switch (SHORT1FROMMP(mp1)) {
|
---|
1110 | case WALK_ADD:
|
---|
1111 | *szBuff = 0;
|
---|
1112 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
---|
1113 | bstrip(szBuff);
|
---|
1114 | while ((p = strchr(szBuff, '/')) != NULL)
|
---|
1115 | *p = '\\';
|
---|
1116 | if (*szBuff && !IsFile(szBuff)) {
|
---|
1117 | MakeFullName(szBuff);
|
---|
1118 | add_udir(TRUE, szBuff);
|
---|
1119 | if (fUdirsChanged) {
|
---|
1120 | WinSendDlgItemMsg(hwnd,
|
---|
1121 | WALK_USERLIST,
|
---|
1122 | LM_INSERTITEM,
|
---|
1123 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
1124 | MPFROMP(szBuff));
|
---|
1125 | wa->changed = 1;
|
---|
1126 | }
|
---|
1127 | }
|
---|
1128 | break;
|
---|
1129 |
|
---|
1130 | case WALK_DELETE:
|
---|
1131 | *szBuff = 0;
|
---|
1132 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
---|
1133 | bstrip(szBuff);
|
---|
1134 | while ((p = strchr(szBuff, '/')) != NULL)
|
---|
1135 | *p = '\\';
|
---|
1136 | if (*szBuff && !IsFile(szBuff)) {
|
---|
1137 | MakeFullName(szBuff);
|
---|
1138 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
1139 | WALK_USERLIST,
|
---|
1140 | LM_SEARCHSTRING,
|
---|
1141 | MPFROM2SHORT(0, LIT_FIRST),
|
---|
1142 | MPFROMP(szBuff));
|
---|
1143 | if (sSelect >= 0) {
|
---|
1144 | WinSendDlgItemMsg(hwnd,
|
---|
1145 | WALK_USERLIST,
|
---|
1146 | LM_DELETEITEM, MPFROM2SHORT(sSelect, 0), MPVOID);
|
---|
1147 | remove_udir(szBuff);
|
---|
1148 | wa->changed = 1;
|
---|
1149 | }
|
---|
1150 | }
|
---|
1151 | break;
|
---|
1152 |
|
---|
1153 | case DID_OK:
|
---|
1154 | if (*wa->szCurrentPath) {
|
---|
1155 | strcpy(wa->szReturnPath, wa->szCurrentPath);
|
---|
1156 | MakeValidDir(wa->szReturnPath);
|
---|
1157 | if (fAutoAddAllDirs)
|
---|
1158 | add_udir(FALSE, wa->szReturnPath);
|
---|
1159 | if (fChangeTarget) {
|
---|
1160 | strcpy(targetdir, wa->szReturnPath);
|
---|
1161 | PrfWriteProfileString(fmprof, appname, "Targetdir", targetdir);
|
---|
1162 | }
|
---|
1163 | }
|
---|
1164 | {
|
---|
1165 | SWP swp;
|
---|
1166 | ULONG size = sizeof(SWP);
|
---|
1167 |
|
---|
1168 | WinQueryWindowPos(hwnd, &swp);
|
---|
1169 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
|
---|
1170 | size);
|
---|
1171 | }
|
---|
1172 | if (wa->changed)
|
---|
1173 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
1174 | WinDismissDlg(hwnd, 1);
|
---|
1175 | break;
|
---|
1176 |
|
---|
1177 | case IDM_HELP:
|
---|
1178 | if (hwndHelp)
|
---|
1179 | WinSendMsg(hwndHelp,
|
---|
1180 | HM_DISPLAY_HELP,
|
---|
1181 | MPFROM2SHORT(HELP_WALKEM, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
1182 | break;
|
---|
1183 |
|
---|
1184 | case DID_CANCEL:
|
---|
1185 | {
|
---|
1186 | SWP swp;
|
---|
1187 | ULONG size = sizeof(SWP);
|
---|
1188 |
|
---|
1189 | WinQueryWindowPos(hwnd, &swp);
|
---|
1190 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
|
---|
1191 | size);
|
---|
1192 | }
|
---|
1193 | if (wa->changed)
|
---|
1194 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
1195 | xfree(wa, pszSrcFile, __LINE__);
|
---|
1196 | WinDismissDlg(hwnd, 0);
|
---|
1197 | break;
|
---|
1198 | }
|
---|
1199 | return 0;
|
---|
1200 |
|
---|
1201 | case WM_CLOSE:
|
---|
1202 | break;
|
---|
1203 | }
|
---|
1204 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
1205 | }
|
---|
1206 |
|
---|
1207 | MRESULT EXPENTRY WalkAllDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1208 | {
|
---|
1209 | switch (msg) {
|
---|
1210 | case WM_INITDLG:
|
---|
1211 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
1212 | }
|
---|
1213 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
1214 | }
|
---|
1215 |
|
---|
1216 | MRESULT EXPENTRY WalkCopyDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1217 | {
|
---|
1218 | switch (msg) {
|
---|
1219 | case WM_INITDLG:
|
---|
1220 | WinSetWindowText(hwnd, GetPString(IDS_WALKCOPYDLGTEXT));
|
---|
1221 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
1222 | }
|
---|
1223 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
1224 | }
|
---|
1225 |
|
---|
1226 | MRESULT EXPENTRY WalkMoveDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1227 | {
|
---|
1228 | switch (msg) {
|
---|
1229 | case WM_INITDLG:
|
---|
1230 | WinSetWindowText(hwnd, GetPString(IDS_WALKMOVEDLGTEXT));
|
---|
1231 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
1232 | }
|
---|
1233 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
1234 | }
|
---|
1235 |
|
---|
1236 | MRESULT EXPENTRY WalkExtractDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
1237 | MPARAM mp2)
|
---|
1238 | {
|
---|
1239 | switch (msg) {
|
---|
1240 | case WM_INITDLG:
|
---|
1241 | WinSetWindowText(hwnd, GetPString(IDS_WALKEXTRACTDLGTEXT));
|
---|
1242 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
1243 | }
|
---|
1244 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 | MRESULT EXPENTRY WalkTargetDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
1248 | MPARAM mp2)
|
---|
1249 | {
|
---|
1250 | switch (msg) {
|
---|
1251 | case WM_INITDLG:
|
---|
1252 | {
|
---|
1253 | char s[CCHMAXPATH + 32];
|
---|
1254 |
|
---|
1255 | sprintf(s,
|
---|
1256 | GetPString(IDS_WALKTARGETDLGTEXT),
|
---|
1257 | (*targetdir) ?
|
---|
1258 | NullStr :
|
---|
1259 | " (",
|
---|
1260 | (*targetdir) ?
|
---|
1261 | NullStr : GetPString(IDS_NONE), (*targetdir) ? NullStr : ")");
|
---|
1262 | WinSetWindowText(hwnd, s);
|
---|
1263 | }
|
---|
1264 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
1265 | }
|
---|
1266 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
1267 | }
|
---|
1268 |
|
---|
1269 | MRESULT EXPENTRY WalkTwoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1270 | {
|
---|
1271 | WALK2 *wa;
|
---|
1272 | CHAR szBuff[CCHMAXPATH + 1], szBuffer[CCHMAXPATH + 1], *p;
|
---|
1273 | SHORT sSelect;
|
---|
1274 | static BOOL okay; /* avoid combobox selecting as filled */
|
---|
1275 |
|
---|
1276 | switch (msg) {
|
---|
1277 | case UM_SETUP2:
|
---|
1278 | case WM_INITDLG:
|
---|
1279 | okay = FALSE;
|
---|
1280 | if (!mp2) {
|
---|
1281 | WinDismissDlg(hwnd, 0);
|
---|
1282 | break;
|
---|
1283 | }
|
---|
1284 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
1285 | wa = mp2;
|
---|
1286 | {
|
---|
1287 | PFNWP oldproc;
|
---|
1288 |
|
---|
1289 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK_PATH),
|
---|
1290 | (PFNWP) TextSubProc);
|
---|
1291 | if (oldproc)
|
---|
1292 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK_PATH),
|
---|
1293 | QWL_USER, (PVOID) oldproc);
|
---|
1294 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK2_PATH),
|
---|
1295 | (PFNWP) TextSubProc);
|
---|
1296 | if (oldproc)
|
---|
1297 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK2_PATH),
|
---|
1298 | QWL_USER, (PVOID) oldproc);
|
---|
1299 | }
|
---|
1300 | {
|
---|
1301 | SWP swp;
|
---|
1302 | ULONG size = sizeof(SWP);
|
---|
1303 |
|
---|
1304 | PrfQueryProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp, &size);
|
---|
1305 | WinSetWindowPos(hwnd,
|
---|
1306 | HWND_TOP,
|
---|
1307 | swp.x,
|
---|
1308 | swp.y,
|
---|
1309 | swp.cx,
|
---|
1310 | swp.cy,
|
---|
1311 | swp.fl);
|
---|
1312 | }
|
---|
1313 | if (!*wa->szCurrentPath1)
|
---|
1314 | save_dir2(wa->szCurrentPath1);
|
---|
1315 | MakeFullName(wa->szCurrentPath1);
|
---|
1316 | if (!*wa->szCurrentPath2)
|
---|
1317 | save_dir2(wa->szCurrentPath2);
|
---|
1318 | MakeFullName(wa->szCurrentPath2);
|
---|
1319 | WinSendDlgItemMsg(hwnd,
|
---|
1320 | WALK_PATH,
|
---|
1321 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
1322 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
---|
1323 | WinSendDlgItemMsg(hwnd, WALK2_PATH, EM_SETTEXTLIMIT,
|
---|
1324 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
1325 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
---|
1326 | FillPathListBox(hwnd,
|
---|
1327 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
1328 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
1329 | wa->szCurrentPath1, FALSE);
|
---|
1330 | FillPathListBox(hwnd,
|
---|
1331 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
---|
1332 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
---|
1333 | wa->szCurrentPath2, FALSE);
|
---|
1334 | if (!PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID))
|
---|
1335 | okay = TRUE;
|
---|
1336 | {
|
---|
1337 | MRESULT ret;
|
---|
1338 |
|
---|
1339 | ret = WinDefDlgProc(hwnd, WM_INITDLG, mp1, mp2);
|
---|
1340 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
1341 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
---|
1342 | WinInvalidateRect(WinWindowFromID(hwnd, WALK2_PATH), NULL, TRUE);
|
---|
1343 | return ret;
|
---|
1344 | }
|
---|
1345 |
|
---|
1346 | case UM_SETUP4:
|
---|
1347 | okay = TRUE;
|
---|
1348 | return 0;
|
---|
1349 |
|
---|
1350 | case WM_PRESPARAMCHANGED:
|
---|
1351 | {
|
---|
1352 | ULONG AttrFound, AttrValue[64], cbRetLen;
|
---|
1353 |
|
---|
1354 | cbRetLen = WinQueryPresParam(hwnd, (ULONG) mp1, 0, &AttrFound,
|
---|
1355 | (ULONG) sizeof(AttrValue), &AttrValue, 0);
|
---|
1356 | if (cbRetLen) {
|
---|
1357 | switch (AttrFound) {
|
---|
1358 | case PP_FONTNAMESIZE:
|
---|
1359 | PrfWriteProfileData(fmprof,
|
---|
1360 | appname,
|
---|
1361 | "WalkFont", (PVOID) AttrValue, cbRetLen);
|
---|
1362 | *WalkFont = 0;
|
---|
1363 | WalkFontSize = sizeof(WalkFont);
|
---|
1364 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
---|
1365 | break;
|
---|
1366 | }
|
---|
1367 | }
|
---|
1368 | }
|
---|
1369 | break;
|
---|
1370 |
|
---|
1371 | case UM_SETUP:
|
---|
1372 | {
|
---|
1373 | INT x;
|
---|
1374 | USHORT id[] = { WALK_PATH, WALK_DIRLIST,
|
---|
1375 | WALK2_PATH, WALK2_DIRLIST, 0
|
---|
1376 | };
|
---|
1377 |
|
---|
1378 | if (*WalkFont ||
|
---|
1379 | (PrfQueryProfileData(fmprof,
|
---|
1380 | appname,
|
---|
1381 | "WalkFont",
|
---|
1382 | (PVOID) WalkFont,
|
---|
1383 | &WalkFontSize) && WalkFontSize)) {
|
---|
1384 | for (x = 0; id[x]; x++)
|
---|
1385 | WinSetPresParam(WinWindowFromID(hwnd, id[x]),
|
---|
1386 | PP_FONTNAMESIZE, WalkFontSize, (PVOID) WalkFont);
|
---|
1387 | }
|
---|
1388 | }
|
---|
1389 | return 0;
|
---|
1390 |
|
---|
1391 | case UM_CONTROL:
|
---|
1392 | case WM_CONTROL:
|
---|
1393 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
1394 | if (SHORT1FROMMP(mp1) == WALK_DRIVELIST ||
|
---|
1395 | SHORT1FROMMP(mp1) == WALK_DIRLIST ||
|
---|
1396 | SHORT1FROMMP(mp1) == WALK2_DRIVELIST ||
|
---|
1397 | SHORT1FROMMP(mp1) == WALK2_DIRLIST) {
|
---|
1398 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
|
---|
1399 | SHORT1FROMMP(mp1),
|
---|
1400 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
---|
1401 | *szBuffer = 0;
|
---|
1402 | if (sSelect >= 0)
|
---|
1403 | WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
|
---|
1404 | MPFROM2SHORT(sSelect, CCHMAXPATH),
|
---|
1405 | MPFROMP(szBuffer));
|
---|
1406 | }
|
---|
1407 | switch (SHORT1FROMMP(mp1)) {
|
---|
1408 | case WALK_DRIVELIST:
|
---|
1409 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
1410 |
|
---|
1411 | ULONG ulDirLen = CCHMAXPATH;
|
---|
1412 | APIRET rc;
|
---|
1413 |
|
---|
1414 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
---|
1415 | if (!rc) {
|
---|
1416 | strcpy(wa->szCurrentPath1, "C:\\");
|
---|
1417 | *wa->szCurrentPath1 = toupper(*szBuffer);
|
---|
1418 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
---|
1419 | FillPathListBox(hwnd,
|
---|
1420 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
1421 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
1422 | wa->szCurrentPath1, FALSE);
|
---|
1423 | }
|
---|
1424 | }
|
---|
1425 | break;
|
---|
1426 |
|
---|
1427 | case WALK_DIRLIST:
|
---|
1428 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
1429 |
|
---|
1430 | ULONG ulSearchCount;
|
---|
1431 | FILEFINDBUF3 findbuf;
|
---|
1432 | HDIR hDir;
|
---|
1433 | APIRET rc;
|
---|
1434 |
|
---|
1435 | bstrip(szBuffer);
|
---|
1436 | if (*szBuffer) {
|
---|
1437 | strcpy(szBuff, wa->szCurrentPath1);
|
---|
1438 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
---|
1439 | strcat(szBuff, "\\");
|
---|
1440 | strcat(szBuff, szBuffer);
|
---|
1441 | MakeFullName(szBuff);
|
---|
1442 | DosError(FERR_DISABLEHARDERR);
|
---|
1443 | hDir = HDIR_CREATE;
|
---|
1444 | ulSearchCount = 1;
|
---|
1445 | if (!IsRoot(szBuff)) {
|
---|
1446 | rc = DosFindFirst(szBuff,
|
---|
1447 | &hDir,
|
---|
1448 | FILE_DIRECTORY |
|
---|
1449 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
1450 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
1451 | &findbuf,
|
---|
1452 | sizeof(FILEFINDBUF3),
|
---|
1453 | &ulSearchCount, FIL_STANDARD);
|
---|
1454 | if (!rc)
|
---|
1455 | DosFindClose(hDir);
|
---|
1456 | }
|
---|
1457 | else {
|
---|
1458 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
1459 | rc = 0;
|
---|
1460 | }
|
---|
1461 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
---|
1462 | strcpy(wa->szCurrentPath1, szBuff);
|
---|
1463 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
---|
1464 | FillPathListBox(hwnd,
|
---|
1465 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
1466 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
1467 | wa->szCurrentPath1, FALSE);
|
---|
1468 | }
|
---|
1469 | }
|
---|
1470 | }
|
---|
1471 | break;
|
---|
1472 |
|
---|
1473 | case WALK2_DRIVELIST:
|
---|
1474 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
1475 |
|
---|
1476 | ULONG ulDirLen = CCHMAXPATH;
|
---|
1477 | APIRET rc;
|
---|
1478 |
|
---|
1479 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
---|
1480 | if (!rc) {
|
---|
1481 | strcpy(wa->szCurrentPath2, "C:\\");
|
---|
1482 | *wa->szCurrentPath2 = toupper(*szBuffer);
|
---|
1483 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
---|
1484 | FillPathListBox(hwnd,
|
---|
1485 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
---|
1486 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
---|
1487 | wa->szCurrentPath2, FALSE);
|
---|
1488 | }
|
---|
1489 | }
|
---|
1490 | break;
|
---|
1491 |
|
---|
1492 | case WALK2_DIRLIST:
|
---|
1493 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
1494 |
|
---|
1495 | ULONG ulSearchCount;
|
---|
1496 | FILEFINDBUF3 findbuf;
|
---|
1497 | HDIR hDir;
|
---|
1498 | APIRET rc;
|
---|
1499 |
|
---|
1500 | bstrip(szBuffer);
|
---|
1501 | if (*szBuffer) {
|
---|
1502 | strcpy(szBuff, wa->szCurrentPath2);
|
---|
1503 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
---|
1504 | strcat(szBuff, "\\");
|
---|
1505 | strcat(szBuff, szBuffer);
|
---|
1506 | MakeFullName(szBuff);
|
---|
1507 | DosError(FERR_DISABLEHARDERR);
|
---|
1508 | hDir = HDIR_CREATE;
|
---|
1509 | ulSearchCount = 1;
|
---|
1510 | if (!IsRoot(szBuff)) {
|
---|
1511 | rc = DosFindFirst(szBuff,
|
---|
1512 | &hDir,
|
---|
1513 | FILE_DIRECTORY |
|
---|
1514 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
1515 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
1516 | &findbuf,
|
---|
1517 | sizeof(FILEFINDBUF3),
|
---|
1518 | &ulSearchCount, FIL_STANDARD);
|
---|
1519 | if (!rc)
|
---|
1520 | DosFindClose(hDir);
|
---|
1521 | }
|
---|
1522 | else {
|
---|
1523 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
1524 | rc = 0;
|
---|
1525 | }
|
---|
1526 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
---|
1527 | strcpy(wa->szCurrentPath2, szBuff);
|
---|
1528 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
---|
1529 | FillPathListBox(hwnd,
|
---|
1530 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
---|
1531 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
---|
1532 | wa->szCurrentPath2, FALSE);
|
---|
1533 | }
|
---|
1534 | }
|
---|
1535 | }
|
---|
1536 | break;
|
---|
1537 | }
|
---|
1538 | return 0;
|
---|
1539 |
|
---|
1540 | case WM_COMMAND:
|
---|
1541 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
1542 | if (!wa)
|
---|
1543 | WinDismissDlg(hwnd, 0);
|
---|
1544 | *szBuff = 0;
|
---|
1545 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
---|
1546 | bstrip(szBuff);
|
---|
1547 | while ((p = strchr(szBuff, '/')) != NULL)
|
---|
1548 | *p = '\\';
|
---|
1549 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
---|
1550 | szBuff[strlen(szBuff) - 1] = 0;
|
---|
1551 | MakeFullName(szBuff);
|
---|
1552 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath1) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
---|
1553 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
1554 | QW_OWNER), hwnd, szBuff, 0))
|
---|
1555 | strcpy(wa->szCurrentPath1, szBuff);
|
---|
1556 | else
|
---|
1557 | return 0;
|
---|
1558 | }
|
---|
1559 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
---|
1560 | *szBuff = 0;
|
---|
1561 | WinQueryDlgItemText(hwnd, WALK2_PATH, CCHMAXPATH, szBuff);
|
---|
1562 | bstrip(szBuff);
|
---|
1563 | while ((p = strchr(szBuff, '/')) != NULL)
|
---|
1564 | *p = '\\';
|
---|
1565 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
---|
1566 | szBuff[strlen(szBuff) - 1] = 0;
|
---|
1567 | MakeFullName(szBuff);
|
---|
1568 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath2) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
---|
1569 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
1570 | QW_OWNER), hwnd, szBuff, 0))
|
---|
1571 | strcpy(wa->szCurrentPath2, szBuff);
|
---|
1572 | else
|
---|
1573 | return 0;
|
---|
1574 | }
|
---|
1575 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
---|
1576 | switch (SHORT1FROMMP(mp1)) {
|
---|
1577 | case DID_OK:
|
---|
1578 | {
|
---|
1579 | SWP swp;
|
---|
1580 | ULONG size = sizeof(SWP);
|
---|
1581 |
|
---|
1582 | WinQueryWindowPos(hwnd, &swp);
|
---|
1583 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp,
|
---|
1584 | size);
|
---|
1585 | }
|
---|
1586 | WinDismissDlg(hwnd, 1);
|
---|
1587 | break;
|
---|
1588 |
|
---|
1589 | case IDM_HELP:
|
---|
1590 | if (hwndHelp)
|
---|
1591 | WinSendMsg(hwndHelp,
|
---|
1592 | HM_DISPLAY_HELP,
|
---|
1593 | MPFROM2SHORT(HELP_WALKEM2, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
1594 | break;
|
---|
1595 |
|
---|
1596 | case DID_CANCEL:
|
---|
1597 | {
|
---|
1598 | SWP swp;
|
---|
1599 | ULONG size = sizeof(SWP);
|
---|
1600 |
|
---|
1601 | WinQueryWindowPos(hwnd, &swp);
|
---|
1602 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp,
|
---|
1603 | size);
|
---|
1604 | }
|
---|
1605 | WinDismissDlg(hwnd, 0);
|
---|
1606 | break;
|
---|
1607 | }
|
---|
1608 | return 0;
|
---|
1609 |
|
---|
1610 | case WM_CLOSE:
|
---|
1611 | break;
|
---|
1612 | }
|
---|
1613 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
1614 | }
|
---|
1615 |
|
---|
1616 | MRESULT EXPENTRY WalkTwoCmpDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
1617 | MPARAM mp2)
|
---|
1618 | {
|
---|
1619 | switch (msg) {
|
---|
1620 | case WM_INITDLG:
|
---|
1621 | WinSetWindowText(hwnd, GetPString(IDS_WALKCOMPAREDLGTEXT));
|
---|
1622 | return WalkTwoDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
1623 | }
|
---|
1624 | return WalkTwoDlgProc(hwnd, msg, mp1, mp2);
|
---|
1625 | }
|
---|
1626 |
|
---|
1627 | MRESULT EXPENTRY WalkTwoSetDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
1628 | MPARAM mp2)
|
---|
1629 | {
|
---|
1630 | switch (msg) {
|
---|
1631 | case WM_INITDLG:
|
---|
1632 | WinSetWindowText(hwnd, GetPString(IDS_WALKSETDIRSDLGTEXT));
|
---|
1633 | return WalkTwoDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
1634 | }
|
---|
1635 | return WalkTwoDlgProc(hwnd, msg, mp1, mp2);
|
---|
1636 | }
|
---|
1637 |
|
---|
1638 | #pragma alloc_text(WALKER,FillPathListBox,WalkDlgProc,TextSubProc)
|
---|
1639 | #pragma alloc_text(WALKER,WalkAllDlgProc,WalkCopyDlgProc)
|
---|
1640 | #pragma alloc_text(WALKER,WalkMoveDlgProc,WalkExtractDlgProc,WalkTargetDlgProc)
|
---|
1641 | #pragma alloc_text(WALK2,WalkTwoDlgProc,WalkTwoCmpDlgProc,WalkTwoSetDlgProc)
|
---|
1642 | #pragma alloc_text(UDIRS,add_udir,remove_udir,remove_ldir,load_udirs)
|
---|
1643 | #pragma alloc_text(UDIRS,save_udirs,load_setups,save_setups,add_setups)
|
---|
1644 | #pragma alloc_text(UDIRS,remove_setup)
|
---|