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