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