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