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