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