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