[123] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: walkem.c 1082 2008-07-19 22:37:36Z 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");
|
---|
| 359 | /*save_dir2(s);
|
---|
[551] | 360 | if (s[strlen(s) - 1] != '\\')
|
---|
| 361 | strcat(s, "\\");
|
---|
[1082] | 362 | strcat(s, "USERDIRS.DAT");*/
|
---|
[551] | 363 | fp = _fsopen(s, "r", SH_DENYWR);
|
---|
| 364 | if (fp) {
|
---|
| 365 | while (!feof(fp)) {
|
---|
| 366 | if (!xfgets(s, CCHMAXPATH + 24, fp, pszSrcFile, __LINE__))
|
---|
| 367 | break;
|
---|
| 368 | s[CCHMAXPATH] = 0;
|
---|
| 369 | bstripcr(s);
|
---|
| 370 | if (*s && *s != ';') {
|
---|
| 371 | info = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
---|
[1078] | 372 | # ifdef FORTIFY
|
---|
| 373 | Fortify_SetOwner(info, 1);
|
---|
| 374 | Fortify_SetScope(info, 1);
|
---|
| 375 | # endif
|
---|
[551] | 376 | if (info) {
|
---|
| 377 | info->path = xstrdup(s, pszSrcFile, __LINE__);
|
---|
| 378 | if (!info->path)
|
---|
[1039] | 379 | free(info);
|
---|
[551] | 380 | else {
|
---|
[1078] | 381 | # ifdef FORTIFY
|
---|
| 382 | Fortify_SetOwner(info->path, 1);
|
---|
| 383 | Fortify_SetScope(info->path, 1);
|
---|
| 384 | # endif
|
---|
[551] | 385 | info->next = NULL;
|
---|
| 386 | if (!udirhead)
|
---|
| 387 | udirhead = info;
|
---|
| 388 | else
|
---|
| 389 | last->next = info;
|
---|
| 390 | last = info;
|
---|
| 391 | }
|
---|
[242] | 392 | }
|
---|
[551] | 393 | }
|
---|
[2] | 394 | }
|
---|
[551] | 395 | fclose(fp);
|
---|
| 396 | }
|
---|
[2] | 397 | }
|
---|
| 398 |
|
---|
[242] | 399 | VOID save_udirs(VOID)
|
---|
| 400 | {
|
---|
[551] | 401 | FILE *fp;
|
---|
| 402 | LINKDIRS *info;
|
---|
| 403 | CHAR s[CCHMAXPATH + 14];
|
---|
[2] | 404 |
|
---|
[551] | 405 | if (loadedudirs) {
|
---|
| 406 | fUdirsChanged = FALSE;
|
---|
| 407 | if (udirhead) {
|
---|
[1082] | 408 | BldFullPathName(s, pFM2SaveDirectory, "USERDIRS.DAT");
|
---|
| 409 | /*save_dir2(s);
|
---|
[551] | 410 | if (s[strlen(s) - 1] != '\\')
|
---|
| 411 | strcat(s, "\\");
|
---|
[1082] | 412 | strcat(s, "USERDIRS.DAT");*/
|
---|
[551] | 413 | fp = xfopen(s, "w", pszSrcFile, __LINE__);
|
---|
| 414 | if (fp) {
|
---|
| 415 | fputs(GetPString(IDS_USERDEFDIRSTEXT), fp);
|
---|
| 416 | info = udirhead;
|
---|
| 417 | while (info) {
|
---|
| 418 | fprintf(fp, "%0.*s\n", CCHMAXPATH, info->path);
|
---|
| 419 | info = info->next;
|
---|
[242] | 420 | }
|
---|
[551] | 421 | fclose(fp);
|
---|
| 422 | }
|
---|
[2] | 423 | }
|
---|
[551] | 424 | }
|
---|
[2] | 425 | }
|
---|
| 426 |
|
---|
[617] | 427 | /**
|
---|
| 428 | * Add path to user directory list or last used directory list.
|
---|
| 429 | * Callers need to check fUdirsChanged to know if user dirs change occured.
|
---|
| 430 | * Callers need to check return code to know if last dirs change occured.
|
---|
| 431 | * @param userdirs TRUE to process user directory list. Otherwise last used list.
|
---|
| 432 | * @return TRUE if added, FALSE if already in list or error.
|
---|
| 433 | */
|
---|
[259] | 434 |
|
---|
[617] | 435 | BOOL add_udir(BOOL userdirs, CHAR *inpath)
|
---|
[242] | 436 | {
|
---|
[551] | 437 | CHAR path[CCHMAXPATH];
|
---|
| 438 | LINKDIRS *info;
|
---|
| 439 | LINKDIRS *last = NULL;
|
---|
| 440 | LINKDIRS *temp;
|
---|
[2] | 441 |
|
---|
[551] | 442 | if (inpath && *inpath) {
|
---|
| 443 | if (DosQueryPathInfo(inpath, FIL_QUERYFULLNAME, path, sizeof(path)))
|
---|
| 444 | strcpy(path, inpath);
|
---|
| 445 | if (!userdirs && IsRoot(path))
|
---|
| 446 | return FALSE;
|
---|
| 447 | if (IsFullName(path)) {
|
---|
| 448 | if (!loadedudirs)
|
---|
| 449 | load_udirs();
|
---|
| 450 | // Search user dir list first unless doing last dirs
|
---|
| 451 | info = userdirs ? udirhead : ldirhead;
|
---|
| 452 | while (info) {
|
---|
| 453 | if (!stricmp(info->path, path))
|
---|
| 454 | return FALSE; // Already in list
|
---|
| 455 | last = info; // Remember append to location
|
---|
| 456 | info = info->next;
|
---|
| 457 | }
|
---|
| 458 | // Search last dir list unless doing just last dirs
|
---|
| 459 | if (!userdirs) {
|
---|
| 460 | info = udirhead;
|
---|
| 461 | while (info) {
|
---|
| 462 | if (!stricmp(info->path, path))
|
---|
[242] | 463 | return FALSE;
|
---|
[551] | 464 | info = info->next;
|
---|
| 465 | }
|
---|
| 466 | }
|
---|
| 467 | else {
|
---|
| 468 | /* if adding manual directory, remove from auto list if present */
|
---|
| 469 | info = ldirhead;
|
---|
| 470 | temp = NULL;
|
---|
| 471 | while (info) {
|
---|
| 472 | if (!stricmp(info->path, path)) {
|
---|
| 473 | if (temp)
|
---|
| 474 | temp->next = info->next;
|
---|
[242] | 475 | else
|
---|
[551] | 476 | ldirhead = info->next;
|
---|
[1009] | 477 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 478 | free(info);
|
---|
[551] | 479 | break;
|
---|
| 480 | }
|
---|
| 481 | temp = info;
|
---|
| 482 | info = info->next;
|
---|
[242] | 483 | }
|
---|
[551] | 484 | }
|
---|
| 485 | // Append entry to end of user dirs list
|
---|
| 486 | info = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
---|
| 487 | if (info) {
|
---|
[1078] | 488 | # ifdef FORTIFY
|
---|
| 489 | Fortify_SetScope(info, 1);
|
---|
| 490 | # endif
|
---|
[551] | 491 | info->path = xstrdup(path, pszSrcFile, __LINE__);
|
---|
| 492 | if (!info->path)
|
---|
[1039] | 493 | free(info);
|
---|
[551] | 494 | else {
|
---|
[1078] | 495 | # ifdef FORTIFY
|
---|
| 496 | Fortify_SetScope(info->path, 1);
|
---|
| 497 | # endif
|
---|
[551] | 498 | info->next = NULL;
|
---|
| 499 | if (userdirs) {
|
---|
| 500 | fUdirsChanged = TRUE;
|
---|
| 501 | if (!udirhead)
|
---|
| 502 | udirhead = info;
|
---|
| 503 | else
|
---|
| 504 | last->next = info;
|
---|
| 505 | }
|
---|
| 506 | else {
|
---|
| 507 | if (!ldirhead)
|
---|
| 508 | ldirhead = info;
|
---|
| 509 | else
|
---|
| 510 | last->next = info;
|
---|
[1077] | 511 | }
|
---|
[551] | 512 | return TRUE;
|
---|
| 513 | }
|
---|
| 514 | }
|
---|
[2] | 515 | }
|
---|
[551] | 516 | }
|
---|
| 517 | return FALSE;
|
---|
[2] | 518 | }
|
---|
| 519 |
|
---|
[259] | 520 | //=== remove_udir - remove path from user dir list or last directory list ===
|
---|
| 521 |
|
---|
[242] | 522 | BOOL remove_udir(CHAR * path)
|
---|
| 523 | {
|
---|
[551] | 524 | LINKDIRS *info;
|
---|
| 525 | LINKDIRS *last = NULL;
|
---|
[2] | 526 |
|
---|
[551] | 527 | if (path && *path) {
|
---|
| 528 | if (!loadedudirs)
|
---|
| 529 | load_udirs();
|
---|
| 530 | info = udirhead;
|
---|
| 531 | while (info) {
|
---|
| 532 | if (!stricmp(info->path, path)) {
|
---|
| 533 | if (last)
|
---|
| 534 | last->next = info->next;
|
---|
| 535 | else
|
---|
| 536 | udirhead = info->next;
|
---|
[1009] | 537 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 538 | free(info);
|
---|
[551] | 539 | fUdirsChanged = TRUE;
|
---|
| 540 | return TRUE;
|
---|
| 541 | }
|
---|
| 542 | last = info;
|
---|
| 543 | info = info->next;
|
---|
| 544 | }
|
---|
[259] | 545 |
|
---|
[551] | 546 | info = ldirhead;
|
---|
| 547 | last = NULL;
|
---|
| 548 | while (info) {
|
---|
| 549 | if (!stricmp(info->path, path)) {
|
---|
| 550 | if (last)
|
---|
| 551 | last->next = info->next;
|
---|
| 552 | else
|
---|
| 553 | ldirhead = info->next;
|
---|
[1009] | 554 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 555 | free(info);
|
---|
[551] | 556 | return TRUE;
|
---|
| 557 | }
|
---|
| 558 | last = info;
|
---|
| 559 | info = info->next;
|
---|
[2] | 560 | }
|
---|
[551] | 561 | }
|
---|
| 562 | return FALSE;
|
---|
[2] | 563 | }
|
---|
| 564 |
|
---|
[242] | 565 | BOOL remove_ldir(CHAR * path)
|
---|
| 566 | {
|
---|
[551] | 567 | LINKDIRS *info;
|
---|
| 568 | LINKDIRS *last = NULL;
|
---|
[2] | 569 |
|
---|
[551] | 570 | if (path && *path) {
|
---|
| 571 | info = ldirhead;
|
---|
| 572 | while (info) {
|
---|
| 573 | if (!stricmp(info->path, path)) {
|
---|
| 574 | if (last)
|
---|
| 575 | last->next = info->next;
|
---|
| 576 | else
|
---|
| 577 | ldirhead = info->next;
|
---|
[1009] | 578 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 579 | free(info);
|
---|
[551] | 580 | return TRUE;
|
---|
| 581 | }
|
---|
| 582 | last = info;
|
---|
| 583 | info = info->next;
|
---|
[2] | 584 | }
|
---|
[551] | 585 | }
|
---|
| 586 | return FALSE;
|
---|
[2] | 587 | }
|
---|
| 588 |
|
---|
[1082] | 589 | # ifdef FORTIFY
|
---|
| 590 |
|
---|
[1029] | 591 | VOID free_ldir(VOID)
|
---|
| 592 | {
|
---|
| 593 | LINKDIRS *info, *next;
|
---|
| 594 |
|
---|
| 595 | info = ldirhead;
|
---|
| 596 | while (info) {
|
---|
| 597 | next = info->next;
|
---|
| 598 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 599 | free(info);
|
---|
[1029] | 600 | info = next;
|
---|
| 601 | }
|
---|
| 602 | ldirhead = NULL;
|
---|
| 603 | }
|
---|
| 604 |
|
---|
[1082] | 605 | # endif
|
---|
| 606 |
|
---|
[1034] | 607 | VOID free_udirs(VOID)
|
---|
[1029] | 608 | {
|
---|
| 609 | LINKDIRS *info, *next;
|
---|
| 610 |
|
---|
| 611 | info = udirhead;
|
---|
| 612 | while (info) {
|
---|
| 613 | next = info->next;
|
---|
| 614 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 615 | free(info);
|
---|
[1029] | 616 | info = next;
|
---|
| 617 | }
|
---|
| 618 | udirhead = NULL;
|
---|
| 619 | }
|
---|
| 620 |
|
---|
[551] | 621 | VOID FillPathListBox(HWND hwnd, HWND hwnddrive, HWND hwnddir, CHAR * pszPath,
|
---|
[242] | 622 | BOOL nounwriteable)
|
---|
| 623 | {
|
---|
[551] | 624 | /*
|
---|
| 625 | * this function fills one or two list boxes with drive and directory
|
---|
| 626 | * information showing all available drives and all directories off of
|
---|
| 627 | * the directory represented by path. This works independently of the
|
---|
| 628 | * current directory.
|
---|
| 629 | */
|
---|
[2] | 630 |
|
---|
[551] | 631 | CHAR szDrive[] = " :", szTemp[1032];
|
---|
[847] | 632 | FILEFINDBUF3 findbuf;
|
---|
[551] | 633 | HDIR hDir = HDIR_CREATE;
|
---|
| 634 | SHORT sDrive;
|
---|
[766] | 635 | ULONG ulDriveNum, ulSearchCount = 1, ulDriveMap;
|
---|
[2] | 636 |
|
---|
[551] | 637 | DosError(FERR_DISABLEHARDERR);
|
---|
| 638 | DosQCurDisk(&ulDriveNum, &ulDriveMap);
|
---|
| 639 | if (hwnddrive)
|
---|
| 640 | WinSendMsg(hwnddrive, LM_DELETEALL, MPVOID, MPVOID);
|
---|
| 641 | if (hwnddrive != hwnddir && hwnddir)
|
---|
| 642 | WinSendMsg(hwnddir, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[2] | 643 |
|
---|
[551] | 644 | if (hwnddrive) {
|
---|
| 645 | // Fill drive listbox
|
---|
| 646 | for (sDrive = 0; sDrive < 26; sDrive++) {
|
---|
[766] | 647 | if (ulDriveMap & (1 << sDrive)) {
|
---|
[551] | 648 | *szDrive = (CHAR) (sDrive + 'A');
|
---|
| 649 | if ((!nounwriteable || !(driveflags[sDrive] & DRIVE_NOTWRITEABLE)) &&
|
---|
| 650 | !(driveflags[sDrive] & (DRIVE_IGNORE | DRIVE_INVALID)))
|
---|
| 651 | WinSendMsg(hwnddrive, LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
|
---|
| 652 | MPFROMP(szDrive));
|
---|
| 653 | }
|
---|
[2] | 654 | }
|
---|
[551] | 655 | if (hwnddrive != hwnddir && pszPath && isalpha(*pszPath)
|
---|
| 656 | && pszPath[1] == ':') {
|
---|
| 657 | *szDrive = toupper(*pszPath);
|
---|
| 658 | WinSetWindowText(hwnddrive, szDrive);
|
---|
| 659 | }
|
---|
| 660 | }
|
---|
[2] | 661 |
|
---|
[551] | 662 | if (hwnddir) {
|
---|
| 663 | // Fill directory listbox
|
---|
| 664 | sprintf(szTemp,
|
---|
| 665 | "%s%s*",
|
---|
| 666 | pszPath, (pszPath[strlen(pszPath) - 1] == '\\') ? "" : "\\");
|
---|
| 667 | DosError(FERR_DISABLEHARDERR);
|
---|
[847] | 668 | if (!DosFindFirst(szTemp,
|
---|
| 669 | &hDir,
|
---|
| 670 | FILE_DIRECTORY | MUST_HAVE_DIRECTORY |
|
---|
| 671 | FILE_READONLY | FILE_ARCHIVED | FILE_SYSTEM |
|
---|
| 672 | FILE_HIDDEN,
|
---|
| 673 | &findbuf,
|
---|
| 674 | sizeof(FILEFINDBUF3), &ulSearchCount, FIL_STANDARD)) {
|
---|
[551] | 675 | do {
|
---|
| 676 | if (findbuf.attrFile & FILE_DIRECTORY) {
|
---|
| 677 | // Skip .. unless full path supplied
|
---|
| 678 | if (strcmp(findbuf.achName, "..") ||
|
---|
| 679 | strlen(pszPath) > 3 || pszPath[1] != ':') {
|
---|
| 680 | // Skip . allow ..
|
---|
| 681 | if (findbuf.achName[0] != '.' || findbuf.achName[1]) {
|
---|
| 682 | WinSendMsg(hwnddir,
|
---|
| 683 | LM_INSERTITEM,
|
---|
| 684 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
| 685 | MPFROMP(findbuf.achName));
|
---|
| 686 | }
|
---|
| 687 | }
|
---|
[242] | 688 | }
|
---|
[766] | 689 | ulSearchCount = 1;
|
---|
[847] | 690 | } while (!DosFindNext(hDir,
|
---|
| 691 | &findbuf, sizeof(FILEFINDBUF3), &ulSearchCount));
|
---|
[551] | 692 | DosFindClose(hDir);
|
---|
[2] | 693 | }
|
---|
[551] | 694 | DosError(FERR_DISABLEHARDERR);
|
---|
| 695 | }
|
---|
[2] | 696 | }
|
---|
| 697 |
|
---|
[242] | 698 | MRESULT EXPENTRY TextSubProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 699 | {
|
---|
[574] | 700 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[2] | 701 |
|
---|
[551] | 702 | switch (msg) {
|
---|
| 703 | case WM_CHAR:
|
---|
| 704 | if (SHORT1FROMMP(mp1) & KC_KEYUP) {
|
---|
| 705 | if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) &&
|
---|
| 706 | (SHORT1FROMMP(mp2) & 255) == '\r')
|
---|
| 707 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND,
|
---|
| 708 | MPFROM2SHORT(DID_OK, 0), MPVOID);
|
---|
[242] | 709 | }
|
---|
[551] | 710 | break;
|
---|
| 711 | }
|
---|
| 712 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
[2] | 713 | }
|
---|
| 714 |
|
---|
[242] | 715 | MRESULT EXPENTRY WalkDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 716 | {
|
---|
[551] | 717 | WALKER *wa;
|
---|
| 718 | CHAR szBuff[CCHMAXPATH + 1], szBuffer[CCHMAXPATH + 1], *p;
|
---|
| 719 | SHORT sSelect;
|
---|
| 720 | static BOOL okay; /* avoid combobox selecting as filled */
|
---|
| 721 | static CHAR lastdir[CCHMAXPATH + 1];
|
---|
[2] | 722 |
|
---|
[551] | 723 | switch (msg) {
|
---|
| 724 | case UM_SETUP2:
|
---|
| 725 | case WM_INITDLG:
|
---|
| 726 | okay = FALSE;
|
---|
| 727 | *lastdir = 0;
|
---|
| 728 | if (!mp2) {
|
---|
| 729 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 730 | WinDismissDlg(hwnd, 0);
|
---|
| 731 | break;
|
---|
| 732 | }
|
---|
| 733 | wa = xmallocz(sizeof(WALKER), pszSrcFile, __LINE__);
|
---|
| 734 | if (!wa) {
|
---|
| 735 | WinDismissDlg(hwnd, 0);
|
---|
| 736 | break;
|
---|
| 737 | }
|
---|
| 738 | wa->size = (USHORT) sizeof(WALKER);
|
---|
[574] | 739 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) wa);
|
---|
[1009] | 740 | wa->szReturnPath = (CHAR *)mp2;
|
---|
[242] | 741 | {
|
---|
[551] | 742 | PFNWP oldproc;
|
---|
[2] | 743 |
|
---|
[551] | 744 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK_PATH),
|
---|
| 745 | (PFNWP) TextSubProc);
|
---|
| 746 | if (oldproc)
|
---|
| 747 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK_PATH),
|
---|
| 748 | QWL_USER, (PVOID) oldproc);
|
---|
| 749 | WinSendDlgItemMsg(WinWindowFromID(hwnd, WALK_RECENT),
|
---|
| 750 | CBID_EDIT,
|
---|
| 751 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 752 | WinSendDlgItemMsg(WinWindowFromID(hwnd, WALK_RECENT),
|
---|
| 753 | CBID_EDIT,
|
---|
| 754 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
|
---|
| 755 | }
|
---|
[939] | 756 | {
|
---|
| 757 | SWP swp;
|
---|
| 758 | ULONG size = sizeof(SWP);
|
---|
| 759 |
|
---|
| 760 | PrfQueryProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp, &size);
|
---|
| 761 | WinSetWindowPos(hwnd,
|
---|
[1077] | 762 | HWND_TOP,
|
---|
| 763 | swp.x,
|
---|
| 764 | swp.y,
|
---|
| 765 | swp.cx,
|
---|
| 766 | swp.cy,
|
---|
| 767 | swp.fl);
|
---|
[939] | 768 | }
|
---|
[551] | 769 | PosOverOkay(hwnd);
|
---|
| 770 | if (msg == UM_SETUP2)
|
---|
| 771 | wa->nounwriteable = FALSE;
|
---|
| 772 | else
|
---|
| 773 | wa->nounwriteable = TRUE;
|
---|
| 774 | if (!*wa->szReturnPath)
|
---|
| 775 | save_dir2(wa->szCurrentPath);
|
---|
| 776 | else {
|
---|
| 777 | strcpy(wa->szCurrentPath, wa->szReturnPath);
|
---|
| 778 | MakeFullName(wa->szCurrentPath);
|
---|
| 779 | }
|
---|
| 780 | if (wa->nounwriteable &&
|
---|
| 781 | (driveflags[toupper(*wa->szCurrentPath) - 'A'] &
|
---|
| 782 | DRIVE_NOTWRITEABLE)) {
|
---|
[2] | 783 |
|
---|
[551] | 784 | ULONG bd;
|
---|
[2] | 785 |
|
---|
[551] | 786 | strcpy(wa->szCurrentPath, "C:\\");
|
---|
| 787 | if (DosQuerySysInfo(QSV_BOOT_DRIVE,
|
---|
| 788 | QSV_BOOT_DRIVE,
|
---|
| 789 | (PVOID) & bd, (ULONG) sizeof(ULONG)))
|
---|
[766] | 790 | bd = 3;
|
---|
[551] | 791 | *wa->szCurrentPath = (CHAR) bd + '@';
|
---|
| 792 | }
|
---|
| 793 | WinSendDlgItemMsg(hwnd,
|
---|
| 794 | WALK_PATH,
|
---|
| 795 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 796 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
| 797 | if (!loadedudirs)
|
---|
| 798 | load_udirs();
|
---|
| 799 | { /* fill user list box */
|
---|
| 800 | ULONG ulDriveNum, ulDriveMap;
|
---|
| 801 | ULONG ulSearchCount;
|
---|
[847] | 802 | FILEFINDBUF3 findbuf;
|
---|
[551] | 803 | HDIR hDir;
|
---|
| 804 | APIRET rc;
|
---|
| 805 | LINKDIRS *info, *temp;
|
---|
[2] | 806 |
|
---|
[551] | 807 | DosError(FERR_DISABLEHARDERR);
|
---|
| 808 | DosQCurDisk(&ulDriveNum, &ulDriveMap);
|
---|
| 809 | info = udirhead;
|
---|
| 810 | while (info) {
|
---|
| 811 | if (IsFullName(info->path) &&
|
---|
| 812 | !(driveflags[toupper(*info->path) - 'A'] &
|
---|
| 813 | (DRIVE_IGNORE | DRIVE_INVALID))) {
|
---|
| 814 | DosError(FERR_DISABLEHARDERR);
|
---|
| 815 | hDir = HDIR_CREATE;
|
---|
[766] | 816 | ulSearchCount = 1;
|
---|
[551] | 817 | if (!IsRoot(info->path))
|
---|
[847] | 818 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
|
---|
| 819 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
| 820 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 821 | &findbuf, sizeof(FILEFINDBUF3),
|
---|
| 822 | &ulSearchCount, FIL_STANDARD);
|
---|
[551] | 823 | else {
|
---|
| 824 | rc = 0;
|
---|
| 825 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
| 826 | }
|
---|
| 827 | if (!rc) {
|
---|
| 828 | if (!IsRoot(info->path))
|
---|
| 829 | DosFindClose(hDir);
|
---|
| 830 | if (findbuf.attrFile & FILE_DIRECTORY)
|
---|
| 831 | WinSendDlgItemMsg(hwnd, WALK_USERLIST, LM_INSERTITEM,
|
---|
| 832 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
| 833 | MPFROMP(info->path));
|
---|
| 834 | else {
|
---|
| 835 | temp = info->next;
|
---|
| 836 | remove_udir(info->path);
|
---|
| 837 | info = temp;
|
---|
| 838 | continue;
|
---|
[242] | 839 | }
|
---|
[551] | 840 | }
|
---|
[766] | 841 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
|
---|
[551] | 842 | temp = info->next;
|
---|
| 843 | remove_udir(info->path);
|
---|
| 844 | info = temp;
|
---|
| 845 | continue;
|
---|
| 846 | }
|
---|
| 847 | }
|
---|
| 848 | info = info->next;
|
---|
| 849 | }
|
---|
| 850 | info = ldirhead;
|
---|
| 851 | while (info) {
|
---|
| 852 | if (IsFullName(info->path) &&
|
---|
| 853 | !(driveflags[toupper(*info->path) - 'A'] &
|
---|
| 854 | (DRIVE_IGNORE | DRIVE_INVALID))) {
|
---|
| 855 | DosError(FERR_DISABLEHARDERR);
|
---|
| 856 | hDir = HDIR_CREATE;
|
---|
[766] | 857 | ulSearchCount = 1;
|
---|
[551] | 858 | if (!IsRoot(info->path))
|
---|
[847] | 859 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
|
---|
| 860 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
| 861 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 862 | &findbuf, sizeof(FILEFINDBUF3),
|
---|
| 863 | &ulSearchCount, FIL_STANDARD);
|
---|
[551] | 864 | else {
|
---|
| 865 | rc = 0;
|
---|
| 866 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
| 867 | }
|
---|
| 868 | if (!rc) {
|
---|
| 869 | if (!IsRoot(info->path))
|
---|
| 870 | DosFindClose(hDir);
|
---|
| 871 | if (findbuf.attrFile & FILE_DIRECTORY)
|
---|
| 872 | WinSendDlgItemMsg(hwnd, WALK_RECENT, LM_INSERTITEM,
|
---|
| 873 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
| 874 | MPFROMP(info->path));
|
---|
| 875 | else {
|
---|
| 876 | temp = info->next;
|
---|
| 877 | remove_ldir(info->path);
|
---|
| 878 | info = temp;
|
---|
| 879 | continue;
|
---|
[242] | 880 | }
|
---|
[551] | 881 | WinSetDlgItemText(hwnd, WALK_RECENT,
|
---|
| 882 | GetPString(IDS_WALKRECENTDIRSTEXT));
|
---|
| 883 | }
|
---|
[766] | 884 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
|
---|
[551] | 885 | temp = info->next;
|
---|
| 886 | remove_ldir(info->path);
|
---|
| 887 | info = temp;
|
---|
| 888 | continue;
|
---|
| 889 | }
|
---|
[242] | 890 | }
|
---|
[551] | 891 | info = info->next;
|
---|
| 892 | }
|
---|
| 893 | }
|
---|
| 894 | FillPathListBox(hwnd,
|
---|
| 895 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
| 896 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
| 897 | wa->szCurrentPath, wa->nounwriteable);
|
---|
| 898 | if (!PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID))
|
---|
| 899 | okay = TRUE;
|
---|
| 900 | {
|
---|
| 901 | MRESULT ret;
|
---|
[2] | 902 |
|
---|
[551] | 903 | ret = WinDefDlgProc(hwnd, WM_INITDLG, mp1, mp2);
|
---|
| 904 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 905 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
---|
| 906 | return ret;
|
---|
| 907 | }
|
---|
[2] | 908 |
|
---|
[551] | 909 | case UM_SETUP4:
|
---|
| 910 | okay = TRUE;
|
---|
| 911 | return 0;
|
---|
[2] | 912 |
|
---|
[551] | 913 | case WM_ADJUSTWINDOWPOS:
|
---|
| 914 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 915 | break;
|
---|
[2] | 916 |
|
---|
[551] | 917 | case UM_SETDIR:
|
---|
| 918 | PaintRecessedWindow(WinWindowFromID(hwnd, WALK_HELP), (HPS) 0, FALSE,
|
---|
| 919 | TRUE);
|
---|
| 920 | return 0;
|
---|
[2] | 921 |
|
---|
[551] | 922 | case WM_PRESPARAMCHANGED:
|
---|
| 923 | {
|
---|
| 924 | ULONG AttrFound, AttrValue[64], cbRetLen;
|
---|
[2] | 925 |
|
---|
[551] | 926 | cbRetLen = WinQueryPresParam(hwnd, (ULONG) mp1, 0, &AttrFound,
|
---|
| 927 | (ULONG) sizeof(AttrValue), &AttrValue, 0);
|
---|
| 928 | if (cbRetLen) {
|
---|
| 929 | switch (AttrFound) {
|
---|
| 930 | case PP_FONTNAMESIZE:
|
---|
| 931 | PrfWriteProfileData(fmprof,
|
---|
| 932 | appname,
|
---|
| 933 | "WalkFont", (PVOID) AttrValue, cbRetLen);
|
---|
| 934 | *WalkFont = 0;
|
---|
| 935 | WalkFontSize = sizeof(WalkFont);
|
---|
| 936 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
---|
| 937 | break;
|
---|
[242] | 938 | }
|
---|
[551] | 939 | }
|
---|
| 940 | }
|
---|
| 941 | break;
|
---|
[2] | 942 |
|
---|
[551] | 943 | case UM_SETUP3:
|
---|
| 944 | save_udirs();
|
---|
| 945 | if (hwndMain)
|
---|
| 946 | PostMsg(hwndMain, UM_FILLUSERLIST, MPVOID, MPVOID);
|
---|
| 947 | return 0;
|
---|
[2] | 948 |
|
---|
[551] | 949 | case UM_SETUP:
|
---|
| 950 | {
|
---|
| 951 | INT x;
|
---|
| 952 | USHORT id[] = { WALK_PATH, WALK_DIRLIST, WALK_USERLIST,
|
---|
| 953 | WALK_RECENT, 0
|
---|
| 954 | };
|
---|
[2] | 955 |
|
---|
[551] | 956 | if (*WalkFont ||
|
---|
| 957 | (PrfQueryProfileData(fmprof,
|
---|
| 958 | appname,
|
---|
| 959 | "WalkFont",
|
---|
| 960 | (PVOID) WalkFont,
|
---|
| 961 | &WalkFontSize) && WalkFontSize)) {
|
---|
| 962 | for (x = 0; id[x]; x++)
|
---|
| 963 | WinSetPresParam(WinWindowFromID(hwnd, id[x]),
|
---|
| 964 | PP_FONTNAMESIZE, WalkFontSize, (PVOID) WalkFont);
|
---|
| 965 | }
|
---|
| 966 | }
|
---|
| 967 | return 0;
|
---|
[2] | 968 |
|
---|
[551] | 969 | case UM_CONTROL:
|
---|
| 970 | case WM_CONTROL:
|
---|
[574] | 971 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 972 | if (SHORT1FROMMP(mp1) == WALK_DRIVELIST ||
|
---|
| 973 | SHORT1FROMMP(mp1) == WALK_DIRLIST ||
|
---|
| 974 | SHORT1FROMMP(mp1) == WALK_USERLIST ||
|
---|
| 975 | SHORT1FROMMP(mp1) == WALK_RECENT) {
|
---|
| 976 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 977 | SHORT1FROMMP(mp1),
|
---|
| 978 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
---|
| 979 | *szBuffer = 0;
|
---|
| 980 | if (sSelect >= 0)
|
---|
| 981 | WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
|
---|
| 982 | MPFROM2SHORT(sSelect, CCHMAXPATH),
|
---|
| 983 | MPFROMP(szBuffer));
|
---|
| 984 | }
|
---|
| 985 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 986 | case WALK_PATH:
|
---|
| 987 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
| 988 | WinSetDlgItemText(hwnd, WALK_HELP, GetPString(IDS_WALKCURRDIRTEXT));
|
---|
| 989 | else if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
| 990 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
| 991 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
| 992 | break;
|
---|
[2] | 993 |
|
---|
[551] | 994 | case WALK_RECENT:
|
---|
| 995 | if (okay && SHORT2FROMMP(mp1) == CBN_LBSELECT) {
|
---|
[2] | 996 |
|
---|
[551] | 997 | ULONG ulSearchCount;
|
---|
[847] | 998 | FILEFINDBUF3 findbuf;
|
---|
[551] | 999 | HDIR hDir;
|
---|
| 1000 | APIRET rc;
|
---|
[2] | 1001 |
|
---|
[551] | 1002 | // *szBuffer = 0;
|
---|
| 1003 | // WinQueryDlgItemText(hwnd,WALK_RECENT,CCHMAXPATH,szBuffer);
|
---|
| 1004 | if (!*szBuffer)
|
---|
| 1005 | break;
|
---|
| 1006 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1007 | hDir = HDIR_CREATE;
|
---|
[766] | 1008 | ulSearchCount = 1;
|
---|
[551] | 1009 | if (!IsRoot(szBuffer)) {
|
---|
[847] | 1010 | rc = DosFindFirst(szBuffer, &hDir, FILE_DIRECTORY |
|
---|
| 1011 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
| 1012 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 1013 | &findbuf, sizeof(FILEFINDBUF3),
|
---|
| 1014 | &ulSearchCount, FIL_STANDARD);
|
---|
[551] | 1015 | if (!rc)
|
---|
| 1016 | DosFindClose(hDir);
|
---|
| 1017 | }
|
---|
| 1018 | else {
|
---|
| 1019 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
| 1020 | rc = 0;
|
---|
| 1021 | }
|
---|
| 1022 | if (rc)
|
---|
| 1023 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
---|
[838] | 1024 | "xDosFindFirst");
|
---|
[551] | 1025 | else if (~findbuf.attrFile & FILE_DIRECTORY)
|
---|
| 1026 | Runtime_Error(pszSrcFile, __LINE__, "not a directory");
|
---|
| 1027 | else {
|
---|
| 1028 | strcpy(wa->szCurrentPath, szBuffer);
|
---|
| 1029 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
| 1030 | WinSetDlgItemText(hwnd, WALK_RECENT, wa->szCurrentPath);
|
---|
| 1031 | FillPathListBox(hwnd,
|
---|
| 1032 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
| 1033 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
| 1034 | wa->szCurrentPath, FALSE);
|
---|
| 1035 | }
|
---|
| 1036 | }
|
---|
| 1037 | else if (SHORT2FROMMP(mp1) == CBN_ENTER)
|
---|
| 1038 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
---|
| 1039 | else if (SHORT2FROMMP(mp1) == CBN_SHOWLIST)
|
---|
| 1040 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
| 1041 | GetPString(IDS_WALKRECENTDIRSHELPTEXT));
|
---|
| 1042 | break;
|
---|
[2] | 1043 |
|
---|
[551] | 1044 | case WALK_USERLIST:
|
---|
| 1045 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_SELECT) {
|
---|
[2] | 1046 |
|
---|
[551] | 1047 | ULONG ulSearchCount;
|
---|
[847] | 1048 | FILEFINDBUF3 findbuf;
|
---|
[551] | 1049 | HDIR hDir;
|
---|
| 1050 | APIRET rc;
|
---|
[2] | 1051 |
|
---|
[551] | 1052 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1053 | hDir = HDIR_CREATE;
|
---|
[766] | 1054 | ulSearchCount = 1;
|
---|
[551] | 1055 | if (!IsRoot(szBuffer)) {
|
---|
[847] | 1056 | rc = DosFindFirst(szBuffer,
|
---|
| 1057 | &hDir,
|
---|
| 1058 | FILE_DIRECTORY |
|
---|
| 1059 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
| 1060 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 1061 | &findbuf,
|
---|
| 1062 | sizeof(FILEFINDBUF3),
|
---|
| 1063 | &ulSearchCount, FIL_STANDARD);
|
---|
[551] | 1064 | if (!rc)
|
---|
| 1065 | DosFindClose(hDir);
|
---|
| 1066 | }
|
---|
| 1067 | else {
|
---|
| 1068 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
| 1069 | rc = 0;
|
---|
| 1070 | }
|
---|
| 1071 | if (rc)
|
---|
| 1072 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
---|
[838] | 1073 | "xDosFindFirst");
|
---|
[551] | 1074 | else if (~findbuf.attrFile & FILE_DIRECTORY)
|
---|
| 1075 | Runtime_Error(pszSrcFile, __LINE__, "not a directory");
|
---|
| 1076 | else {
|
---|
| 1077 | strcpy(wa->szCurrentPath, szBuffer);
|
---|
| 1078 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
| 1079 | FillPathListBox(hwnd,
|
---|
| 1080 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
| 1081 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
| 1082 | wa->szCurrentPath, FALSE);
|
---|
| 1083 | }
|
---|
| 1084 | }
|
---|
| 1085 | else if (SHORT2FROMMP(mp1) == LN_ENTER)
|
---|
| 1086 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
---|
| 1087 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
---|
| 1088 | WinSetDlgItemText(hwnd,
|
---|
| 1089 | WALK_HELP, GetPString(IDS_WALKUSERDIRSHELPTEXT));
|
---|
| 1090 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
---|
| 1091 | WinSetDlgItemText(hwnd,
|
---|
| 1092 | WALK_HELP, GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
| 1093 | break;
|
---|
[2] | 1094 |
|
---|
[551] | 1095 | case WALK_DRIVELIST:
|
---|
| 1096 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1097 |
|
---|
[551] | 1098 | ULONG ulDirLen = CCHMAXPATH;
|
---|
| 1099 | APIRET rc;
|
---|
[2] | 1100 |
|
---|
[551] | 1101 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
---|
| 1102 | if (!rc) {
|
---|
| 1103 | strcpy(wa->szCurrentPath, "C:\\");
|
---|
| 1104 | *wa->szCurrentPath = toupper(*szBuffer);
|
---|
| 1105 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
| 1106 | FillPathListBox(hwnd,
|
---|
| 1107 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
| 1108 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
| 1109 | wa->szCurrentPath, FALSE);
|
---|
| 1110 | }
|
---|
| 1111 | }
|
---|
| 1112 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
---|
| 1113 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
| 1114 | GetPString(IDS_WALKDRIVELISTHELPTEXT));
|
---|
| 1115 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
---|
| 1116 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
| 1117 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
| 1118 | break;
|
---|
[2] | 1119 |
|
---|
[551] | 1120 | case WALK_DIRLIST:
|
---|
| 1121 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1122 |
|
---|
[551] | 1123 | ULONG ulSearchCount;
|
---|
[847] | 1124 | FILEFINDBUF3 findbuf;
|
---|
[551] | 1125 | HDIR hDir;
|
---|
| 1126 | APIRET rc;
|
---|
[2] | 1127 |
|
---|
[551] | 1128 | bstrip(szBuffer);
|
---|
| 1129 | if (*szBuffer) {
|
---|
| 1130 | strcpy(szBuff, wa->szCurrentPath);
|
---|
| 1131 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
---|
| 1132 | strcat(szBuff, "\\");
|
---|
| 1133 | strcat(szBuff, szBuffer);
|
---|
| 1134 | MakeFullName(szBuff);
|
---|
| 1135 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1136 | hDir = HDIR_CREATE;
|
---|
[766] | 1137 | ulSearchCount = 1;
|
---|
[551] | 1138 | if (!IsRoot(szBuff)) {
|
---|
[847] | 1139 | rc = DosFindFirst(szBuff,
|
---|
| 1140 | &hDir,
|
---|
| 1141 | FILE_DIRECTORY |
|
---|
| 1142 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
| 1143 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 1144 | &findbuf,
|
---|
| 1145 | sizeof(FILEFINDBUF3),
|
---|
| 1146 | &ulSearchCount, FIL_STANDARD);
|
---|
[551] | 1147 | if (!rc)
|
---|
| 1148 | DosFindClose(hDir);
|
---|
| 1149 | }
|
---|
| 1150 | else {
|
---|
| 1151 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
| 1152 | rc = 0;
|
---|
| 1153 | }
|
---|
| 1154 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
---|
| 1155 | strcpy(wa->szCurrentPath, szBuff);
|
---|
| 1156 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
| 1157 | FillPathListBox(hwnd,
|
---|
| 1158 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
| 1159 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
| 1160 | wa->szCurrentPath, FALSE);
|
---|
| 1161 | }
|
---|
[242] | 1162 | }
|
---|
[551] | 1163 | }
|
---|
| 1164 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
---|
| 1165 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
| 1166 | GetPString(IDS_WALKDIRLISTHELPTEXT));
|
---|
| 1167 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
---|
| 1168 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
| 1169 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
| 1170 | break;
|
---|
| 1171 | }
|
---|
| 1172 | return 0;
|
---|
| 1173 |
|
---|
| 1174 | case WM_COMMAND:
|
---|
[574] | 1175 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 1176 | if (!wa)
|
---|
| 1177 | WinDismissDlg(hwnd, 0);
|
---|
| 1178 | *szBuff = 0;
|
---|
| 1179 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
---|
| 1180 | bstrip(szBuff);
|
---|
| 1181 | while ((p = strchr(szBuff, '/')) != NULL)
|
---|
| 1182 | *p = '\\';
|
---|
| 1183 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
---|
| 1184 | szBuff[strlen(szBuff) - 1] = 0;
|
---|
| 1185 | MakeFullName(szBuff);
|
---|
[864] | 1186 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
---|
[551] | 1187 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1188 | QW_OWNER), hwnd, szBuff, 0))
|
---|
| 1189 | strcpy(wa->szCurrentPath, szBuff);
|
---|
[865] | 1190 | else
|
---|
[242] | 1191 | return 0;
|
---|
[551] | 1192 | }
|
---|
| 1193 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
---|
| 1194 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1195 | case WALK_ADD:
|
---|
| 1196 | *szBuff = 0;
|
---|
| 1197 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
---|
| 1198 | bstrip(szBuff);
|
---|
| 1199 | while ((p = strchr(szBuff, '/')) != NULL)
|
---|
| 1200 | *p = '\\';
|
---|
| 1201 | if (*szBuff && !IsFile(szBuff)) {
|
---|
| 1202 | MakeFullName(szBuff);
|
---|
[617] | 1203 | add_udir(TRUE, szBuff);
|
---|
| 1204 | if (fUdirsChanged) {
|
---|
[551] | 1205 | WinSendDlgItemMsg(hwnd,
|
---|
| 1206 | WALK_USERLIST,
|
---|
| 1207 | LM_INSERTITEM,
|
---|
| 1208 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
| 1209 | MPFROMP(szBuff));
|
---|
| 1210 | wa->changed = 1;
|
---|
| 1211 | }
|
---|
| 1212 | }
|
---|
| 1213 | break;
|
---|
[2] | 1214 |
|
---|
[551] | 1215 | case WALK_DELETE:
|
---|
| 1216 | *szBuff = 0;
|
---|
| 1217 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
---|
| 1218 | bstrip(szBuff);
|
---|
| 1219 | while ((p = strchr(szBuff, '/')) != NULL)
|
---|
| 1220 | *p = '\\';
|
---|
| 1221 | if (*szBuff && !IsFile(szBuff)) {
|
---|
[242] | 1222 | MakeFullName(szBuff);
|
---|
[551] | 1223 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 1224 | WALK_USERLIST,
|
---|
| 1225 | LM_SEARCHSTRING,
|
---|
| 1226 | MPFROM2SHORT(0, LIT_FIRST),
|
---|
| 1227 | MPFROMP(szBuff));
|
---|
| 1228 | if (sSelect >= 0) {
|
---|
| 1229 | WinSendDlgItemMsg(hwnd,
|
---|
| 1230 | WALK_USERLIST,
|
---|
| 1231 | LM_DELETEITEM, MPFROM2SHORT(sSelect, 0), MPVOID);
|
---|
| 1232 | remove_udir(szBuff);
|
---|
| 1233 | wa->changed = 1;
|
---|
[242] | 1234 | }
|
---|
[551] | 1235 | }
|
---|
| 1236 | break;
|
---|
[2] | 1237 |
|
---|
[551] | 1238 | case DID_OK:
|
---|
| 1239 | if (*wa->szCurrentPath) {
|
---|
| 1240 | strcpy(wa->szReturnPath, wa->szCurrentPath);
|
---|
| 1241 | MakeValidDir(wa->szReturnPath);
|
---|
| 1242 | if (fAutoAddAllDirs)
|
---|
| 1243 | add_udir(FALSE, wa->szReturnPath);
|
---|
| 1244 | if (fChangeTarget) {
|
---|
| 1245 | strcpy(targetdir, wa->szReturnPath);
|
---|
| 1246 | PrfWriteProfileString(fmprof, appname, "Targetdir", targetdir);
|
---|
| 1247 | }
|
---|
| 1248 | }
|
---|
[939] | 1249 | {
|
---|
[1077] | 1250 | SWP swp;
|
---|
| 1251 | ULONG size = sizeof(SWP);
|
---|
[939] | 1252 |
|
---|
[1077] | 1253 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 1254 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
|
---|
| 1255 | size);
|
---|
[939] | 1256 | }
|
---|
[551] | 1257 | if (wa->changed)
|
---|
| 1258 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
| 1259 | WinDismissDlg(hwnd, 1);
|
---|
| 1260 | break;
|
---|
[2] | 1261 |
|
---|
[551] | 1262 | case IDM_HELP:
|
---|
| 1263 | if (hwndHelp)
|
---|
| 1264 | WinSendMsg(hwndHelp,
|
---|
| 1265 | HM_DISPLAY_HELP,
|
---|
| 1266 | MPFROM2SHORT(HELP_WALKEM, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 1267 | break;
|
---|
[2] | 1268 |
|
---|
[551] | 1269 | case DID_CANCEL:
|
---|
[939] | 1270 | {
|
---|
[1077] | 1271 | SWP swp;
|
---|
| 1272 | ULONG size = sizeof(SWP);
|
---|
[939] | 1273 |
|
---|
[1077] | 1274 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 1275 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
|
---|
| 1276 | size);
|
---|
[939] | 1277 | }
|
---|
[551] | 1278 | if (wa->changed)
|
---|
[1077] | 1279 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
[1039] | 1280 | free(wa);
|
---|
[551] | 1281 | WinDismissDlg(hwnd, 0);
|
---|
| 1282 | break;
|
---|
| 1283 | }
|
---|
| 1284 | return 0;
|
---|
[2] | 1285 |
|
---|
[551] | 1286 | case WM_CLOSE:
|
---|
[1077] | 1287 | break;
|
---|
[551] | 1288 | }
|
---|
| 1289 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1290 | }
|
---|
| 1291 |
|
---|
[242] | 1292 | MRESULT EXPENTRY WalkAllDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 1293 | {
|
---|
[551] | 1294 | switch (msg) {
|
---|
| 1295 | case WM_INITDLG:
|
---|
| 1296 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1297 | }
|
---|
| 1298 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1299 | }
|
---|
| 1300 |
|
---|
[242] | 1301 | MRESULT EXPENTRY WalkCopyDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 1302 | {
|
---|
[551] | 1303 | switch (msg) {
|
---|
| 1304 | case WM_INITDLG:
|
---|
| 1305 | WinSetWindowText(hwnd, GetPString(IDS_WALKCOPYDLGTEXT));
|
---|
| 1306 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1307 | }
|
---|
| 1308 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1309 | }
|
---|
| 1310 |
|
---|
[242] | 1311 | MRESULT EXPENTRY WalkMoveDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 1312 | {
|
---|
[551] | 1313 | switch (msg) {
|
---|
| 1314 | case WM_INITDLG:
|
---|
| 1315 | WinSetWindowText(hwnd, GetPString(IDS_WALKMOVEDLGTEXT));
|
---|
| 1316 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1317 | }
|
---|
| 1318 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1319 | }
|
---|
| 1320 |
|
---|
[242] | 1321 | MRESULT EXPENTRY WalkExtractDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1322 | MPARAM mp2)
|
---|
| 1323 | {
|
---|
[551] | 1324 | switch (msg) {
|
---|
| 1325 | case WM_INITDLG:
|
---|
| 1326 | WinSetWindowText(hwnd, GetPString(IDS_WALKEXTRACTDLGTEXT));
|
---|
| 1327 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1328 | }
|
---|
| 1329 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1330 | }
|
---|
| 1331 |
|
---|
[242] | 1332 | MRESULT EXPENTRY WalkTargetDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1333 | MPARAM mp2)
|
---|
| 1334 | {
|
---|
[551] | 1335 | switch (msg) {
|
---|
| 1336 | case WM_INITDLG:
|
---|
[242] | 1337 | {
|
---|
[551] | 1338 | char s[CCHMAXPATH + 32];
|
---|
[2] | 1339 |
|
---|
[551] | 1340 | sprintf(s,
|
---|
| 1341 | GetPString(IDS_WALKTARGETDLGTEXT),
|
---|
| 1342 | (*targetdir) ?
|
---|
| 1343 | NullStr :
|
---|
| 1344 | " (",
|
---|
| 1345 | (*targetdir) ?
|
---|
| 1346 | NullStr : GetPString(IDS_NONE), (*targetdir) ? NullStr : ")");
|
---|
| 1347 | WinSetWindowText(hwnd, s);
|
---|
[242] | 1348 | }
|
---|
[551] | 1349 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1350 | }
|
---|
| 1351 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1352 | }
|
---|
| 1353 |
|
---|
[242] | 1354 | MRESULT EXPENTRY WalkTwoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 1355 | {
|
---|
[551] | 1356 | WALK2 *wa;
|
---|
| 1357 | CHAR szBuff[CCHMAXPATH + 1], szBuffer[CCHMAXPATH + 1], *p;
|
---|
| 1358 | SHORT sSelect;
|
---|
| 1359 | static BOOL okay; /* avoid combobox selecting as filled */
|
---|
[2] | 1360 |
|
---|
[551] | 1361 | switch (msg) {
|
---|
| 1362 | case UM_SETUP2:
|
---|
| 1363 | case WM_INITDLG:
|
---|
| 1364 | okay = FALSE;
|
---|
| 1365 | if (!mp2) {
|
---|
| 1366 | WinDismissDlg(hwnd, 0);
|
---|
| 1367 | break;
|
---|
| 1368 | }
|
---|
[574] | 1369 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
[551] | 1370 | wa = mp2;
|
---|
[242] | 1371 | {
|
---|
[551] | 1372 | PFNWP oldproc;
|
---|
[2] | 1373 |
|
---|
[551] | 1374 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK_PATH),
|
---|
| 1375 | (PFNWP) TextSubProc);
|
---|
| 1376 | if (oldproc)
|
---|
| 1377 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK_PATH),
|
---|
| 1378 | QWL_USER, (PVOID) oldproc);
|
---|
| 1379 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK2_PATH),
|
---|
| 1380 | (PFNWP) TextSubProc);
|
---|
| 1381 | if (oldproc)
|
---|
| 1382 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK2_PATH),
|
---|
| 1383 | QWL_USER, (PVOID) oldproc);
|
---|
| 1384 | }
|
---|
[939] | 1385 | {
|
---|
| 1386 | SWP swp;
|
---|
| 1387 | ULONG size = sizeof(SWP);
|
---|
| 1388 |
|
---|
| 1389 | PrfQueryProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp, &size);
|
---|
| 1390 | WinSetWindowPos(hwnd,
|
---|
[1077] | 1391 | HWND_TOP,
|
---|
| 1392 | swp.x,
|
---|
| 1393 | swp.y,
|
---|
| 1394 | swp.cx,
|
---|
| 1395 | swp.cy,
|
---|
| 1396 | swp.fl);
|
---|
[939] | 1397 | }
|
---|
[551] | 1398 | if (!*wa->szCurrentPath1)
|
---|
| 1399 | save_dir2(wa->szCurrentPath1);
|
---|
| 1400 | MakeFullName(wa->szCurrentPath1);
|
---|
| 1401 | if (!*wa->szCurrentPath2)
|
---|
| 1402 | save_dir2(wa->szCurrentPath2);
|
---|
| 1403 | MakeFullName(wa->szCurrentPath2);
|
---|
| 1404 | WinSendDlgItemMsg(hwnd,
|
---|
| 1405 | WALK_PATH,
|
---|
| 1406 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 1407 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
---|
| 1408 | WinSendDlgItemMsg(hwnd, WALK2_PATH, EM_SETTEXTLIMIT,
|
---|
| 1409 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 1410 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
---|
| 1411 | FillPathListBox(hwnd,
|
---|
| 1412 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
| 1413 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
| 1414 | wa->szCurrentPath1, FALSE);
|
---|
| 1415 | FillPathListBox(hwnd,
|
---|
| 1416 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
---|
| 1417 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
---|
| 1418 | wa->szCurrentPath2, FALSE);
|
---|
| 1419 | if (!PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID))
|
---|
| 1420 | okay = TRUE;
|
---|
| 1421 | {
|
---|
| 1422 | MRESULT ret;
|
---|
[2] | 1423 |
|
---|
[551] | 1424 | ret = WinDefDlgProc(hwnd, WM_INITDLG, mp1, mp2);
|
---|
| 1425 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 1426 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
---|
| 1427 | WinInvalidateRect(WinWindowFromID(hwnd, WALK2_PATH), NULL, TRUE);
|
---|
| 1428 | return ret;
|
---|
| 1429 | }
|
---|
[2] | 1430 |
|
---|
[551] | 1431 | case UM_SETUP4:
|
---|
| 1432 | okay = TRUE;
|
---|
| 1433 | return 0;
|
---|
[2] | 1434 |
|
---|
[551] | 1435 | case WM_PRESPARAMCHANGED:
|
---|
| 1436 | {
|
---|
| 1437 | ULONG AttrFound, AttrValue[64], cbRetLen;
|
---|
[2] | 1438 |
|
---|
[551] | 1439 | cbRetLen = WinQueryPresParam(hwnd, (ULONG) mp1, 0, &AttrFound,
|
---|
| 1440 | (ULONG) sizeof(AttrValue), &AttrValue, 0);
|
---|
| 1441 | if (cbRetLen) {
|
---|
| 1442 | switch (AttrFound) {
|
---|
| 1443 | case PP_FONTNAMESIZE:
|
---|
| 1444 | PrfWriteProfileData(fmprof,
|
---|
| 1445 | appname,
|
---|
| 1446 | "WalkFont", (PVOID) AttrValue, cbRetLen);
|
---|
| 1447 | *WalkFont = 0;
|
---|
| 1448 | WalkFontSize = sizeof(WalkFont);
|
---|
| 1449 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
---|
| 1450 | break;
|
---|
[242] | 1451 | }
|
---|
[551] | 1452 | }
|
---|
| 1453 | }
|
---|
| 1454 | break;
|
---|
[2] | 1455 |
|
---|
[551] | 1456 | case UM_SETUP:
|
---|
| 1457 | {
|
---|
| 1458 | INT x;
|
---|
| 1459 | USHORT id[] = { WALK_PATH, WALK_DIRLIST,
|
---|
| 1460 | WALK2_PATH, WALK2_DIRLIST, 0
|
---|
| 1461 | };
|
---|
[2] | 1462 |
|
---|
[551] | 1463 | if (*WalkFont ||
|
---|
| 1464 | (PrfQueryProfileData(fmprof,
|
---|
| 1465 | appname,
|
---|
| 1466 | "WalkFont",
|
---|
| 1467 | (PVOID) WalkFont,
|
---|
| 1468 | &WalkFontSize) && WalkFontSize)) {
|
---|
| 1469 | for (x = 0; id[x]; x++)
|
---|
| 1470 | WinSetPresParam(WinWindowFromID(hwnd, id[x]),
|
---|
| 1471 | PP_FONTNAMESIZE, WalkFontSize, (PVOID) WalkFont);
|
---|
| 1472 | }
|
---|
| 1473 | }
|
---|
| 1474 | return 0;
|
---|
[2] | 1475 |
|
---|
[551] | 1476 | case UM_CONTROL:
|
---|
| 1477 | case WM_CONTROL:
|
---|
[574] | 1478 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 1479 | if (SHORT1FROMMP(mp1) == WALK_DRIVELIST ||
|
---|
| 1480 | SHORT1FROMMP(mp1) == WALK_DIRLIST ||
|
---|
| 1481 | SHORT1FROMMP(mp1) == WALK2_DRIVELIST ||
|
---|
| 1482 | SHORT1FROMMP(mp1) == WALK2_DIRLIST) {
|
---|
| 1483 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 1484 | SHORT1FROMMP(mp1),
|
---|
| 1485 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
---|
| 1486 | *szBuffer = 0;
|
---|
| 1487 | if (sSelect >= 0)
|
---|
| 1488 | WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
|
---|
| 1489 | MPFROM2SHORT(sSelect, CCHMAXPATH),
|
---|
| 1490 | MPFROMP(szBuffer));
|
---|
| 1491 | }
|
---|
| 1492 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1493 | case WALK_DRIVELIST:
|
---|
| 1494 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1495 |
|
---|
[551] | 1496 | ULONG ulDirLen = CCHMAXPATH;
|
---|
| 1497 | APIRET rc;
|
---|
[2] | 1498 |
|
---|
[551] | 1499 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
---|
| 1500 | if (!rc) {
|
---|
| 1501 | strcpy(wa->szCurrentPath1, "C:\\");
|
---|
| 1502 | *wa->szCurrentPath1 = toupper(*szBuffer);
|
---|
| 1503 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
---|
| 1504 | FillPathListBox(hwnd,
|
---|
| 1505 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
| 1506 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
| 1507 | wa->szCurrentPath1, FALSE);
|
---|
| 1508 | }
|
---|
| 1509 | }
|
---|
| 1510 | break;
|
---|
[2] | 1511 |
|
---|
[551] | 1512 | case WALK_DIRLIST:
|
---|
| 1513 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1514 |
|
---|
[551] | 1515 | ULONG ulSearchCount;
|
---|
[847] | 1516 | FILEFINDBUF3 findbuf;
|
---|
[551] | 1517 | HDIR hDir;
|
---|
| 1518 | APIRET rc;
|
---|
[2] | 1519 |
|
---|
[551] | 1520 | bstrip(szBuffer);
|
---|
| 1521 | if (*szBuffer) {
|
---|
| 1522 | strcpy(szBuff, wa->szCurrentPath1);
|
---|
| 1523 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
---|
| 1524 | strcat(szBuff, "\\");
|
---|
| 1525 | strcat(szBuff, szBuffer);
|
---|
| 1526 | MakeFullName(szBuff);
|
---|
| 1527 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1528 | hDir = HDIR_CREATE;
|
---|
[766] | 1529 | ulSearchCount = 1;
|
---|
[551] | 1530 | if (!IsRoot(szBuff)) {
|
---|
[847] | 1531 | rc = DosFindFirst(szBuff,
|
---|
| 1532 | &hDir,
|
---|
| 1533 | FILE_DIRECTORY |
|
---|
| 1534 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
| 1535 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 1536 | &findbuf,
|
---|
| 1537 | sizeof(FILEFINDBUF3),
|
---|
| 1538 | &ulSearchCount, FIL_STANDARD);
|
---|
[551] | 1539 | if (!rc)
|
---|
| 1540 | DosFindClose(hDir);
|
---|
| 1541 | }
|
---|
| 1542 | else {
|
---|
| 1543 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
| 1544 | rc = 0;
|
---|
| 1545 | }
|
---|
| 1546 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
---|
| 1547 | strcpy(wa->szCurrentPath1, szBuff);
|
---|
| 1548 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
---|
| 1549 | FillPathListBox(hwnd,
|
---|
| 1550 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
| 1551 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
| 1552 | wa->szCurrentPath1, FALSE);
|
---|
| 1553 | }
|
---|
| 1554 | }
|
---|
| 1555 | }
|
---|
| 1556 | break;
|
---|
[2] | 1557 |
|
---|
[551] | 1558 | case WALK2_DRIVELIST:
|
---|
| 1559 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1560 |
|
---|
[551] | 1561 | ULONG ulDirLen = CCHMAXPATH;
|
---|
| 1562 | APIRET rc;
|
---|
[2] | 1563 |
|
---|
[551] | 1564 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
---|
| 1565 | if (!rc) {
|
---|
| 1566 | strcpy(wa->szCurrentPath2, "C:\\");
|
---|
| 1567 | *wa->szCurrentPath2 = toupper(*szBuffer);
|
---|
| 1568 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
---|
| 1569 | FillPathListBox(hwnd,
|
---|
| 1570 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
---|
| 1571 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
---|
| 1572 | wa->szCurrentPath2, FALSE);
|
---|
| 1573 | }
|
---|
| 1574 | }
|
---|
| 1575 | break;
|
---|
[2] | 1576 |
|
---|
[551] | 1577 | case WALK2_DIRLIST:
|
---|
| 1578 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1579 |
|
---|
[551] | 1580 | ULONG ulSearchCount;
|
---|
[847] | 1581 | FILEFINDBUF3 findbuf;
|
---|
[551] | 1582 | HDIR hDir;
|
---|
| 1583 | APIRET rc;
|
---|
[2] | 1584 |
|
---|
[551] | 1585 | bstrip(szBuffer);
|
---|
| 1586 | if (*szBuffer) {
|
---|
| 1587 | strcpy(szBuff, wa->szCurrentPath2);
|
---|
| 1588 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
---|
| 1589 | strcat(szBuff, "\\");
|
---|
| 1590 | strcat(szBuff, szBuffer);
|
---|
| 1591 | MakeFullName(szBuff);
|
---|
| 1592 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1593 | hDir = HDIR_CREATE;
|
---|
[766] | 1594 | ulSearchCount = 1;
|
---|
[551] | 1595 | if (!IsRoot(szBuff)) {
|
---|
[847] | 1596 | rc = DosFindFirst(szBuff,
|
---|
| 1597 | &hDir,
|
---|
| 1598 | FILE_DIRECTORY |
|
---|
| 1599 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
---|
| 1600 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
---|
| 1601 | &findbuf,
|
---|
| 1602 | sizeof(FILEFINDBUF3),
|
---|
| 1603 | &ulSearchCount, FIL_STANDARD);
|
---|
[551] | 1604 | if (!rc)
|
---|
| 1605 | DosFindClose(hDir);
|
---|
| 1606 | }
|
---|
| 1607 | else {
|
---|
| 1608 | findbuf.attrFile = FILE_DIRECTORY;
|
---|
| 1609 | rc = 0;
|
---|
| 1610 | }
|
---|
| 1611 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
---|
| 1612 | strcpy(wa->szCurrentPath2, szBuff);
|
---|
| 1613 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
---|
| 1614 | FillPathListBox(hwnd,
|
---|
| 1615 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
---|
| 1616 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
---|
| 1617 | wa->szCurrentPath2, FALSE);
|
---|
| 1618 | }
|
---|
[242] | 1619 | }
|
---|
[551] | 1620 | }
|
---|
| 1621 | break;
|
---|
| 1622 | }
|
---|
| 1623 | return 0;
|
---|
| 1624 |
|
---|
| 1625 | case WM_COMMAND:
|
---|
[574] | 1626 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 1627 | if (!wa)
|
---|
| 1628 | WinDismissDlg(hwnd, 0);
|
---|
| 1629 | *szBuff = 0;
|
---|
| 1630 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
---|
| 1631 | bstrip(szBuff);
|
---|
| 1632 | while ((p = strchr(szBuff, '/')) != NULL)
|
---|
| 1633 | *p = '\\';
|
---|
| 1634 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
---|
| 1635 | szBuff[strlen(szBuff) - 1] = 0;
|
---|
| 1636 | MakeFullName(szBuff);
|
---|
[864] | 1637 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath1) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
---|
[551] | 1638 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1639 | QW_OWNER), hwnd, szBuff, 0))
|
---|
| 1640 | strcpy(wa->szCurrentPath1, szBuff);
|
---|
[865] | 1641 | else
|
---|
[242] | 1642 | return 0;
|
---|
[551] | 1643 | }
|
---|
| 1644 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
---|
| 1645 | *szBuff = 0;
|
---|
| 1646 | WinQueryDlgItemText(hwnd, WALK2_PATH, CCHMAXPATH, szBuff);
|
---|
| 1647 | bstrip(szBuff);
|
---|
| 1648 | while ((p = strchr(szBuff, '/')) != NULL)
|
---|
| 1649 | *p = '\\';
|
---|
| 1650 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
---|
| 1651 | szBuff[strlen(szBuff) - 1] = 0;
|
---|
| 1652 | MakeFullName(szBuff);
|
---|
[864] | 1653 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath2) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
---|
[551] | 1654 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1655 | QW_OWNER), hwnd, szBuff, 0))
|
---|
| 1656 | strcpy(wa->szCurrentPath2, szBuff);
|
---|
[865] | 1657 | else
|
---|
[551] | 1658 | return 0;
|
---|
| 1659 | }
|
---|
| 1660 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
---|
| 1661 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1662 | case DID_OK:
|
---|
[939] | 1663 | {
|
---|
| 1664 | SWP swp;
|
---|
| 1665 | ULONG size = sizeof(SWP);
|
---|
| 1666 |
|
---|
| 1667 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 1668 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp,
|
---|
[1077] | 1669 | size);
|
---|
[939] | 1670 | }
|
---|
[551] | 1671 | WinDismissDlg(hwnd, 1);
|
---|
| 1672 | break;
|
---|
[2] | 1673 |
|
---|
[551] | 1674 | case IDM_HELP:
|
---|
| 1675 | if (hwndHelp)
|
---|
| 1676 | WinSendMsg(hwndHelp,
|
---|
| 1677 | HM_DISPLAY_HELP,
|
---|
| 1678 | MPFROM2SHORT(HELP_WALKEM2, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 1679 | break;
|
---|
[2] | 1680 |
|
---|
[551] | 1681 | case DID_CANCEL:
|
---|
[939] | 1682 | {
|
---|
| 1683 | SWP swp;
|
---|
| 1684 | ULONG size = sizeof(SWP);
|
---|
| 1685 |
|
---|
| 1686 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 1687 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp,
|
---|
[1077] | 1688 | size);
|
---|
[939] | 1689 | }
|
---|
[551] | 1690 | WinDismissDlg(hwnd, 0);
|
---|
| 1691 | break;
|
---|
| 1692 | }
|
---|
| 1693 | return 0;
|
---|
[2] | 1694 |
|
---|
[551] | 1695 | case WM_CLOSE:
|
---|
| 1696 | break;
|
---|
| 1697 | }
|
---|
| 1698 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1699 | }
|
---|
| 1700 |
|
---|
[242] | 1701 | MRESULT EXPENTRY WalkTwoCmpDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1702 | MPARAM mp2)
|
---|
| 1703 | {
|
---|
[551] | 1704 | switch (msg) {
|
---|
| 1705 | case WM_INITDLG:
|
---|
| 1706 | WinSetWindowText(hwnd, GetPString(IDS_WALKCOMPAREDLGTEXT));
|
---|
| 1707 | return WalkTwoDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1708 | }
|
---|
| 1709 | return WalkTwoDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1710 | }
|
---|
| 1711 |
|
---|
[242] | 1712 | MRESULT EXPENTRY WalkTwoSetDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1713 | MPARAM mp2)
|
---|
| 1714 | {
|
---|
[551] | 1715 | switch (msg) {
|
---|
| 1716 | case WM_INITDLG:
|
---|
| 1717 | WinSetWindowText(hwnd, GetPString(IDS_WALKSETDIRSDLGTEXT));
|
---|
| 1718 | return WalkTwoDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1719 | }
|
---|
| 1720 | return WalkTwoDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1721 | }
|
---|
[794] | 1722 |
|
---|
| 1723 | #pragma alloc_text(WALKER,FillPathListBox,WalkDlgProc,TextSubProc)
|
---|
| 1724 | #pragma alloc_text(WALKER,WalkAllDlgProc,WalkCopyDlgProc)
|
---|
| 1725 | #pragma alloc_text(WALKER,WalkMoveDlgProc,WalkExtractDlgProc,WalkTargetDlgProc)
|
---|
| 1726 | #pragma alloc_text(WALK2,WalkTwoDlgProc,WalkTwoCmpDlgProc,WalkTwoSetDlgProc)
|
---|
| 1727 | #pragma alloc_text(UDIRS,add_udir,remove_udir,remove_ldir,load_udirs)
|
---|
[807] | 1728 | #pragma alloc_text(UDIRS,save_udirs,load_setups,save_setups,add_setups)
|
---|
[794] | 1729 | #pragma alloc_text(UDIRS,remove_setup)
|
---|