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