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