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