| 1 |  | 
|---|
| 2 | /*********************************************************************** | 
|---|
| 3 |  | 
|---|
| 4 | $Id: seeall.c 907 2008-01-06 07:26:17Z stevenhl $ | 
|---|
| 5 |  | 
|---|
| 6 | See all matching files | 
|---|
| 7 |  | 
|---|
| 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
| 9 | Copyright (c) 2001, 2008 Steven H. Levine | 
|---|
| 10 |  | 
|---|
| 11 | 16 Oct 02 SHL Handle large partitions | 
|---|
| 12 | 25 Nov 03 SHL StartSeeAll: avoid forgetting startpath | 
|---|
| 13 | 06 Dec 03 SHL StartSeeAll: correct malloc arg oops | 
|---|
| 14 | 23 May 05 SHL Use QWL_USER | 
|---|
| 15 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL | 
|---|
| 16 | 05 Jun 05 SHL Use QWL_USER | 
|---|
| 17 | 06 Jun 05 SHL Drop unused code | 
|---|
| 18 | 29 May 06 SHL Comments | 
|---|
| 19 | 17 Jul 06 SHL Use Runtime_Error | 
|---|
| 20 | 19 Oct 06 SHL Correct . and .. detect | 
|---|
| 21 | 03 Nov 06 SHL Renames | 
|---|
| 22 | 03 Nov 06 SHL Count thread usage | 
|---|
| 23 | 30 Mar 07 GKY Remove GetPString for window class names | 
|---|
| 24 | 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speeds file loading) | 
|---|
| 25 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148) | 
|---|
| 26 | 07 Aug 07 SHL Use BldQuotedFullPathName and BldQuotedFileName | 
|---|
| 27 | 13 Aug 07 SHL Sync code with other FilesToGet usage | 
|---|
| 28 | 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat | 
|---|
| 29 | 14 Aug 07 SHL Revert to DosSleep(0) to speed up inner loops | 
|---|
| 30 | 14 Aug 07 SHL Drop afFilesToGet | 
|---|
| 31 | 26 Aug 07 GKY DosSleep(1) in loops changed to (0) | 
|---|
| 32 | 27 Sep 07 SHL Correct ULONGLONG size formatting | 
|---|
| 33 | 30 Dec 07 GKY Use CommaFmtULL | 
|---|
| 34 | 30 Dec 07 GKY Use TestFDates for comparing by date | 
|---|
| 35 |  | 
|---|
| 36 | ***********************************************************************/ | 
|---|
| 37 |  | 
|---|
| 38 | #include <stdlib.h> | 
|---|
| 39 | #include <string.h> | 
|---|
| 40 | #include <ctype.h> | 
|---|
| 41 | #include <process.h> | 
|---|
| 42 |  | 
|---|
| 43 | #define INCL_DOS | 
|---|
| 44 | #define INCL_DOSERRORS | 
|---|
| 45 | #define INCL_WIN | 
|---|
| 46 | #define INCL_GPI | 
|---|
| 47 | #define INCL_LONGLONG | 
|---|
| 48 |  | 
|---|
| 49 | #include "fm3dlg.h" | 
|---|
| 50 | #include "fm3str.h" | 
|---|
| 51 | #include "pathutil.h"                   // BldQuotedFullPathName... | 
|---|
| 52 | #include "makelist.h"                   // AddToList | 
|---|
| 53 | #include "errutil.h"                    // Dos_Error... | 
|---|
| 54 | #include "strutil.h"                    // GetPString | 
|---|
| 55 | #include "fm3dll.h" | 
|---|
| 56 |  | 
|---|
| 57 | #pragma data_seg(DATA2) | 
|---|
| 58 |  | 
|---|
| 59 | static PSZ pszSrcFile = __FILE__; | 
|---|
| 60 |  | 
|---|
| 61 | typedef struct | 
|---|
| 62 | { | 
|---|
| 63 | CHAR *fullname, *filename; | 
|---|
| 64 | USHORT attrFile, flags; | 
|---|
| 65 | FDATE date; | 
|---|
| 66 | FTIME time; | 
|---|
| 67 | ULONGLONG cbFile; | 
|---|
| 68 | ULONG CRC; | 
|---|
| 69 | } | 
|---|
| 70 | ALLFILES; | 
|---|
| 71 |  | 
|---|
| 72 | #define AF_SELECTED     0x0001 | 
|---|
| 73 | #define AF_DELETED      0x0002 | 
|---|
| 74 | #define AF_FILTERED     0x0004 | 
|---|
| 75 | #define AF_DUPE         0x0008 | 
|---|
| 76 | #define AF_CRCED        0x0010 | 
|---|
| 77 |  | 
|---|
| 78 | #define AFM_MARK        0 | 
|---|
| 79 | #define AFM_UNMARK      1 | 
|---|
| 80 | #define AFM_INVERT      2 | 
|---|
| 81 | #define AFM_MARKDELETED 3 | 
|---|
| 82 | #define AFM_FILTER      4 | 
|---|
| 83 |  | 
|---|
| 84 | #define DP_NAMES        0x0001 | 
|---|
| 85 | #define DP_DATES        0x0002 | 
|---|
| 86 | #define DP_SIZES        0x0004 | 
|---|
| 87 | #define DP_CRCS         0x0008 | 
|---|
| 88 | #define DP_EXTS         0x0010 | 
|---|
| 89 |  | 
|---|
| 90 | #define FIXED_FONT_LCID 5 | 
|---|
| 91 |  | 
|---|
| 92 | #define COLORS_MAX                   8 | 
|---|
| 93 |  | 
|---|
| 94 | #define COLORS_CURSOREDNORMALBACK    0 | 
|---|
| 95 | #define COLORS_CURSOREDSELECTEDBACK  1 | 
|---|
| 96 | #define COLORS_NORMALBACK            2 | 
|---|
| 97 | #define COLORS_SELECTEDBACK          3 | 
|---|
| 98 | #define COLORS_SELECTEDNORMALFORE    4 | 
|---|
| 99 | #define COLORS_NORMALFORE            5 | 
|---|
| 100 | #define COLORS_READONLYFORE          6 | 
|---|
| 101 | #define COLORS_SYSTEMFORE            7 | 
|---|
| 102 |  | 
|---|
| 103 | static LONG Colors[COLORS_MAX] = { COLR_WHITE, COLR_DARKGRAY, COLR_PALEGRAY, | 
|---|
| 104 | COLR_BLACK, COLR_WHITE, COLR_BLACK, | 
|---|
| 105 | COLR_DARKBLUE, COLR_DARKRED | 
|---|
| 106 | }; | 
|---|
| 107 |  | 
|---|
| 108 | typedef int (FNSORT) (const void *, const void *); | 
|---|
| 109 | typedef FNSORT *PFNSORT; | 
|---|
| 110 |  | 
|---|
| 111 | typedef struct | 
|---|
| 112 | { | 
|---|
| 113 | USHORT size; | 
|---|
| 114 | USHORT dupeflags; | 
|---|
| 115 | ALLFILES *afhead; | 
|---|
| 116 | ALLFILES **afindex; | 
|---|
| 117 | ULONG affiles; | 
|---|
| 118 | ULONG afalloc; | 
|---|
| 119 | ULONG longest; | 
|---|
| 120 | ULONG longestw; | 
|---|
| 121 | ULONG topfile; | 
|---|
| 122 | ULONG cursored; | 
|---|
| 123 | ULONG selected; | 
|---|
| 124 | ULONGLONG ullSelectedBytes; | 
|---|
| 125 | ULONG afifiles; | 
|---|
| 126 | ULONG lastselected; | 
|---|
| 127 | ULONG lastdirection; | 
|---|
| 128 | ULONG multiplier; | 
|---|
| 129 | ULONG lasttime; | 
|---|
| 130 | CHAR stopflag; | 
|---|
| 131 | CHAR abDrvFlags[26]; | 
|---|
| 132 | CHAR szCommonName[CCHMAXPATH]; | 
|---|
| 133 | CHAR szFindPath[CCHMAXPATH]; | 
|---|
| 134 | LONG lMaxAscender; | 
|---|
| 135 | LONG lMaxDescender; | 
|---|
| 136 | LONG lMaxHeight; | 
|---|
| 137 | LONG maxx; | 
|---|
| 138 | LONG horzscroll; | 
|---|
| 139 | BOOL fullnames; | 
|---|
| 140 | BOOL invertsort; | 
|---|
| 141 | BOOL mousecaptured; | 
|---|
| 142 | HMTX hmtxScan; | 
|---|
| 143 | HWND hvscroll; | 
|---|
| 144 | HWND hhscroll; | 
|---|
| 145 | HWND hwndMenu; | 
|---|
| 146 | HWND hwndObj; | 
|---|
| 147 | HWND hwndClient; | 
|---|
| 148 | HWND hwndPopup; | 
|---|
| 149 | HWND hwndStatus; | 
|---|
| 150 | HWND hwndFrame; | 
|---|
| 151 | HPS hps; | 
|---|
| 152 | PFNSORT pfnCompare; | 
|---|
| 153 | MASK mask; | 
|---|
| 154 | FATTRS fattrs; | 
|---|
| 155 | LONG aulColors[8]; | 
|---|
| 156 | BOOL killme; | 
|---|
| 157 | } | 
|---|
| 158 | ALLDATA; | 
|---|
| 159 |  | 
|---|
| 160 | static BOOL Fullnames = FALSE; | 
|---|
| 161 | static BOOL Firsttime = TRUE; | 
|---|
| 162 | static BOOL SortReverse; | 
|---|
| 163 | static USHORT Codepage, SortType; | 
|---|
| 164 | static FATTRS Fattrs; | 
|---|
| 165 |  | 
|---|
| 166 | extern LONG CRCFile(CHAR * filename, INT * error); | 
|---|
| 167 |  | 
|---|
| 168 | MRESULT EXPENTRY DupeDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 169 | { | 
|---|
| 170 | switch (msg) { | 
|---|
| 171 | case WM_INITDLG: | 
|---|
| 172 | { | 
|---|
| 173 | USHORT flags = SHORT1FROMMP(mp2); | 
|---|
| 174 |  | 
|---|
| 175 | WinCheckButton(hwnd, DUPE_NAMES, ((flags & DP_NAMES) != 0)); | 
|---|
| 176 | WinCheckButton(hwnd, DUPE_DATES, ((flags & DP_NAMES) != 0)); | 
|---|
| 177 | WinCheckButton(hwnd, DUPE_SIZES, ((flags & DP_NAMES) != 0)); | 
|---|
| 178 | WinCheckButton(hwnd, DUPE_CRCS, ((flags & DP_NAMES) != 0)); | 
|---|
| 179 | if (!(flags & DP_NAMES)) | 
|---|
| 180 | WinEnableWindow(WinWindowFromID(hwnd, DUPE_EXTS), FALSE); | 
|---|
| 181 | } | 
|---|
| 182 | break; | 
|---|
| 183 |  | 
|---|
| 184 | case WM_CONTROL: | 
|---|
| 185 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 186 | case DUPE_NAMES: | 
|---|
| 187 | if (WinQueryButtonCheckstate(hwnd, DUPE_NAMES)) | 
|---|
| 188 | WinEnableWindow(WinWindowFromID(hwnd, DUPE_EXTS), TRUE); | 
|---|
| 189 | else { | 
|---|
| 190 | WinCheckButton(hwnd, DUPE_EXTS, FALSE); | 
|---|
| 191 | WinEnableWindow(WinWindowFromID(hwnd, DUPE_EXTS), FALSE); | 
|---|
| 192 | } | 
|---|
| 193 | break; | 
|---|
| 194 | case DUPE_SIZES: | 
|---|
| 195 | if (!WinQueryButtonCheckstate(hwnd, DUPE_SIZES)) | 
|---|
| 196 | WinCheckButton(hwnd, DUPE_CRCS, FALSE); | 
|---|
| 197 | break; | 
|---|
| 198 | case DUPE_CRCS: | 
|---|
| 199 | if (WinQueryButtonCheckstate(hwnd, DUPE_CRCS)) | 
|---|
| 200 | WinCheckButton(hwnd, DUPE_SIZES, TRUE); | 
|---|
| 201 | break; | 
|---|
| 202 | } | 
|---|
| 203 | return 0; | 
|---|
| 204 |  | 
|---|
| 205 | case WM_COMMAND: | 
|---|
| 206 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 207 | case DID_OK: | 
|---|
| 208 | { | 
|---|
| 209 | USHORT flags = 0; | 
|---|
| 210 |  | 
|---|
| 211 | if (WinQueryButtonCheckstate(hwnd, DUPE_NAMES)) { | 
|---|
| 212 | flags |= DP_NAMES; | 
|---|
| 213 | if (WinQueryButtonCheckstate(hwnd, DUPE_EXTS)) | 
|---|
| 214 | flags |= DP_EXTS; | 
|---|
| 215 | } | 
|---|
| 216 | if (WinQueryButtonCheckstate(hwnd, DUPE_DATES)) | 
|---|
| 217 | flags |= DP_DATES; | 
|---|
| 218 | if (WinQueryButtonCheckstate(hwnd, DUPE_SIZES)) { | 
|---|
| 219 | flags |= DP_SIZES; | 
|---|
| 220 | if (WinQueryButtonCheckstate(hwnd, DUPE_CRCS)) | 
|---|
| 221 | flags |= (DP_CRCS | DP_SIZES); | 
|---|
| 222 | } | 
|---|
| 223 | if (!flags) | 
|---|
| 224 | saymsg(MB_ENTER, | 
|---|
| 225 | hwnd, | 
|---|
| 226 | GetPString(IDS_ERRORTEXT), | 
|---|
| 227 | "%s", GetPString(IDS_CHECKONETEXT)); | 
|---|
| 228 | else | 
|---|
| 229 | WinDismissDlg(hwnd, flags); | 
|---|
| 230 | } | 
|---|
| 231 | break; | 
|---|
| 232 |  | 
|---|
| 233 | case DID_CANCEL: | 
|---|
| 234 | WinDismissDlg(hwnd, 0); | 
|---|
| 235 | break; | 
|---|
| 236 |  | 
|---|
| 237 | case IDM_HELP: | 
|---|
| 238 | if (hwndHelp) | 
|---|
| 239 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 240 | MPFROM2SHORT(HELP_DUPES, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 241 | break; | 
|---|
| 242 | } | 
|---|
| 243 | return 0; | 
|---|
| 244 | } | 
|---|
| 245 | return WinDefDlgProc(hwnd, msg, mp1, mp2); | 
|---|
| 246 | } | 
|---|
| 247 |  | 
|---|
| 248 | static ULONG NumLines(RECTL * rcl, ALLDATA * ad) | 
|---|
| 249 | { | 
|---|
| 250 | ULONG numlines; | 
|---|
| 251 |  | 
|---|
| 252 | numlines = (rcl->yTop - rcl->yBottom) / ad->lMaxHeight; | 
|---|
| 253 | if (ad->lMaxDescender && numlines && | 
|---|
| 254 | ((rcl->yTop - rcl->yBottom) - | 
|---|
| 255 | (numlines * ad->lMaxHeight) <= ad->lMaxDescender)) | 
|---|
| 256 | numlines--; | 
|---|
| 257 | return numlines; | 
|---|
| 258 | } | 
|---|
| 259 |  | 
|---|
| 260 | MRESULT EXPENTRY SeeObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 261 | { | 
|---|
| 262 | switch (msg) { | 
|---|
| 263 | case UM_MASSACTION: | 
|---|
| 264 | { | 
|---|
| 265 | CHAR **files = NULL, **list = (CHAR **) mp2, path[CCHMAXPATH]; | 
|---|
| 266 | UINT numfiles = 0, numalloc = 0; | 
|---|
| 267 | INT plen = 0; | 
|---|
| 268 | HWND hwndFrame = WinQueryWindowULong(hwnd, QWL_USER); | 
|---|
| 269 | CHAR message[CCHMAXPATH * 2], wildname[CCHMAXPATH]; | 
|---|
| 270 | register INT x; | 
|---|
| 271 | register CHAR *p, *pp; | 
|---|
| 272 | BOOL dontask = FALSE, wildcarding = FALSE, | 
|---|
| 273 | overold = FALSE, overnew = FALSE; | 
|---|
| 274 |  | 
|---|
| 275 | if (!list || !list[0]) | 
|---|
| 276 | goto Abort; | 
|---|
| 277 | *path = *wildname = 0; | 
|---|
| 278 |  | 
|---|
| 279 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 280 | case IDM_MOVEPRESERVE: | 
|---|
| 281 | { | 
|---|
| 282 | CHAR preserve[CCHMAXPATH], *end; | 
|---|
| 283 |  | 
|---|
| 284 | mp1 = MPFROM2SHORT(IDM_MOVE, SHORT2FROMMP(mp1)); | 
|---|
| 285 | strcpy(preserve, list[0] + 2); | 
|---|
| 286 | end = strrchr(preserve, '\\'); | 
|---|
| 287 | if (end) { | 
|---|
| 288 | end++; | 
|---|
| 289 | for (x = 1; list[x]; x++) { | 
|---|
| 290 | p = preserve; | 
|---|
| 291 | pp = list[x] + 2; | 
|---|
| 292 | while (p < end && toupper(*p) == toupper(*pp)) { | 
|---|
| 293 | p++; | 
|---|
| 294 | pp++; | 
|---|
| 295 | } | 
|---|
| 296 | if (*p == '\\') | 
|---|
| 297 | p++; | 
|---|
| 298 | if (p < end) | 
|---|
| 299 | end = p; | 
|---|
| 300 | } | 
|---|
| 301 | *end = 0; | 
|---|
| 302 | } | 
|---|
| 303 | else | 
|---|
| 304 | *preserve = 0; | 
|---|
| 305 | plen = strlen(preserve); | 
|---|
| 306 | if (plen) | 
|---|
| 307 | plen += 2; | 
|---|
| 308 | } | 
|---|
| 309 | break; | 
|---|
| 310 | case IDM_COPYPRESERVE: | 
|---|
| 311 | { | 
|---|
| 312 | CHAR preserve[CCHMAXPATH], *end; | 
|---|
| 313 |  | 
|---|
| 314 | mp1 = MPFROM2SHORT(IDM_COPY, SHORT2FROMMP(mp1)); | 
|---|
| 315 | strcpy(preserve, list[0] + 2); | 
|---|
| 316 | end = strrchr(preserve, '\\'); | 
|---|
| 317 | if (end) { | 
|---|
| 318 | end++; | 
|---|
| 319 | for (x = 1; list[x]; x++) { | 
|---|
| 320 | p = preserve; | 
|---|
| 321 | pp = list[x] + 2; | 
|---|
| 322 | while (p < end && toupper(*p) == toupper(*pp)) { | 
|---|
| 323 | p++; | 
|---|
| 324 | pp++; | 
|---|
| 325 | } | 
|---|
| 326 | if (*p == '\\') | 
|---|
| 327 | p++; | 
|---|
| 328 | if (p < end) | 
|---|
| 329 | end = p; | 
|---|
| 330 | } | 
|---|
| 331 | *end = 0; | 
|---|
| 332 | } | 
|---|
| 333 | else | 
|---|
| 334 | *preserve = 0; | 
|---|
| 335 | plen = strlen(preserve); | 
|---|
| 336 | if (plen) | 
|---|
| 337 | plen += 2; | 
|---|
| 338 | } | 
|---|
| 339 | break; | 
|---|
| 340 | case IDM_WILDMOVE: | 
|---|
| 341 | wildcarding = TRUE; | 
|---|
| 342 | mp1 = MPFROM2SHORT(IDM_MOVE, SHORT2FROMMP(mp1)); | 
|---|
| 343 | break; | 
|---|
| 344 | case IDM_WILDRENAME: | 
|---|
| 345 | wildcarding = TRUE; | 
|---|
| 346 | mp1 = MPFROM2SHORT(IDM_RENAME, SHORT2FROMMP(mp1)); | 
|---|
| 347 | break; | 
|---|
| 348 | case IDM_WILDCOPY: | 
|---|
| 349 | wildcarding = TRUE; | 
|---|
| 350 | mp1 = MPFROM2SHORT(IDM_COPY, SHORT2FROMMP(mp1)); | 
|---|
| 351 | break; | 
|---|
| 352 | } | 
|---|
| 353 |  | 
|---|
| 354 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 355 | case IDM_OBJECT: | 
|---|
| 356 | case IDM_SHADOW: | 
|---|
| 357 | { | 
|---|
| 358 | APIRET rc; | 
|---|
| 359 |  | 
|---|
| 360 | GetDesktopName(path, sizeof(path)); | 
|---|
| 361 | rc = WinDlgBox(HWND_DESKTOP, | 
|---|
| 362 | hwndFrame, | 
|---|
| 363 | ObjCnrDlgProc, | 
|---|
| 364 | FM3ModHandle, OBJCNR_FRAME, MPFROMP(path)); | 
|---|
| 365 | if (rc) { | 
|---|
| 366 | if (rc > 1) | 
|---|
| 367 | strcpy(path, "<WP_DESKTOP>"); | 
|---|
| 368 | } | 
|---|
| 369 | else { | 
|---|
| 370 | FreeList(list); | 
|---|
| 371 | break; | 
|---|
| 372 | } | 
|---|
| 373 | MakeShadows(hwndFrame, | 
|---|
| 374 | list, (SHORT1FROMMP(mp1) == IDM_SHADOW), path, NULL); | 
|---|
| 375 | } | 
|---|
| 376 | FreeList(list); | 
|---|
| 377 | break; | 
|---|
| 378 |  | 
|---|
| 379 | case IDM_PRINT: | 
|---|
| 380 | { | 
|---|
| 381 | LISTINFO *li; | 
|---|
| 382 |  | 
|---|
| 383 | li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__); | 
|---|
| 384 | if (li) { | 
|---|
| 385 | li->hwndS = WinWindowFromID(hwndFrame, FID_CLIENT); | 
|---|
| 386 | li->type = IDM_PRINT; | 
|---|
| 387 | li->list = list; | 
|---|
| 388 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 389 | li->hwndS, | 
|---|
| 390 | PrintDlgProc, | 
|---|
| 391 | FM3ModHandle, PRN_FRAME, MPFROMP(li))) { | 
|---|
| 392 | if (li && li->list && li->list[0]) { | 
|---|
| 393 | strcpy(li->targetpath, printer); | 
|---|
| 394 | if (_beginthread(PrintListThread, NULL, 65536, (PVOID) li) == | 
|---|
| 395 | -1) { | 
|---|
| 396 | Runtime_Error(pszSrcFile, __LINE__, | 
|---|
| 397 | GetPString(IDS_COULDNTSTARTTHREADTEXT)); | 
|---|
| 398 | FreeListInfo(li); | 
|---|
| 399 | } | 
|---|
| 400 | } | 
|---|
| 401 | } | 
|---|
| 402 | } | 
|---|
| 403 | } | 
|---|
| 404 | break; | 
|---|
| 405 |  | 
|---|
| 406 | case IDM_EAS: | 
|---|
| 407 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 408 | hwndFrame, | 
|---|
| 409 | DisplayEAsProc, FM3ModHandle, EA_FRAME, (PVOID) list)) { | 
|---|
| 410 | if (!PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 411 | UM_UPDATERECORDLIST, MPFROMP(list), MPVOID)) | 
|---|
| 412 | FreeList(list); | 
|---|
| 413 | } | 
|---|
| 414 | else | 
|---|
| 415 | FreeList(list); | 
|---|
| 416 | break; | 
|---|
| 417 |  | 
|---|
| 418 | case IDM_INFO: | 
|---|
| 419 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 420 | hwndFrame, | 
|---|
| 421 | FileInfoProc, | 
|---|
| 422 | FM3ModHandle, FLE_FRAME, (PVOID) list) == 2) { | 
|---|
| 423 | if (!PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 424 | UM_UPDATERECORDLIST, MPFROMP(list), MPVOID)) | 
|---|
| 425 | FreeList(list); | 
|---|
| 426 | } | 
|---|
| 427 | else | 
|---|
| 428 | FreeList(list); | 
|---|
| 429 | break; | 
|---|
| 430 |  | 
|---|
| 431 | case IDM_ARCHIVE: | 
|---|
| 432 | { | 
|---|
| 433 | DIRCNRDATA ad; | 
|---|
| 434 | CHAR szBuffer[1025]; | 
|---|
| 435 |  | 
|---|
| 436 | memset(&ad, 0, sizeof(ad)); | 
|---|
| 437 | ad.namecanchange = 1; | 
|---|
| 438 | ad.info = arcsighead;         // Hide dups | 
|---|
| 439 | if (!WinDlgBox(HWND_DESKTOP, | 
|---|
| 440 | hwndFrame, | 
|---|
| 441 | SBoxDlgProc, | 
|---|
| 442 | FM3ModHandle, | 
|---|
| 443 | ASEL_FRAME, (PVOID) & ad.info) || !ad.info) { | 
|---|
| 444 | // we blew it | 
|---|
| 445 | FreeList(list); | 
|---|
| 446 | break; | 
|---|
| 447 | } | 
|---|
| 448 | if (!ad.info->create && | 
|---|
| 449 | !ad.info->move && | 
|---|
| 450 | !ad.info->createwdirs && | 
|---|
| 451 | !ad.info->movewdirs && !ad.info->createrecurse) { | 
|---|
| 452 | // 14 Aug 07 SHL fixme to tell user why we failed | 
|---|
| 453 | FreeList(list); | 
|---|
| 454 | break; | 
|---|
| 455 | } | 
|---|
| 456 | if (!WinDlgBox(HWND_DESKTOP, hwndFrame, ArchiveDlgProc, FM3ModHandle, ARCH_FRAME, (PVOID) & ad) || !*ad.arcname || !*ad.command) {    /* we blew it */ | 
|---|
| 457 | FreeList(list); | 
|---|
| 458 | break; | 
|---|
| 459 | } | 
|---|
| 460 | // Build archiver command line | 
|---|
| 461 | strcpy(szBuffer, ad.command); | 
|---|
| 462 | strcat(szBuffer, " "); | 
|---|
| 463 | strcat(szBuffer, ad.arcname); | 
|---|
| 464 | p = &szBuffer[strlen(szBuffer)]; | 
|---|
| 465 | if (ad.mask.szMask) { | 
|---|
| 466 | strcat(szBuffer, " "); | 
|---|
| 467 | strcat(szBuffer, ad.mask.szMask); | 
|---|
| 468 | } | 
|---|
| 469 | strcat(szBuffer, " "); | 
|---|
| 470 | x = 0; | 
|---|
| 471 | while (list[x]) { | 
|---|
| 472 | FILESTATUS3 fsa; | 
|---|
| 473 | memset(&fsa, 0, sizeof(fsa)); | 
|---|
| 474 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 475 | DosQueryPathInfo(list[x], FIL_STANDARD, &fsa, sizeof(fsa)); | 
|---|
| 476 | if (fsa.attrFile & FILE_DIRECTORY) { | 
|---|
| 477 | BldQuotedFullPathName(szBuffer + strlen(szBuffer), | 
|---|
| 478 | list[x], "*"); | 
|---|
| 479 | } | 
|---|
| 480 | else | 
|---|
| 481 | BldQuotedFileName(szBuffer + strlen(szBuffer), list[x]); | 
|---|
| 482 | x++; | 
|---|
| 483 | if (!list[x] || strlen(szBuffer) + strlen(list[x]) + 5 > 1024) { | 
|---|
| 484 | runemf2(SEPARATE | WINDOWED | WAIT | | 
|---|
| 485 | (fArcStuffVisible ? 0 : (BACKGROUND | MINIMIZED)), | 
|---|
| 486 | HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 487 | NULL, NULL, "%s", szBuffer); | 
|---|
| 488 | DosSleep(1);              // Let archiver get started | 
|---|
| 489 | *p = 0; | 
|---|
| 490 | } | 
|---|
| 491 | strcat(szBuffer, " "); | 
|---|
| 492 | } // while | 
|---|
| 493 | AddToList(ad.arcname, &files, &numfiles, &numalloc); | 
|---|
| 494 | } | 
|---|
| 495 | if (!PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 496 | UM_UPDATERECORDLIST, MPFROMP(list), MPVOID)) | 
|---|
| 497 | FreeList(list); | 
|---|
| 498 | break; | 
|---|
| 499 |  | 
|---|
| 500 | case IDM_ATTRS: | 
|---|
| 501 | { | 
|---|
| 502 | LISTINFO li; | 
|---|
| 503 |  | 
|---|
| 504 | memset(&li, 0, sizeof(li)); | 
|---|
| 505 | li.list = list; | 
|---|
| 506 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 507 | hwndFrame, | 
|---|
| 508 | AttrListDlgProc, | 
|---|
| 509 | FM3ModHandle, ATR_FRAME, MPFROMP(&li))) { | 
|---|
| 510 | if (li.list && li.list[0]) { | 
|---|
| 511 | if (!PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 512 | UM_UPDATERECORDLIST, MPFROMP(li.list), MPVOID)) | 
|---|
| 513 | FreeList(li.list); | 
|---|
| 514 | } | 
|---|
| 515 | } | 
|---|
| 516 | else | 
|---|
| 517 | FreeList(list); | 
|---|
| 518 | } | 
|---|
| 519 | break; | 
|---|
| 520 |  | 
|---|
| 521 | case IDM_MOVE: | 
|---|
| 522 | case IDM_COPY: | 
|---|
| 523 | if (!*path) | 
|---|
| 524 | strcpy(path, targetdir); | 
|---|
| 525 | if (!*path) | 
|---|
| 526 | strcpy(path, list[0]); | 
|---|
| 527 | MakeValidDir(path); | 
|---|
| 528 | RetryPath: | 
|---|
| 529 | if (SHORT1FROMMP(mp1) == IDM_MOVE) { | 
|---|
| 530 | if (!WinDlgBox(HWND_DESKTOP, | 
|---|
| 531 | hwndFrame, | 
|---|
| 532 | WalkMoveDlgProc, | 
|---|
| 533 | FM3ModHandle, WALK_FRAME, MPFROMP(path)) || !*path) { | 
|---|
| 534 | FreeList(list); | 
|---|
| 535 | goto Abort; | 
|---|
| 536 | } | 
|---|
| 537 | } | 
|---|
| 538 | else { | 
|---|
| 539 | if (!WinDlgBox(HWND_DESKTOP, | 
|---|
| 540 | hwndFrame, | 
|---|
| 541 | WalkCopyDlgProc, | 
|---|
| 542 | FM3ModHandle, WALK_FRAME, MPFROMP(path)) || !*path) { | 
|---|
| 543 | FreeList(list); | 
|---|
| 544 | goto Abort; | 
|---|
| 545 | } | 
|---|
| 546 | } | 
|---|
| 547 | if (driveflags[toupper(*path) - 'A'] & DRIVE_NOTWRITEABLE) { | 
|---|
| 548 | saymsg(MB_CANCEL, | 
|---|
| 549 | hwndFrame, | 
|---|
| 550 | GetPString(IDS_ERRORTEXT), | 
|---|
| 551 | "%s", GetPString(IDS_NOTWRITENOTARGETTEXT)); | 
|---|
| 552 | goto RetryPath; | 
|---|
| 553 | } | 
|---|
| 554 | /* intentional fallthru */ | 
|---|
| 555 | case IDM_RENAME: | 
|---|
| 556 | { | 
|---|
| 557 | CHAR newname[CCHMAXPATH], *moving, *move, *moved; | 
|---|
| 558 | APIRET rc; | 
|---|
| 559 | INT type; | 
|---|
| 560 | FILESTATUS4L fs4; | 
|---|
| 561 | BOOL isnewer, existed; | 
|---|
| 562 |  | 
|---|
| 563 | for (x = 0; list[x]; x++) { | 
|---|
| 564 | Retry: | 
|---|
| 565 | type = (SHORT1FROMMP(mp1) == IDM_RENAME) ? MOVE : | 
|---|
| 566 | (SHORT1FROMMP(mp1) == IDM_MOVE) ? MOVE : | 
|---|
| 567 | (SHORT1FROMMP(mp1) == IDM_WPSMOVE) ? WPSMOVE : | 
|---|
| 568 | (SHORT1FROMMP(mp1) == IDM_WPSCOPY) ? WPSCOPY : COPY; | 
|---|
| 569 | moving = (SHORT1FROMMP(mp1) == IDM_RENAME) ? | 
|---|
| 570 | GetPString(IDS_RENAMINGTEXT) : | 
|---|
| 571 | (SHORT1FROMMP(mp1) == IDM_MOVE || | 
|---|
| 572 | SHORT1FROMMP(mp1) == IDM_WPSMOVE) ? | 
|---|
| 573 | GetPString(IDS_MOVINGTEXT) : GetPString(IDS_COPYINGTEXT); | 
|---|
| 574 | move = (SHORT1FROMMP(mp1) == IDM_RENAME) ? | 
|---|
| 575 | GetPString(IDS_RENAMETEXT) : | 
|---|
| 576 | (SHORT1FROMMP(mp1) == IDM_MOVE || | 
|---|
| 577 | SHORT1FROMMP(mp1) == IDM_WPSMOVE) ? | 
|---|
| 578 | GetPString(IDS_MOVETEXT) : GetPString(IDS_COPYTEXT); | 
|---|
| 579 | moved = (SHORT1FROMMP(mp1) == IDM_RENAME) ? | 
|---|
| 580 | GetPString(IDS_RENAMEDTEXT) : | 
|---|
| 581 | (SHORT1FROMMP(mp1) == IDM_MOVE || | 
|---|
| 582 | SHORT1FROMMP(mp1) == IDM_WPSMOVE) ? | 
|---|
| 583 | GetPString(IDS_MOVEDTEXT) : GetPString(IDS_COPIEDTEXT); | 
|---|
| 584 | if (*path) { | 
|---|
| 585 | strcpy(newname, path); | 
|---|
| 586 | if (newname[strlen(newname) - 1] != '\\') | 
|---|
| 587 | strcat(newname, "\\"); | 
|---|
| 588 | if (plen) | 
|---|
| 589 | p = list[x] + plen; | 
|---|
| 590 | else { | 
|---|
| 591 | p = strrchr(list[x], '\\'); | 
|---|
| 592 | if (p) | 
|---|
| 593 | p++; | 
|---|
| 594 | else | 
|---|
| 595 | p = list[x]; | 
|---|
| 596 | } | 
|---|
| 597 | strcat(newname, p); | 
|---|
| 598 | } | 
|---|
| 599 | else | 
|---|
| 600 | strcpy(newname, list[x]); | 
|---|
| 601 | if ((wildcarding || SHORT1FROMMP(mp1) == IDM_RENAME) && *wildname) { | 
|---|
| 602 |  | 
|---|
| 603 | CHAR testname[CCHMAXPATH]; | 
|---|
| 604 |  | 
|---|
| 605 | strcpy(testname, wildname); | 
|---|
| 606 | if (AdjustWildcardName(newname, testname)) | 
|---|
| 607 | strcpy(newname, testname); | 
|---|
| 608 | } | 
|---|
| 609 | existed = (IsFile(newname) != -1); | 
|---|
| 610 | isnewer = IsNewer(list[x], newname); | 
|---|
| 611 | if (existed && SHORT1FROMMP(mp1) != IDM_RENAME && dontask) { | 
|---|
| 612 | if (!overold && !overnew) | 
|---|
| 613 | break; | 
|---|
| 614 | if (!overold && !isnewer) | 
|---|
| 615 | break; | 
|---|
| 616 | if (!overnew && isnewer) | 
|---|
| 617 | break; | 
|---|
| 618 | } | 
|---|
| 619 | if ((SHORT1FROMMP(mp1) == IDM_RENAME && | 
|---|
| 620 | (!dontask || !*wildname)) || | 
|---|
| 621 | (!dontask && existed) || | 
|---|
| 622 | (!dontask && wildcarding) || | 
|---|
| 623 | (IsFile(newname) == 0 && IsFile(list[x]) == 1)) { | 
|---|
| 624 |  | 
|---|
| 625 | MOVEIT mv; | 
|---|
| 626 |  | 
|---|
| 627 | memset(&mv, 0, sizeof(mv)); | 
|---|
| 628 | mv.rename = (SHORT1FROMMP(mp1) == IDM_RENAME); | 
|---|
| 629 | mv.source = list[x]; | 
|---|
| 630 | strcpy(mv.target, newname); | 
|---|
| 631 | rc = WinDlgBox(HWND_DESKTOP, | 
|---|
| 632 | hwndFrame, | 
|---|
| 633 | RenameProc, | 
|---|
| 634 | FM3ModHandle, REN_FRAME, (PVOID) & mv); | 
|---|
| 635 | if (!rc) { | 
|---|
| 636 | FreeList(list); | 
|---|
| 637 | goto Abort; | 
|---|
| 638 | } | 
|---|
| 639 | DosSleep(0);  //26 Aug 07 GKY 1 | 
|---|
| 640 | if (mv.skip || !*mv.target) | 
|---|
| 641 | break; | 
|---|
| 642 | if (mv.dontask) | 
|---|
| 643 | dontask = TRUE; | 
|---|
| 644 | if (mv.overold) | 
|---|
| 645 | overold = TRUE; | 
|---|
| 646 | if (mv.overnew) | 
|---|
| 647 | overnew = TRUE; | 
|---|
| 648 | if (wildcarding || SHORT1FROMMP(mp1) == IDM_RENAME) { | 
|---|
| 649 | p = strrchr(mv.target, '\\'); | 
|---|
| 650 | if (p && (strchr(p, '*') || strchr(p, '?'))) { | 
|---|
| 651 | strcpy(wildname, mv.target); | 
|---|
| 652 | AdjustWildcardName(list[x], mv.target); | 
|---|
| 653 | } | 
|---|
| 654 | else | 
|---|
| 655 | *wildname = 0; | 
|---|
| 656 | } | 
|---|
| 657 | strcpy(newname, mv.target); | 
|---|
| 658 | existed = (IsFile(newname) != -1); | 
|---|
| 659 | isnewer = IsNewer(list[x], newname); | 
|---|
| 660 | if (!mv.overwrite) { | 
|---|
| 661 | if (existed && SHORT1FROMMP(mp1) != IDM_RENAME && dontask) { | 
|---|
| 662 | if (!overold && !overnew) | 
|---|
| 663 | break; | 
|---|
| 664 | if (!overold && !isnewer) | 
|---|
| 665 | break; | 
|---|
| 666 | if (!overnew && isnewer) | 
|---|
| 667 | break; | 
|---|
| 668 | } | 
|---|
| 669 | } | 
|---|
| 670 | } | 
|---|
| 671 | if (!stricmp(list[x], newname)) | 
|---|
| 672 | break; | 
|---|
| 673 | sprintf(message, | 
|---|
| 674 | " %s \"%s\" %s \"%s\"", | 
|---|
| 675 | moving, list[x], GetPString(IDS_TOTEXT), newname); | 
|---|
| 676 | WinSetWindowText(WinWindowFromID(hwndFrame, SEEALL_STATUS), | 
|---|
| 677 | message); | 
|---|
| 678 | if (fRealIdle) | 
|---|
| 679 | priority_idle(); | 
|---|
| 680 | if (plen) { | 
|---|
| 681 | /* make directory/ies, if required */ | 
|---|
| 682 |  | 
|---|
| 683 | CHAR dirpart[CCHMAXPATH]; | 
|---|
| 684 |  | 
|---|
| 685 | strcpy(dirpart, newname); | 
|---|
| 686 | p = strrchr(dirpart, '\\'); | 
|---|
| 687 | if (p) { | 
|---|
| 688 | *p = 0; | 
|---|
| 689 | if (p > dirpart + 3) | 
|---|
| 690 | MassMkdir((hwndMain) ? hwndMain : (HWND) 0, dirpart); | 
|---|
| 691 | } | 
|---|
| 692 | } | 
|---|
| 693 | rc = docopyf(type, list[x], "%s", newname); | 
|---|
| 694 | priority_normal(); | 
|---|
| 695 | if (rc) { | 
|---|
| 696 | if ((rc == ERROR_DISK_FULL || | 
|---|
| 697 | rc == ERROR_HANDLE_DISK_FULL) && | 
|---|
| 698 | isalpha(*newname) && | 
|---|
| 699 | (driveflags[toupper(*newname) - 'A'] & DRIVE_REMOVABLE) && | 
|---|
| 700 | !(driveflags[toupper(*newname) - 'A'] & DRIVE_NOTWRITEABLE) | 
|---|
| 701 | && toupper(*newname) != toupper(*list[x]) | 
|---|
| 702 | && !DosQueryPathInfo(list[x], FIL_QUERYEASIZEL, &fs4, | 
|---|
| 703 | sizeof(fs4)) | 
|---|
| 704 | && !(fs4.attrFile & FILE_DIRECTORY)) { | 
|---|
| 705 |  | 
|---|
| 706 | FSALLOCATE fsa; | 
|---|
| 707 | ULONG clFreeBytes; | 
|---|
| 708 | CHAR *ptr; | 
|---|
| 709 | INT cntr; | 
|---|
| 710 |  | 
|---|
| 711 | WinSetWindowText(WinWindowFromID(hwndFrame, SEEALL_STATUS), | 
|---|
| 712 | GetPString(IDS_FITTINGTEXT)); | 
|---|
| 713 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 714 | if (!DosQueryFSInfo(toupper(*newname) - '@', | 
|---|
| 715 | FSIL_ALLOC, &fsa, sizeof(fsa))) { | 
|---|
| 716 | // Assume <2GB since file did not fit | 
|---|
| 717 | clFreeBytes = fsa.cUnitAvail * fsa.cSectorUnit * | 
|---|
| 718 | fsa.cbSector; | 
|---|
| 719 | if (clFreeBytes) { | 
|---|
| 720 | // Find item that will fit in available space | 
|---|
| 721 | for (cntr = x + 1; list[cntr]; cntr++) { | 
|---|
| 722 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 723 | if (!DosQueryPathInfo(list[cntr], | 
|---|
| 724 | FIL_QUERYEASIZEL, | 
|---|
| 725 | &fs4, sizeof(fs4)) && | 
|---|
| 726 | !(fs4.attrFile & FILE_DIRECTORY) && | 
|---|
| 727 | // fixme to use CBLIST_TO_EASIZE? | 
|---|
| 728 | fs4.cbFile + fs4.cbList <= clFreeBytes) { | 
|---|
| 729 | // Swap with failing item | 
|---|
| 730 | ptr = list[x]; | 
|---|
| 731 | list[x] = list[cntr]; | 
|---|
| 732 | list[cntr] = ptr; | 
|---|
| 733 | goto Retry; | 
|---|
| 734 | } | 
|---|
| 735 | } | 
|---|
| 736 | WinSetWindowText(WinWindowFromID(hwndFrame, | 
|---|
| 737 | SEEALL_STATUS), | 
|---|
| 738 | GetPString(IDS_COULDNTFITTEXT)); | 
|---|
| 739 | } | 
|---|
| 740 | } | 
|---|
| 741 | rc = saymsg(MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION, | 
|---|
| 742 | hwndFrame, | 
|---|
| 743 | GetPString(IDS_DISKFULLTEXT), | 
|---|
| 744 | "%s", GetPString(IDS_ANOTHERDISKTEXT)); | 
|---|
| 745 | if (rc == MBID_RETRY) | 
|---|
| 746 | goto Retry; | 
|---|
| 747 | if (rc == MBID_ABORT) { | 
|---|
| 748 | FreeList(list); | 
|---|
| 749 | goto Abort; | 
|---|
| 750 | } | 
|---|
| 751 | } | 
|---|
| 752 | else { | 
|---|
| 753 | if (LogFileHandle) | 
|---|
| 754 | fprintf(LogFileHandle, | 
|---|
| 755 | GetPString(IDS_LOGTOFAILEDTEXT), | 
|---|
| 756 | move, list[x], newname, rc); | 
|---|
| 757 | rc = Dos_Error(MB_ENTERCANCEL, | 
|---|
| 758 | rc, | 
|---|
| 759 | hwndFrame, | 
|---|
| 760 | pszSrcFile, | 
|---|
| 761 | __LINE__, | 
|---|
| 762 | "%s %s \"%s\" %s\"%s\" %s.", | 
|---|
| 763 | move, | 
|---|
| 764 | GetPString(IDS_OFTEXT), | 
|---|
| 765 | list[x], | 
|---|
| 766 | GetPString(IDS_TOTEXT), | 
|---|
| 767 | newname, GetPString(IDS_FAILEDTEXT)); | 
|---|
| 768 | if (rc == MBID_CANCEL) { | 
|---|
| 769 | FreeList(list); | 
|---|
| 770 | goto Abort; | 
|---|
| 771 | } | 
|---|
| 772 | } | 
|---|
| 773 | } | 
|---|
| 774 | else { | 
|---|
| 775 | if (LogFileHandle) | 
|---|
| 776 | fprintf(LogFileHandle, | 
|---|
| 777 | "%s \"%s\" %s \"%s\"\n", | 
|---|
| 778 | moved, list[x], GetPString(IDS_TOTEXT), newname); | 
|---|
| 779 | AddToList(newname, &files, &numfiles, &numalloc); | 
|---|
| 780 | } | 
|---|
| 781 | } | 
|---|
| 782 | } | 
|---|
| 783 | if (SHORT1FROMMP(mp1) != IDM_COPY) { | 
|---|
| 784 | if (!PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 785 | UM_UPDATERECORDLIST, MPFROMP(list), MPVOID)) | 
|---|
| 786 | FreeList(list); | 
|---|
| 787 | } | 
|---|
| 788 | else | 
|---|
| 789 | FreeList(list); | 
|---|
| 790 | break; | 
|---|
| 791 |  | 
|---|
| 792 | case IDM_UUDECODE: | 
|---|
| 793 | for (x = 0; list[x]; x++) | 
|---|
| 794 | UUD(list[x], NULL); | 
|---|
| 795 | break; | 
|---|
| 796 |  | 
|---|
| 797 | case IDM_EXTRACT: | 
|---|
| 798 | for (x = 0; list[x]; x++) { | 
|---|
| 799 |  | 
|---|
| 800 | EXTRDATA ex; | 
|---|
| 801 | BOOL maskspaces = FALSE; | 
|---|
| 802 |  | 
|---|
| 803 | memset(&ex, 0, sizeof(ex)); | 
|---|
| 804 | ex.info = find_type(list[x], NULL); | 
|---|
| 805 | if (!ex.info || (!ex.info->extract && !ex.info->exwdirs)) | 
|---|
| 806 | break; | 
|---|
| 807 | ex.size = sizeof(ex); | 
|---|
| 808 | ex.arcname = list[x]; | 
|---|
| 809 | strcpy(ex.masks, "*"); | 
|---|
| 810 | if (!WinDlgBox(HWND_DESKTOP, | 
|---|
| 811 | hwndFrame, | 
|---|
| 812 | ExtractDlgProc, | 
|---|
| 813 | FM3ModHandle, | 
|---|
| 814 | EXT_FRAME, | 
|---|
| 815 | (PVOID) & ex) || | 
|---|
| 816 | !ex.ret || !*ex.command || !*ex.arcname || !*ex.extractdir) | 
|---|
| 817 | break; | 
|---|
| 818 | if (IsFile(ex.extractdir) != 0) | 
|---|
| 819 | Runtime_Error(pszSrcFile, __LINE__, "directory expected"); | 
|---|
| 820 | else { | 
|---|
| 821 | if (needs_quoting(ex.masks) && !strchr(ex.masks, '\"')) | 
|---|
| 822 | maskspaces = TRUE; | 
|---|
| 823 | runemf2(SEPARATE | WINDOWED | | 
|---|
| 824 | (fArcStuffVisible ? 0 : (BACKGROUND | MINIMIZED)), | 
|---|
| 825 | HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 826 | ex.extractdir, NULL, | 
|---|
| 827 | "%s %s %s%s%s", | 
|---|
| 828 | ex.command, | 
|---|
| 829 | ex.arcname, | 
|---|
| 830 | maskspaces ? "\"" : NullStr, | 
|---|
| 831 | *ex.masks ? ex.masks : "*", | 
|---|
| 832 | maskspaces ? "\"" : NullStr); | 
|---|
| 833 | } | 
|---|
| 834 | } | 
|---|
| 835 | // fixme to not leak? | 
|---|
| 836 | if (!PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 837 | UM_UPDATERECORDLIST, MPFROMP(list), MPVOID)) | 
|---|
| 838 | FreeList(list); | 
|---|
| 839 | break; | 
|---|
| 840 |  | 
|---|
| 841 | case IDM_SUBJECT: | 
|---|
| 842 | for (x = 0; list[x]; x++) { | 
|---|
| 843 |  | 
|---|
| 844 | INT ret; | 
|---|
| 845 |  | 
|---|
| 846 | if (IsFile(list[x]) == 1) { | 
|---|
| 847 | ret = Subject(hwndFrame, list[x]); | 
|---|
| 848 | if (!ret) | 
|---|
| 849 | break; | 
|---|
| 850 | } | 
|---|
| 851 | } | 
|---|
| 852 | if (!PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 853 | UM_UPDATERECORDLIST, MPFROMP(list), MPVOID)) | 
|---|
| 854 | FreeList(list); | 
|---|
| 855 | break; | 
|---|
| 856 |  | 
|---|
| 857 | case IDM_OPENDEFAULT: | 
|---|
| 858 | case IDM_OPENSETTINGS: | 
|---|
| 859 | for (x = 0; list[x]; x++) { | 
|---|
| 860 | if (IsFile(list[x]) != -1) { | 
|---|
| 861 |  | 
|---|
| 862 | CHAR *s; | 
|---|
| 863 |  | 
|---|
| 864 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 865 | case IDM_OPENSETTINGS: | 
|---|
| 866 | s = Settings; | 
|---|
| 867 | break; | 
|---|
| 868 | default: | 
|---|
| 869 | s = Default; | 
|---|
| 870 | break; | 
|---|
| 871 | } | 
|---|
| 872 | OpenObject(list[x], s, hwndFrame); | 
|---|
| 873 | } | 
|---|
| 874 | } | 
|---|
| 875 | FreeList(list); | 
|---|
| 876 | break; | 
|---|
| 877 |  | 
|---|
| 878 | case IDM_DELETE: | 
|---|
| 879 | case IDM_PERMDELETE: | 
|---|
| 880 | { | 
|---|
| 881 | CHECKLIST cl; | 
|---|
| 882 | INT isdir = 0, sysdir = 0, ro = 0, hs = 0; | 
|---|
| 883 | FILESTATUS3 fsa; | 
|---|
| 884 | CHAR prompt[CCHMAXPATH * 3]; | 
|---|
| 885 | APIRET error; | 
|---|
| 886 |  | 
|---|
| 887 | for (x = 0; list[x]; x++) { | 
|---|
| 888 | if (IsRoot(list[x])) { | 
|---|
| 889 | list = RemoveFromList(list, list[x]); | 
|---|
| 890 | if (!list) | 
|---|
| 891 | break; | 
|---|
| 892 | x--; | 
|---|
| 893 | continue; | 
|---|
| 894 | } | 
|---|
| 895 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 896 | if (DosQueryPathInfo(list[x], FIL_STANDARD, &fsa, sizeof(fsa))) { | 
|---|
| 897 | list = RemoveFromList(list, list[x]); | 
|---|
| 898 | if (!list) | 
|---|
| 899 | break; | 
|---|
| 900 | x--; | 
|---|
| 901 | continue; | 
|---|
| 902 | } | 
|---|
| 903 | if (fsa.attrFile & FILE_DIRECTORY) { | 
|---|
| 904 | isdir++; | 
|---|
| 905 | if (stristr(list[x], ":\\OS2\\") || | 
|---|
| 906 | !stricmp(list[x] + 1, ":\\OS2")) | 
|---|
| 907 | sysdir++; | 
|---|
| 908 | } | 
|---|
| 909 | else { | 
|---|
| 910 | if (fsa.attrFile & (FILE_HIDDEN | FILE_SYSTEM)) | 
|---|
| 911 | hs++; | 
|---|
| 912 | if (fsa.attrFile & FILE_READONLY) | 
|---|
| 913 | ro++; | 
|---|
| 914 | } | 
|---|
| 915 | } | 
|---|
| 916 | if (!list) | 
|---|
| 917 | break; | 
|---|
| 918 | if (fConfirmDelete || isdir) { | 
|---|
| 919 | memset(&cl, 0, sizeof(cl)); | 
|---|
| 920 | cl.size = sizeof(cl); | 
|---|
| 921 | cl.list = list; | 
|---|
| 922 | cl.prompt = prompt; | 
|---|
| 923 | cl.flags |= CHECK_FILES; | 
|---|
| 924 | cl.cmd = SHORT1FROMMP(mp1); | 
|---|
| 925 | sprintf(prompt, | 
|---|
| 926 | GetPString(IDS_DELPROMPT1TEXT), | 
|---|
| 927 | (SHORT1FROMMP(mp1) == IDM_DELETE) ? | 
|---|
| 928 | NullStr : | 
|---|
| 929 | GetPString(IDS_PERMANENTLYTEXT), &"s"[list[1] == NULL]); | 
|---|
| 930 | if (isdir) { | 
|---|
| 931 | sprintf(&prompt[strlen(prompt)], | 
|---|
| 932 | GetPString(IDS_DELPROMPT2TEXT), | 
|---|
| 933 | isdir, | 
|---|
| 934 | (isdir > 1) ? | 
|---|
| 935 | GetPString(IDS_ARETEXT) : | 
|---|
| 936 | GetPString(IDS_ISTEXT), | 
|---|
| 937 | (isdir == 1) ? | 
|---|
| 938 | GetPString(IDS_ATEXT) : | 
|---|
| 939 | NullStr, | 
|---|
| 940 | (isdir > 1) ? | 
|---|
| 941 | GetPString(IDS_IESTEXT) : GetPString(IDS_YTEXT)); | 
|---|
| 942 | if (sysdir) | 
|---|
| 943 | sprintf(&prompt[strlen(prompt)], | 
|---|
| 944 | GetPString(IDS_DELPROMPT3TEXT), | 
|---|
| 945 | sysdir, | 
|---|
| 946 | (sysdir == 1) ? | 
|---|
| 947 | GetPString(IDS_YTEXT) : GetPString(IDS_IESTEXT)); | 
|---|
| 948 | } | 
|---|
| 949 | if (ro) | 
|---|
| 950 | sprintf(&prompt[strlen(prompt)], | 
|---|
| 951 | GetPString(IDS_DELPROMPT4TEXT), | 
|---|
| 952 | ro, | 
|---|
| 953 | &"s"[ro == 1], | 
|---|
| 954 | (ro > 1) ? | 
|---|
| 955 | GetPString(IDS_ARETEXT) : GetPString(IDS_ISTEXT)); | 
|---|
| 956 | if (hs) | 
|---|
| 957 | sprintf(&prompt[strlen(prompt)], | 
|---|
| 958 | GetPString(IDS_DELPROMPT5TEXT), | 
|---|
| 959 | hs, | 
|---|
| 960 | &"s"[hs == 1], | 
|---|
| 961 | (hs > 1) ? | 
|---|
| 962 | GetPString(IDS_ARETEXT) : GetPString(IDS_ISTEXT)); | 
|---|
| 963 | if (ro || hs || sysdir) | 
|---|
| 964 | DosBeep(300, 100); | 
|---|
| 965 | strcat(prompt, GetPString(IDS_DELPROMPT6TEXT)); | 
|---|
| 966 | if (!WinDlgBox(HWND_DESKTOP, | 
|---|
| 967 | WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 968 | CheckListProc, | 
|---|
| 969 | FM3ModHandle, CHECK_FRAME, MPFROMP(&cl))) | 
|---|
| 970 | break; | 
|---|
| 971 | list = cl.list; | 
|---|
| 972 | if (!list || !list[0]) | 
|---|
| 973 | break; | 
|---|
| 974 | } | 
|---|
| 975 | for (x = 0; list[x]; x++) { | 
|---|
| 976 | fsa.attrFile = 0; | 
|---|
| 977 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 978 | DosQueryPathInfo(list[x], FIL_STANDARD, &fsa, sizeof(fsa)); | 
|---|
| 979 | if (fsa.attrFile & FILE_DIRECTORY) { | 
|---|
| 980 | sprintf(prompt, GetPString(IDS_DELETINGTEXT), list[x]); | 
|---|
| 981 | WinSetWindowText(WinWindowFromID(hwndFrame, SEEALL_STATUS), | 
|---|
| 982 | prompt); | 
|---|
| 983 | error = (APIRET) wipeallf("%s%s*", | 
|---|
| 984 | list[x], | 
|---|
| 985 | (*list[x] && | 
|---|
| 986 | list[x][strlen(list[x]) - 1] != | 
|---|
| 987 | '\\') ? "\\" : NullStr); | 
|---|
| 988 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 989 | if (!error) | 
|---|
| 990 | error = DosDeleteDir(list[x]); | 
|---|
| 991 | else | 
|---|
| 992 | DosDeleteDir(list[x]); | 
|---|
| 993 | } | 
|---|
| 994 | else { | 
|---|
| 995 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 996 | if (SHORT1FROMMP(mp1) == IDM_DELETE) | 
|---|
| 997 | error = DosDelete(list[x]); | 
|---|
| 998 | else | 
|---|
| 999 | error = DosForceDelete(list[x]); | 
|---|
| 1000 | if (error) { | 
|---|
| 1001 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 1002 | make_deleteable(list[x]); | 
|---|
| 1003 | if (SHORT1FROMMP(mp1) == IDM_DELETE) | 
|---|
| 1004 | error = DosDelete(list[x]); | 
|---|
| 1005 | else | 
|---|
| 1006 | error = DosForceDelete(list[x]); | 
|---|
| 1007 | } | 
|---|
| 1008 | } | 
|---|
| 1009 | if (error) { | 
|---|
| 1010 | if (LogFileHandle) | 
|---|
| 1011 | fprintf(LogFileHandle, | 
|---|
| 1012 | GetPString(IDS_DELETEFAILED1TEXT), list[x], error); | 
|---|
| 1013 | if (Dos_Error(MB_ENTERCANCEL, | 
|---|
| 1014 | error, | 
|---|
| 1015 | hwndFrame, | 
|---|
| 1016 | pszSrcFile, | 
|---|
| 1017 | __LINE__, | 
|---|
| 1018 | GetPString(IDS_DELETEFAILED2TEXT), | 
|---|
| 1019 | list[x]) == MBID_CANCEL) | 
|---|
| 1020 | break; | 
|---|
| 1021 | } | 
|---|
| 1022 | else if (LogFileHandle) | 
|---|
| 1023 | fprintf(LogFileHandle, | 
|---|
| 1024 | "%s\n", GetPString(IDS_DELETEDTEXT), list[x]); | 
|---|
| 1025 | AddToList(list[x], &files, &numfiles, &numalloc); | 
|---|
| 1026 | } | 
|---|
| 1027 | } | 
|---|
| 1028 | FreeList(list); | 
|---|
| 1029 | break; | 
|---|
| 1030 |  | 
|---|
| 1031 | case IDM_SAVETOLIST: | 
|---|
| 1032 | if (list) { | 
|---|
| 1033 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 1034 | WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 1035 | SaveAllListDlgProc, | 
|---|
| 1036 | FM3ModHandle, SAV_FRAME, MPFROMP(list)); | 
|---|
| 1037 | FreeList(list); | 
|---|
| 1038 | } | 
|---|
| 1039 | break; | 
|---|
| 1040 |  | 
|---|
| 1041 | case IDM_SAVETOCLIP: | 
|---|
| 1042 | case IDM_APPENDTOCLIP: | 
|---|
| 1043 | if (list) { | 
|---|
| 1044 | ListToClipboardHab(WinQueryAnchorBlock(hwnd), | 
|---|
| 1045 | list, (SHORT1FROMMP(mp1) == IDM_APPENDTOCLIP)); | 
|---|
| 1046 | FreeList(list); | 
|---|
| 1047 | } | 
|---|
| 1048 | break; | 
|---|
| 1049 |  | 
|---|
| 1050 | default: | 
|---|
| 1051 | if (list) | 
|---|
| 1052 | FreeList(list); | 
|---|
| 1053 | break; | 
|---|
| 1054 | } | 
|---|
| 1055 |  | 
|---|
| 1056 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 1057 | case IDM_MOVE: | 
|---|
| 1058 | case IDM_COPY: | 
|---|
| 1059 | case IDM_RENAME: | 
|---|
| 1060 | sprintf(message, | 
|---|
| 1061 | GetPString(IDS_OPSCOMPLETETEXT), | 
|---|
| 1062 | SHORT1FROMMP(mp1) == IDM_MOVE ? | 
|---|
| 1063 | GetPString(IDS_MOVETEXT) : | 
|---|
| 1064 | SHORT1FROMMP(mp1) == IDM_COPY ? | 
|---|
| 1065 | GetPString(IDS_COPYTEXT) : | 
|---|
| 1066 | SHORT1FROMMP(mp1) == IDM_WPSMOVE ? | 
|---|
| 1067 | GetPString(IDS_WPSMOVETEXT) : | 
|---|
| 1068 | SHORT1FROMMP(mp1) == IDM_WPSCOPY ? | 
|---|
| 1069 | GetPString(IDS_WPSCOPYTEXT) : | 
|---|
| 1070 | GetPString(IDS_RENAMETEXT), | 
|---|
| 1071 | &"s"[x == 1], | 
|---|
| 1072 | SHORT1FROMMP(mp1) == IDM_MOVE || | 
|---|
| 1073 | SHORT1FROMMP(mp1) == IDM_COPY || | 
|---|
| 1074 | SHORT1FROMMP(mp1) == IDM_WPSMOVE || | 
|---|
| 1075 | SHORT1FROMMP(mp1) == IDM_WPSCOPY ? | 
|---|
| 1076 | GetPString(IDS_TOTEXT) : NullStr, | 
|---|
| 1077 | SHORT1FROMMP(mp1) == IDM_MOVE || | 
|---|
| 1078 | SHORT1FROMMP(mp1) == IDM_COPY || | 
|---|
| 1079 | SHORT1FROMMP(mp1) == IDM_WPSMOVE || | 
|---|
| 1080 | SHORT1FROMMP(mp1) == IDM_WPSCOPY ? | 
|---|
| 1081 | path : NullStr, | 
|---|
| 1082 | x != 1 ? GetPString(IDS_ARETEXT) : GetPString(IDS_ISTEXT)); | 
|---|
| 1083 | WinSetWindowText(WinWindowFromID(hwndFrame, SEEALL_STATUS), message); | 
|---|
| 1084 | if (toupper(*path) < 'C') | 
|---|
| 1085 | DosBeep(1000, 25); | 
|---|
| 1086 | DosSleep(16);                   // 05 Aug 07 GKY 33 | 
|---|
| 1087 | break; | 
|---|
| 1088 |  | 
|---|
| 1089 | default: | 
|---|
| 1090 | break; | 
|---|
| 1091 | } | 
|---|
| 1092 | Abort: | 
|---|
| 1093 | if (files) { | 
|---|
| 1094 | if (!PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 1095 | UM_UPDATERECORDLIST, MPFROMP(files), MPVOID)) | 
|---|
| 1096 | FreeList(files); | 
|---|
| 1097 | } | 
|---|
| 1098 | PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 1099 | UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 1100 | } | 
|---|
| 1101 | return 0; | 
|---|
| 1102 |  | 
|---|
| 1103 | case WM_CLOSE: | 
|---|
| 1104 | WinDestroyWindow(hwnd); | 
|---|
| 1105 | break; | 
|---|
| 1106 |  | 
|---|
| 1107 | case WM_DESTROY: | 
|---|
| 1108 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID)) | 
|---|
| 1109 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); | 
|---|
| 1110 | break; | 
|---|
| 1111 | } | 
|---|
| 1112 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 1113 | } | 
|---|
| 1114 |  | 
|---|
| 1115 | static VOID MakeSeeObjWinThread(VOID * args) | 
|---|
| 1116 | { | 
|---|
| 1117 | HAB hab2; | 
|---|
| 1118 | HMQ hmq2; | 
|---|
| 1119 | HWND hwndObj; | 
|---|
| 1120 | ALLDATA *ad = (ALLDATA *) args; | 
|---|
| 1121 | QMSG qmsg2; | 
|---|
| 1122 |  | 
|---|
| 1123 | if (ad) { | 
|---|
| 1124 | hab2 = WinInitialize(0); | 
|---|
| 1125 | if (hab2) { | 
|---|
| 1126 | hmq2 = WinCreateMsgQueue(hab2, 256); | 
|---|
| 1127 | if (hmq2) { | 
|---|
| 1128 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 1129 | WinRegisterClass(hab2, | 
|---|
| 1130 | WC_OBJECTWINDOW, | 
|---|
| 1131 | SeeObjWndProc, 0, sizeof(PVOID)); | 
|---|
| 1132 | hwndObj = WinCreateWindow(HWND_OBJECT, | 
|---|
| 1133 | WC_OBJECTWINDOW, | 
|---|
| 1134 | (PSZ) NULL, | 
|---|
| 1135 | 0, | 
|---|
| 1136 | 0, | 
|---|
| 1137 | 0, | 
|---|
| 1138 | 0, | 
|---|
| 1139 | 0, 0, HWND_TOP, SEEALL_OBJ, NULL, NULL); | 
|---|
| 1140 | if (!hwndObj) { | 
|---|
| 1141 | Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1142 | IDS_WINCREATEWINDOW); | 
|---|
| 1143 | if (!PostMsg(ad->hwndClient, WM_CLOSE, MPVOID, MPVOID)) | 
|---|
| 1144 | WinSendMsg(ad->hwndClient, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 1145 | } | 
|---|
| 1146 | else { | 
|---|
| 1147 | ad->hwndObj = hwndObj; | 
|---|
| 1148 | WinSetWindowULong(hwndObj, QWL_USER, ad->hwndFrame); | 
|---|
| 1149 | priority_normal(); | 
|---|
| 1150 | while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0)) | 
|---|
| 1151 | WinDispatchMsg(hab2, &qmsg2); | 
|---|
| 1152 | WinDestroyWindow(hwndObj); | 
|---|
| 1153 | } | 
|---|
| 1154 | WinDestroyMsgQueue(hmq2); | 
|---|
| 1155 | } | 
|---|
| 1156 | else | 
|---|
| 1157 | WinTerminate(hab2); | 
|---|
| 1158 | } | 
|---|
| 1159 | } | 
|---|
| 1160 | } | 
|---|
| 1161 |  | 
|---|
| 1162 | static VOID SelectMask(HWND hwnd, BOOL deselect) | 
|---|
| 1163 | { | 
|---|
| 1164 | MASK mask; | 
|---|
| 1165 | register ULONG x, y, z; | 
|---|
| 1166 | BOOL ret; | 
|---|
| 1167 | ALLDATA *pAD = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1168 |  | 
|---|
| 1169 | memset(&mask, 0, sizeof(mask)); | 
|---|
| 1170 | mask.fNoAttribs = FALSE; | 
|---|
| 1171 | mask.fNoDirs = TRUE; | 
|---|
| 1172 | mask.attrFile = pAD->mask.attrFile; | 
|---|
| 1173 | mask.antiattr = pAD->mask.antiattr; | 
|---|
| 1174 | mask.fIsSeeAll = TRUE; | 
|---|
| 1175 | strcpy(mask.prompt, | 
|---|
| 1176 | GetPString((!deselect) ? | 
|---|
| 1177 | IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT)); | 
|---|
| 1178 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 1179 | hwnd, | 
|---|
| 1180 | PickMaskDlgProc, | 
|---|
| 1181 | FM3ModHandle, | 
|---|
| 1182 | MSK_FRAME, | 
|---|
| 1183 | MPFROMP(&mask)) && | 
|---|
| 1184 | (*mask.szMask || | 
|---|
| 1185 | mask.attrFile != pAD->mask.attrFile || | 
|---|
| 1186 | mask.antiattr != pAD->mask.antiattr)) { | 
|---|
| 1187 | for (x = 0; x < pAD->afifiles; x++) { | 
|---|
| 1188 | y = (pAD->invertsort) ? (pAD->afifiles - 1) - x : x; | 
|---|
| 1189 | ret = FALSE; | 
|---|
| 1190 | if (mask.pszMasks[1]) { | 
|---|
| 1191 | for (z = 0; mask.pszMasks[z]; z++) { | 
|---|
| 1192 | if (*mask.pszMasks[z]) { | 
|---|
| 1193 | if (*mask.pszMasks[z] != '/') { | 
|---|
| 1194 | if (wildcard((strchr(mask.pszMasks[z], '\\') || | 
|---|
| 1195 | strchr(mask.pszMasks[z], ':')) ? | 
|---|
| 1196 | pAD->afindex[y]->fullname : pAD->afindex[y]-> | 
|---|
| 1197 | filename, mask.pszMasks[z], FALSE)) | 
|---|
| 1198 | ret = TRUE; | 
|---|
| 1199 | } | 
|---|
| 1200 | else { | 
|---|
| 1201 | if (wildcard((strchr(mask.pszMasks[z], '\\') || | 
|---|
| 1202 | strchr(mask.pszMasks[z], ':')) ? | 
|---|
| 1203 | pAD->afindex[y]->fullname : pAD->afindex[y]-> | 
|---|
| 1204 | filename, mask.pszMasks[y] + 1, FALSE)) { | 
|---|
| 1205 | ret = FALSE; | 
|---|
| 1206 | break; | 
|---|
| 1207 | } | 
|---|
| 1208 | } | 
|---|
| 1209 | } | 
|---|
| 1210 | } | 
|---|
| 1211 | } | 
|---|
| 1212 | else if (*mask.szMask) { | 
|---|
| 1213 | if (wildcard((strchr(mask.szMask, '\\') || | 
|---|
| 1214 | strchr(mask.szMask, ':')) ? | 
|---|
| 1215 | pAD->afindex[y]->fullname : pAD->afindex[y]->filename, | 
|---|
| 1216 | mask.szMask, FALSE)) | 
|---|
| 1217 | ret = TRUE; | 
|---|
| 1218 | } | 
|---|
| 1219 | else | 
|---|
| 1220 | ret = TRUE; | 
|---|
| 1221 | if (ret) { | 
|---|
| 1222 | if ((!(mask.attrFile & FILE_HIDDEN) | 
|---|
| 1223 | && (pAD->afindex[y]->attrFile & FILE_HIDDEN)) | 
|---|
| 1224 | || (!(mask.attrFile & FILE_SYSTEM) | 
|---|
| 1225 | && (pAD->afindex[y]->attrFile & FILE_SYSTEM)) | 
|---|
| 1226 | || (!(mask.attrFile & FILE_READONLY) | 
|---|
| 1227 | && (pAD->afindex[y]->attrFile & FILE_READONLY)) | 
|---|
| 1228 | || (!(mask.attrFile & FILE_ARCHIVED) | 
|---|
| 1229 | && (pAD->afindex[y]->attrFile & FILE_ARCHIVED))) | 
|---|
| 1230 | ret = FALSE; | 
|---|
| 1231 | else | 
|---|
| 1232 | if (((mask.antiattr & FILE_HIDDEN) | 
|---|
| 1233 | && !(pAD->afindex[y]->attrFile & FILE_HIDDEN)) | 
|---|
| 1234 | || ((mask.antiattr & FILE_SYSTEM) | 
|---|
| 1235 | && !(pAD->afindex[y]->attrFile & FILE_SYSTEM)) | 
|---|
| 1236 | || ((mask.antiattr & FILE_READONLY) | 
|---|
| 1237 | && !(pAD->afindex[y]->attrFile & FILE_READONLY)) | 
|---|
| 1238 | || ((mask.antiattr & FILE_ARCHIVED) | 
|---|
| 1239 | && !(pAD->afindex[y]->attrFile & FILE_ARCHIVED))) | 
|---|
| 1240 | ret = FALSE; | 
|---|
| 1241 | } | 
|---|
| 1242 | if (ret) { | 
|---|
| 1243 | if (deselect) { | 
|---|
| 1244 | if (pAD->afindex[y]->flags & AF_SELECTED) { | 
|---|
| 1245 | pAD->selected--; | 
|---|
| 1246 | pAD->ullSelectedBytes -= pAD->afindex[y]->cbFile; | 
|---|
| 1247 | pAD->afindex[y]->flags &= ~AF_SELECTED; | 
|---|
| 1248 | } | 
|---|
| 1249 | } | 
|---|
| 1250 | else { | 
|---|
| 1251 | if (~pAD->afindex[y]->flags & AF_SELECTED) { | 
|---|
| 1252 | pAD->selected++; | 
|---|
| 1253 | pAD->ullSelectedBytes += pAD->afindex[y]->cbFile; | 
|---|
| 1254 | pAD->afindex[y]->flags |= AF_SELECTED; | 
|---|
| 1255 | } | 
|---|
| 1256 | } | 
|---|
| 1257 | } | 
|---|
| 1258 | }                                   // for | 
|---|
| 1259 | } | 
|---|
| 1260 | } | 
|---|
| 1261 |  | 
|---|
| 1262 | static VOID CollectList(HWND hwnd, CHAR ** list) | 
|---|
| 1263 | { | 
|---|
| 1264 | if (!Collector) { | 
|---|
| 1265 | if (hwndMain && !fExternalCollector && !strcmp(realappname, FM3Str)) { | 
|---|
| 1266 |  | 
|---|
| 1267 | HWND hwndC; | 
|---|
| 1268 | SWP swp; | 
|---|
| 1269 |  | 
|---|
| 1270 | if (!fAutoTile) | 
|---|
| 1271 | GetNextWindowPos(hwndMain, &swp, NULL, NULL); | 
|---|
| 1272 | hwndC = StartCollector(hwndMain, 4); | 
|---|
| 1273 | if (hwndC) { | 
|---|
| 1274 | if (!fAutoTile) | 
|---|
| 1275 | WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y, | 
|---|
| 1276 | swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | | 
|---|
| 1277 | SWP_SHOW | SWP_ZORDER); | 
|---|
| 1278 | else | 
|---|
| 1279 | TileChildren(hwndMain, TRUE); | 
|---|
| 1280 | WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE); | 
|---|
| 1281 | DosSleep(100);//05 Aug 07 GKY 250 | 
|---|
| 1282 | } | 
|---|
| 1283 | } | 
|---|
| 1284 | else { | 
|---|
| 1285 | StartCollector(HWND_DESKTOP, 4); | 
|---|
| 1286 | DosSleep(100);//05 Aug 07 GKY 250 | 
|---|
| 1287 | } | 
|---|
| 1288 | } | 
|---|
| 1289 | if (!PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), | 
|---|
| 1290 | MPFROMP(list))) | 
|---|
| 1291 | FreeList(list); | 
|---|
| 1292 | } | 
|---|
| 1293 |  | 
|---|
| 1294 | static VOID FreeAllFilesList(HWND hwnd) | 
|---|
| 1295 | { | 
|---|
| 1296 | ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1297 | register ULONG x; | 
|---|
| 1298 |  | 
|---|
| 1299 | if (ad->afhead && ad->affiles) { | 
|---|
| 1300 | for (x = 0; x < ad->affiles; x++) { | 
|---|
| 1301 | if (ad->afhead[x].fullname) | 
|---|
| 1302 | free(ad->afhead[x].fullname); | 
|---|
| 1303 | } | 
|---|
| 1304 | free(ad->afhead); | 
|---|
| 1305 | ad->afhead = NULL; | 
|---|
| 1306 | if (ad->afindex) | 
|---|
| 1307 | free(ad->afindex); | 
|---|
| 1308 | ad->afindex = NULL; | 
|---|
| 1309 | } | 
|---|
| 1310 | DosPostEventSem(CompactSem); | 
|---|
| 1311 | ad->afalloc = ad->afifiles = ad->affiles = ad->longest = ad->longestw = | 
|---|
| 1312 | ad->maxx = ad->horzscroll = 0; | 
|---|
| 1313 | } | 
|---|
| 1314 |  | 
|---|
| 1315 | static CHAR **BuildAList(HWND hwnd) | 
|---|
| 1316 | { | 
|---|
| 1317 | ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1318 | ULONG x; | 
|---|
| 1319 | ULONG y; | 
|---|
| 1320 | ULONG z = 0; | 
|---|
| 1321 | CHAR **list = NULL; | 
|---|
| 1322 | UINT numfiles = 0; | 
|---|
| 1323 | UINT numalloc = 0; | 
|---|
| 1324 | INT error; | 
|---|
| 1325 |  | 
|---|
| 1326 | if (ad->selected) { | 
|---|
| 1327 | for (x = 0; x < ad->afifiles; x++) { | 
|---|
| 1328 | y = (ad->invertsort) ? (ad->afifiles - 1) - x : x; | 
|---|
| 1329 | if (ad->afindex[y]->flags & AF_SELECTED) { | 
|---|
| 1330 | error = AddToList(ad->afindex[y]->fullname, &list, | 
|---|
| 1331 | &numfiles, &numalloc); | 
|---|
| 1332 | if (error) | 
|---|
| 1333 | break; | 
|---|
| 1334 | z++; | 
|---|
| 1335 | if (z >= ad->selected) | 
|---|
| 1336 | break; | 
|---|
| 1337 | } | 
|---|
| 1338 | } | 
|---|
| 1339 | } | 
|---|
| 1340 | return list; | 
|---|
| 1341 | } | 
|---|
| 1342 |  | 
|---|
| 1343 | static BOOL Mark(HWND hwnd, INT command, CHAR ** list) | 
|---|
| 1344 | { | 
|---|
| 1345 | /* Marks only unfiltered files */ | 
|---|
| 1346 |  | 
|---|
| 1347 | ALLDATA *pAD = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1348 | register ULONG x, y, z; | 
|---|
| 1349 | BOOL ret = TRUE; | 
|---|
| 1350 | BOOL didone = FALSE; | 
|---|
| 1351 |  | 
|---|
| 1352 | for (x = 0; x < pAD->afifiles; x++) { | 
|---|
| 1353 | y = (pAD->invertsort) ? (pAD->afifiles - 1) - x : x; | 
|---|
| 1354 | if (list) { | 
|---|
| 1355 | ret = FALSE; | 
|---|
| 1356 | for (z = 0; list[z]; z++) { | 
|---|
| 1357 | if (!stricmp(list[z], pAD->afindex[y]->fullname)) { | 
|---|
| 1358 | ret = TRUE; | 
|---|
| 1359 | break; | 
|---|
| 1360 | } | 
|---|
| 1361 | } | 
|---|
| 1362 | } | 
|---|
| 1363 | if (ret) { | 
|---|
| 1364 | didone = TRUE; | 
|---|
| 1365 | if (command == AFM_UNMARK) { | 
|---|
| 1366 | if (pAD->afindex[y]->flags & AF_SELECTED) { | 
|---|
| 1367 | pAD->selected--; | 
|---|
| 1368 | pAD->ullSelectedBytes -= pAD->afindex[y]->cbFile; | 
|---|
| 1369 | pAD->afindex[y]->flags &= ~AF_SELECTED; | 
|---|
| 1370 | } | 
|---|
| 1371 | } | 
|---|
| 1372 | else if (command == AFM_MARK) { | 
|---|
| 1373 | if (~pAD->afindex[y]->flags & AF_SELECTED) { | 
|---|
| 1374 | pAD->selected++; | 
|---|
| 1375 | pAD->ullSelectedBytes += pAD->afindex[y]->cbFile; | 
|---|
| 1376 | pAD->afindex[y]->flags |= AF_SELECTED; | 
|---|
| 1377 | } | 
|---|
| 1378 | } | 
|---|
| 1379 | else if (command == AFM_INVERT) { | 
|---|
| 1380 | if (pAD->afindex[y]->flags & AF_SELECTED) { | 
|---|
| 1381 | pAD->selected--; | 
|---|
| 1382 | pAD->ullSelectedBytes -= pAD->afindex[y]->cbFile; | 
|---|
| 1383 | pAD->afindex[y]->flags &= ~AF_SELECTED; | 
|---|
| 1384 | } | 
|---|
| 1385 | else { | 
|---|
| 1386 | pAD->selected++; | 
|---|
| 1387 | pAD->ullSelectedBytes += pAD->afindex[y]->cbFile; | 
|---|
| 1388 | pAD->afindex[y]->flags |= AF_SELECTED; | 
|---|
| 1389 | } | 
|---|
| 1390 | } | 
|---|
| 1391 | else if (command == AFM_MARKDELETED) { | 
|---|
| 1392 | if (pAD->afindex[y]->flags & AF_SELECTED) | 
|---|
| 1393 | pAD->afindex[y]->flags |= AF_DELETED; | 
|---|
| 1394 | } | 
|---|
| 1395 | else if (command == AFM_FILTER) { | 
|---|
| 1396 | if (pAD->afindex[y]->flags & AF_SELECTED) | 
|---|
| 1397 | pAD->afindex[y]->flags |= AF_FILTERED; | 
|---|
| 1398 | } | 
|---|
| 1399 | } | 
|---|
| 1400 | }                                     // for x | 
|---|
| 1401 | return didone; | 
|---|
| 1402 | } | 
|---|
| 1403 |  | 
|---|
| 1404 | static BOOL UpdateList(HWND hwnd, CHAR **list) | 
|---|
| 1405 | { | 
|---|
| 1406 | /* Updates files in the list */ | 
|---|
| 1407 |  | 
|---|
| 1408 | ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1409 | ULONG x, z; | 
|---|
| 1410 | BOOL ret, didone = FALSE; | 
|---|
| 1411 | FILEFINDBUF3L ffb; | 
|---|
| 1412 | ULONG ulFindCnt; | 
|---|
| 1413 | HDIR hdir; | 
|---|
| 1414 | CHAR *p; | 
|---|
| 1415 |  | 
|---|
| 1416 | if (list) { | 
|---|
| 1417 | for (z = 0; list[z] && !ad->stopflag; z++) { | 
|---|
| 1418 | ret = FALSE; | 
|---|
| 1419 | for (x = 0; x < ad->affiles; x++) { | 
|---|
| 1420 | if (!stricmp(list[z], ad->afhead[x].fullname)) { | 
|---|
| 1421 | ret = TRUE; | 
|---|
| 1422 | break; | 
|---|
| 1423 | } | 
|---|
| 1424 | } | 
|---|
| 1425 | if (ret) { | 
|---|
| 1426 | didone = TRUE; | 
|---|
| 1427 | hdir = HDIR_CREATE; | 
|---|
| 1428 | ulFindCnt = 1; | 
|---|
| 1429 | if (!xDosFindFirst(list[z], &hdir, FILE_NORMAL | FILE_ARCHIVED | | 
|---|
| 1430 | FILE_DIRECTORY | FILE_READONLY | FILE_SYSTEM | | 
|---|
| 1431 | FILE_HIDDEN, &ffb, sizeof(ffb), &ulFindCnt, | 
|---|
| 1432 | FIL_STANDARDL)) { | 
|---|
| 1433 | DosFindClose(hdir); | 
|---|
| 1434 | if (!(ffb.attrFile & FILE_DIRECTORY)) { | 
|---|
| 1435 | ad->afhead[x].attrFile = (USHORT) ffb.attrFile; | 
|---|
| 1436 | ad->afhead[x].cbFile = ffb.cbFile; | 
|---|
| 1437 | ad->afhead[x].date = ffb.fdateLastWrite; | 
|---|
| 1438 | ad->afhead[x].time = ffb.ftimeLastWrite; | 
|---|
| 1439 | } | 
|---|
| 1440 | else | 
|---|
| 1441 | ad->afhead[x].flags |= AF_DELETED; | 
|---|
| 1442 | } | 
|---|
| 1443 | else | 
|---|
| 1444 | ad->afhead[x].flags |= AF_DELETED; | 
|---|
| 1445 | } | 
|---|
| 1446 | else if (isalpha(*list[z]) && ad->abDrvFlags[toupper(*list[z]) - 'A']) { | 
|---|
| 1447 | didone = TRUE; | 
|---|
| 1448 | hdir = HDIR_CREATE; | 
|---|
| 1449 | ulFindCnt = 1; | 
|---|
| 1450 | if (!xDosFindFirst(list[z], &hdir, FILE_NORMAL | FILE_ARCHIVED | | 
|---|
| 1451 | FILE_DIRECTORY | FILE_READONLY | FILE_SYSTEM | | 
|---|
| 1452 | FILE_HIDDEN, &ffb, sizeof(ffb), &ulFindCnt, | 
|---|
| 1453 | FIL_STANDARDL)) { | 
|---|
| 1454 | DosFindClose(hdir); | 
|---|
| 1455 | if (!(ffb.attrFile & FILE_DIRECTORY)) { | 
|---|
| 1456 | if (!ad->afalloc || ad->affiles > ad->afalloc - 1) { | 
|---|
| 1457 |  | 
|---|
| 1458 | ALLFILES *temp, **templ; | 
|---|
| 1459 |  | 
|---|
| 1460 | temp = | 
|---|
| 1461 | xrealloc(ad->afhead, (ad->afalloc + 1) * sizeof(ALLFILES), | 
|---|
| 1462 | pszSrcFile, __LINE__); | 
|---|
| 1463 | if (!temp) { | 
|---|
| 1464 | ad->stopflag = 1; | 
|---|
| 1465 | break; | 
|---|
| 1466 | } | 
|---|
| 1467 | else { | 
|---|
| 1468 | ad->afhead = temp; | 
|---|
| 1469 | templ = | 
|---|
| 1470 | xrealloc(ad->afindex, | 
|---|
| 1471 | (ad->afalloc + 1) * sizeof(ALLFILES *), pszSrcFile, | 
|---|
| 1472 | __LINE__); | 
|---|
| 1473 | if (!templ) { | 
|---|
| 1474 | ad->stopflag = 1; | 
|---|
| 1475 | break; | 
|---|
| 1476 | } | 
|---|
| 1477 | else | 
|---|
| 1478 | ad->afindex = templ; | 
|---|
| 1479 | ad->afalloc++; | 
|---|
| 1480 | } | 
|---|
| 1481 | } | 
|---|
| 1482 | ad->afhead[ad->affiles].fullname = | 
|---|
| 1483 | xstrdup(list[z], pszSrcFile, __LINE__); | 
|---|
| 1484 | if (ad->afhead[ad->affiles].fullname) { | 
|---|
| 1485 | p = strrchr(ad->afhead[ad->affiles].fullname, '\\'); | 
|---|
| 1486 | if (!p) | 
|---|
| 1487 | p = ad->afhead[ad->affiles].fullname; | 
|---|
| 1488 | else | 
|---|
| 1489 | p++; | 
|---|
| 1490 | ad->afhead[ad->affiles].filename = p; | 
|---|
| 1491 | ad->afhead[ad->affiles].cbFile = ffb.cbFile; | 
|---|
| 1492 | ad->afhead[ad->affiles].date = ffb.fdateLastWrite; | 
|---|
| 1493 | ad->afhead[ad->affiles].time = ffb.ftimeLastWrite; | 
|---|
| 1494 | ad->afhead[ad->affiles].attrFile = (USHORT) ffb.attrFile; | 
|---|
| 1495 | ad->afhead[ad->affiles].flags = 0; | 
|---|
| 1496 | if (ad->longest < strlen(ad->afhead[ad->affiles].filename)) | 
|---|
| 1497 | ad->longest = strlen(ad->afhead[ad->affiles].filename); | 
|---|
| 1498 | if (ad->longestw < strlen(ad->afhead[ad->affiles].fullname)) | 
|---|
| 1499 | ad->longestw = strlen(ad->afhead[ad->affiles].fullname); | 
|---|
| 1500 |  | 
|---|
| 1501 | ad->affiles++; | 
|---|
| 1502 | } | 
|---|
| 1503 | else { | 
|---|
| 1504 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Strdup failed."); | 
|---|
| 1505 | ad->stopflag = 1; | 
|---|
| 1506 | break; | 
|---|
| 1507 | } | 
|---|
| 1508 | } | 
|---|
| 1509 | } | 
|---|
| 1510 | } | 
|---|
| 1511 | } | 
|---|
| 1512 | } | 
|---|
| 1513 | return didone; | 
|---|
| 1514 | } | 
|---|
| 1515 |  | 
|---|
| 1516 | static int comparefullnames(const void *v1, const void *v2) | 
|---|
| 1517 | { | 
|---|
| 1518 | ALLFILES *d1 = *(ALLFILES **) v1; | 
|---|
| 1519 | ALLFILES *d2 = *(ALLFILES **) v2; | 
|---|
| 1520 | int ret; | 
|---|
| 1521 |  | 
|---|
| 1522 | ret = stricmp(d1->fullname, d2->fullname); | 
|---|
| 1523 | return ret; | 
|---|
| 1524 | } | 
|---|
| 1525 |  | 
|---|
| 1526 | static int comparenames(const void *v1, const void *v2) | 
|---|
| 1527 | { | 
|---|
| 1528 | ALLFILES *d1 = *(ALLFILES **) v1; | 
|---|
| 1529 | ALLFILES *d2 = *(ALLFILES **) v2; | 
|---|
| 1530 | int ret; | 
|---|
| 1531 |  | 
|---|
| 1532 | ret = stricmp(d1->filename, d2->filename); | 
|---|
| 1533 | if (!ret) | 
|---|
| 1534 | ret = comparefullnames(v1, v2); | 
|---|
| 1535 | return ret; | 
|---|
| 1536 | } | 
|---|
| 1537 |  | 
|---|
| 1538 | static int compareexts(const void *v1, const void *v2) | 
|---|
| 1539 | { | 
|---|
| 1540 | ALLFILES *d1 = *(ALLFILES **) v1; | 
|---|
| 1541 | ALLFILES *d2 = *(ALLFILES **) v2; | 
|---|
| 1542 | register CHAR *p1, *p2; | 
|---|
| 1543 | int ret; | 
|---|
| 1544 |  | 
|---|
| 1545 | p1 = strrchr(d1->filename, '.'); | 
|---|
| 1546 | p2 = strrchr(d2->filename, '.'); | 
|---|
| 1547 | if (!p1) | 
|---|
| 1548 | p1 = NullStr; | 
|---|
| 1549 | else | 
|---|
| 1550 | p1++; | 
|---|
| 1551 | if (!p2) | 
|---|
| 1552 | p2 = NullStr; | 
|---|
| 1553 | else | 
|---|
| 1554 | p2++; | 
|---|
| 1555 | ret = stricmp(p1, p2); | 
|---|
| 1556 | if (!ret) | 
|---|
| 1557 | ret = comparenames(v1, v2); | 
|---|
| 1558 | return ret; | 
|---|
| 1559 | } | 
|---|
| 1560 |  | 
|---|
| 1561 | static int comparesizes(const void *v1, const void *v2) | 
|---|
| 1562 | { | 
|---|
| 1563 | ALLFILES *d1 = *(ALLFILES **) v1; | 
|---|
| 1564 | ALLFILES *d2 = *(ALLFILES **) v2; | 
|---|
| 1565 | int ret; | 
|---|
| 1566 |  | 
|---|
| 1567 | ret = (d1->cbFile > d2->cbFile) ? 1 : (d1->cbFile == d2->cbFile) ? 0 : -1; | 
|---|
| 1568 | if (!ret) | 
|---|
| 1569 | ret = comparenames(v1, v2); | 
|---|
| 1570 | return ret; | 
|---|
| 1571 | } | 
|---|
| 1572 |  | 
|---|
| 1573 | static int comparedates(const void *v1, const void *v2) | 
|---|
| 1574 | { | 
|---|
| 1575 | ALLFILES *d1 = *(ALLFILES **) v1; | 
|---|
| 1576 | ALLFILES *d2 = *(ALLFILES **) v2; | 
|---|
| 1577 | int ret; | 
|---|
| 1578 |  | 
|---|
| 1579 | ret = TestFDates(NULL, NULL, | 
|---|
| 1580 | &d2->date, &d2->time, | 
|---|
| 1581 | &d1->date, &d1->time); | 
|---|
| 1582 | /*(d1->date.year > d2->date.year) ? 1 : | 
|---|
| 1583 | (d1->date.year < d2->date.year) ? -1 : | 
|---|
| 1584 | (d1->date.month > d2->date.month) ? 1 : | 
|---|
| 1585 | (d1->date.month < d2->date.month) ? -1 : | 
|---|
| 1586 | (d1->date.day > d2->date.day) ? 1 : | 
|---|
| 1587 | (d1->date.day < d2->date.day) ? -1 : | 
|---|
| 1588 | (d1->time.hours > d2->time.hours) ? 1 : | 
|---|
| 1589 | (d1->time.hours < d2->time.hours) ? -1 : | 
|---|
| 1590 | (d1->time.minutes > d2->time.minutes) ? 1 : | 
|---|
| 1591 | (d1->time.minutes < d2->time.minutes) ? -1 : | 
|---|
| 1592 | (d1->time.twosecs > d2->time.twosecs) ? 1 : | 
|---|
| 1593 | (d1->time.twosecs < d2->time.twosecs) ? -1 : 0;*/ | 
|---|
| 1594 |  | 
|---|
| 1595 | if (!ret) | 
|---|
| 1596 | ret = comparenames(v1, v2); | 
|---|
| 1597 | return ret; | 
|---|
| 1598 | } | 
|---|
| 1599 |  | 
|---|
| 1600 | static VOID ReSort(HWND hwnd) | 
|---|
| 1601 | { | 
|---|
| 1602 | ALLDATA *pAD = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1603 | register ULONG x, y; | 
|---|
| 1604 |  | 
|---|
| 1605 | pAD->selected = 0; | 
|---|
| 1606 | pAD->ullSelectedBytes = 0; | 
|---|
| 1607 | for (x = 0, y = 0; x < pAD->affiles; x++) { | 
|---|
| 1608 | if (!(pAD->afhead[x].flags & (AF_DELETED | AF_FILTERED))) { | 
|---|
| 1609 | if (pAD->afhead[x].flags & AF_SELECTED) { | 
|---|
| 1610 | pAD->selected++; | 
|---|
| 1611 | pAD->ullSelectedBytes += pAD->afhead[x].cbFile; | 
|---|
| 1612 | } | 
|---|
| 1613 | pAD->afindex[y++] = &(pAD->afhead[x]); | 
|---|
| 1614 | } | 
|---|
| 1615 | }                                     // for x | 
|---|
| 1616 | pAD->afifiles = y; | 
|---|
| 1617 | PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID); | 
|---|
| 1618 | if (!pAD->stopflag && pAD->pfnCompare && pAD->afifiles) { | 
|---|
| 1619 | WinSendMsg(hwnd, UM_RESCAN, MPFROMLONG(1), MPVOID); | 
|---|
| 1620 | qsort(pAD->afindex, pAD->afifiles, sizeof(ALLFILES *), pAD->pfnCompare); | 
|---|
| 1621 | } | 
|---|
| 1622 | } | 
|---|
| 1623 |  | 
|---|
| 1624 | VOID FindDupesThread(VOID * args) | 
|---|
| 1625 | { | 
|---|
| 1626 | register ULONG x, z; | 
|---|
| 1627 | register CHAR *px, *pz; | 
|---|
| 1628 | CHAR s[80]; | 
|---|
| 1629 | INT error; | 
|---|
| 1630 | HWND hwnd = (HWND) args; | 
|---|
| 1631 | HAB hab2 = (HAB) 0; | 
|---|
| 1632 | HMQ hmq2 = (HMQ) 0; | 
|---|
| 1633 | ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1634 |  | 
|---|
| 1635 | if (!DosRequestMutexSem(ad->hmtxScan, SEM_INDEFINITE_WAIT)) { | 
|---|
| 1636 | priority_normal(); | 
|---|
| 1637 | hab2 = WinInitialize(0); | 
|---|
| 1638 | if (hab2) { | 
|---|
| 1639 | hmq2 = WinCreateMsgQueue(hab2, 0); | 
|---|
| 1640 | if (hmq2) { | 
|---|
| 1641 | WinCancelShutdown(hmq2, TRUE); | 
|---|
| 1642 | IncrThreadUsage(); | 
|---|
| 1643 | if (ad->cursored <= ad->afifiles) { | 
|---|
| 1644 | for (x = 0; x < ad->affiles; x++) | 
|---|
| 1645 | ad->afhead[x].flags &= (~(AF_DUPE | AF_SELECTED)); | 
|---|
| 1646 | DosSleep(0);  //26 Aug 07 GKY 1 | 
|---|
| 1647 | for (x = 0; x < ad->affiles && !ad->stopflag; x++) { | 
|---|
| 1648 | if (!(ad->afhead[x].flags & (AF_DUPE | AF_FILTERED))) { | 
|---|
| 1649 | if (!(x % 50)) { | 
|---|
| 1650 | sprintf(s, | 
|---|
| 1651 | GetPString(IDS_DUPECHECKINGOFTEXT), x, ad->affiles); | 
|---|
| 1652 | WinSetWindowText(ad->hwndStatus, s); | 
|---|
| 1653 | } | 
|---|
| 1654 | for (z = 0; z < ad->affiles && !ad->stopflag; z++) { | 
|---|
| 1655 | if (x != z && | 
|---|
| 1656 | !(ad->afhead[z].flags & (AF_DUPE | AF_FILTERED))) | 
|---|
| 1657 | { | 
|---|
| 1658 | if (ad->dupeflags & DP_SIZES) { | 
|---|
| 1659 | if (ad->afhead[x].cbFile != ad->afhead[z].cbFile) | 
|---|
| 1660 | goto SkipNonDupe; | 
|---|
| 1661 | } | 
|---|
| 1662 | if (ad->dupeflags & DP_DATES) { | 
|---|
| 1663 | if (*(INT *) & ad->afhead[x].date != | 
|---|
| 1664 | *(INT *) & ad->afhead[z].date || | 
|---|
| 1665 | *(INT *) & ad->afhead[x].time != | 
|---|
| 1666 | *(INT *) & ad->afhead[z].time) | 
|---|
| 1667 | goto SkipNonDupe; | 
|---|
| 1668 | } | 
|---|
| 1669 | if (ad->dupeflags & DP_NAMES) { | 
|---|
| 1670 | if (ad->dupeflags & DP_EXTS) { | 
|---|
| 1671 | px = strrchr(ad->afhead[x].filename, '.'); | 
|---|
| 1672 | pz = strrchr(ad->afhead[z].filename, '.'); | 
|---|
| 1673 | if ((px || pz) && (!px || !pz)) | 
|---|
| 1674 | goto SkipNonDupe; | 
|---|
| 1675 | if (px) { | 
|---|
| 1676 | *px = 0; | 
|---|
| 1677 | *pz = 0; | 
|---|
| 1678 | } | 
|---|
| 1679 | } | 
|---|
| 1680 | if (stricmp(ad->afhead[x].filename, | 
|---|
| 1681 | ad->afhead[z].filename)) { | 
|---|
| 1682 | if (ad->dupeflags & DP_EXTS) { | 
|---|
| 1683 | if (px) { | 
|---|
| 1684 | *px = '.'; | 
|---|
| 1685 | *pz = '.'; | 
|---|
| 1686 | } | 
|---|
| 1687 | } | 
|---|
| 1688 | goto SkipNonDupe; | 
|---|
| 1689 | } | 
|---|
| 1690 | if (ad->dupeflags & DP_EXTS) { | 
|---|
| 1691 | if (px) { | 
|---|
| 1692 | *px = '.'; | 
|---|
| 1693 | *pz = '.'; | 
|---|
| 1694 | } | 
|---|
| 1695 | } | 
|---|
| 1696 | } | 
|---|
| 1697 | if (ad->dupeflags & DP_CRCS) { | 
|---|
| 1698 | if (!(ad->afhead[x].flags & AF_CRCED)) { | 
|---|
| 1699 | ad->afhead[x].CRC = CRCFile(ad->afhead[x].fullname, | 
|---|
| 1700 | &error); | 
|---|
| 1701 | if (!error) | 
|---|
| 1702 | ad->afhead[x].flags |= AF_CRCED; | 
|---|
| 1703 | } | 
|---|
| 1704 | if (!(ad->afhead[z].flags & AF_CRCED)) { | 
|---|
| 1705 | ad->afhead[z].CRC = CRCFile(ad->afhead[z].fullname, | 
|---|
| 1706 | &error); | 
|---|
| 1707 | if (!error) | 
|---|
| 1708 | ad->afhead[z].flags |= AF_CRCED; | 
|---|
| 1709 | } | 
|---|
| 1710 | if ((ad->afhead[x].flags & AF_CRCED) && | 
|---|
| 1711 | (ad->afhead[z].flags & AF_CRCED)) { | 
|---|
| 1712 | if (ad->afhead[x].CRC != ad->afhead[z].CRC) | 
|---|
| 1713 | goto SkipNonDupe; | 
|---|
| 1714 | } | 
|---|
| 1715 | DosSleep(0); | 
|---|
| 1716 | } | 
|---|
| 1717 | ad->afhead[x].flags |= AF_DUPE; | 
|---|
| 1718 | ad->afhead[z].flags |= AF_DUPE; | 
|---|
| 1719 | SkipNonDupe: | 
|---|
| 1720 | ; | 
|---|
| 1721 | } | 
|---|
| 1722 | } // for | 
|---|
| 1723 | DosSleep(0); | 
|---|
| 1724 | } | 
|---|
| 1725 | } // for | 
|---|
| 1726 | for (x = 0; x < ad->affiles && !ad->stopflag; x++) { | 
|---|
| 1727 | if (!(ad->afhead[x].flags & AF_DUPE)) | 
|---|
| 1728 | ad->afhead[x].flags |= AF_FILTERED; | 
|---|
| 1729 | } | 
|---|
| 1730 | ReSort(hwnd); | 
|---|
| 1731 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 1732 | } | 
|---|
| 1733 | } | 
|---|
| 1734 | } | 
|---|
| 1735 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 1736 | DosReleaseMutexSem(ad->hmtxScan); | 
|---|
| 1737 | } // if got sem | 
|---|
| 1738 | if (hmq2) { | 
|---|
| 1739 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID); | 
|---|
| 1740 | WinDestroyMsgQueue(hmq2); | 
|---|
| 1741 | } | 
|---|
| 1742 | if (hab2) { | 
|---|
| 1743 | DecrThreadUsage(); | 
|---|
| 1744 | WinTerminate(hab2); | 
|---|
| 1745 | } | 
|---|
| 1746 | } | 
|---|
| 1747 |  | 
|---|
| 1748 | static VOID FilterList(HWND hwnd) | 
|---|
| 1749 | { | 
|---|
| 1750 | register ULONG x, z; | 
|---|
| 1751 | BOOL ret; | 
|---|
| 1752 | ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1753 | CHAR *p; | 
|---|
| 1754 |  | 
|---|
| 1755 | if (ad->cursored <= ad->afifiles) { | 
|---|
| 1756 | x = ad->cursored - 1; | 
|---|
| 1757 | x = (ad->invertsort) ? (ad->afifiles - 1) - x : x; | 
|---|
| 1758 | p = strrchr(ad->afindex[x]->filename, '.'); | 
|---|
| 1759 | if (p) { | 
|---|
| 1760 | strcpy(ad->mask.szMask, "*"); | 
|---|
| 1761 | strcat(ad->mask.szMask, p); | 
|---|
| 1762 | } | 
|---|
| 1763 | } | 
|---|
| 1764 | *(ad->mask.prompt) = 0; | 
|---|
| 1765 | ad->mask.fIsSeeAll = TRUE; | 
|---|
| 1766 | if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc, | 
|---|
| 1767 | FM3ModHandle, MSK_FRAME, MPFROMP(&ad->mask))) { | 
|---|
| 1768 | for (x = 0; x < ad->affiles; x++) { | 
|---|
| 1769 | ret = FALSE; | 
|---|
| 1770 | if (ad->mask.pszMasks[1]) { | 
|---|
| 1771 | for (z = 0; ad->mask.pszMasks[z]; z++) { | 
|---|
| 1772 | if (*ad->mask.pszMasks[z]) { | 
|---|
| 1773 | if (*ad->mask.pszMasks[z] != '/') { | 
|---|
| 1774 | if (wildcard((strchr(ad->mask.pszMasks[z], '\\') || | 
|---|
| 1775 | strchr(ad->mask.pszMasks[z], ':')) ? | 
|---|
| 1776 | ad->afhead[x].fullname : ad->afhead[x].filename, | 
|---|
| 1777 | ad->mask.pszMasks[z], FALSE)) | 
|---|
| 1778 | ret = TRUE; | 
|---|
| 1779 | } | 
|---|
| 1780 | else { | 
|---|
| 1781 | if (wildcard((strchr(ad->mask.pszMasks[z], '\\') || | 
|---|
| 1782 | strchr(ad->mask.pszMasks[z], ':')) ? | 
|---|
| 1783 | ad->afhead[x].fullname : ad->afhead[x].filename, | 
|---|
| 1784 | ad->mask.pszMasks[z] + 1, FALSE)) { | 
|---|
| 1785 | ret = FALSE; | 
|---|
| 1786 | break; | 
|---|
| 1787 | } | 
|---|
| 1788 | } | 
|---|
| 1789 | } | 
|---|
| 1790 | } | 
|---|
| 1791 | } | 
|---|
| 1792 | else if (*ad->mask.szMask) { | 
|---|
| 1793 | if (wildcard((strchr(ad->mask.szMask, '\\') || | 
|---|
| 1794 | strchr(ad->mask.szMask, ':')) ? | 
|---|
| 1795 | ad->afhead[x].fullname : ad->afhead[x].filename, | 
|---|
| 1796 | ad->mask.szMask, FALSE)) | 
|---|
| 1797 | ret = TRUE; | 
|---|
| 1798 | } | 
|---|
| 1799 | else | 
|---|
| 1800 | ret = TRUE; | 
|---|
| 1801 |  | 
|---|
| 1802 | if (ret) { | 
|---|
| 1803 | if ((!(ad->mask.attrFile & FILE_HIDDEN) | 
|---|
| 1804 | && (ad->afhead[x].attrFile & FILE_HIDDEN)) | 
|---|
| 1805 | || (!(ad->mask.attrFile & FILE_SYSTEM) | 
|---|
| 1806 | && (ad->afhead[x].attrFile & FILE_SYSTEM)) | 
|---|
| 1807 | || (!(ad->mask.attrFile & FILE_READONLY) | 
|---|
| 1808 | && (ad->afhead[x].attrFile & FILE_READONLY)) | 
|---|
| 1809 | || (!(ad->mask.attrFile & FILE_ARCHIVED) | 
|---|
| 1810 | && (ad->afhead[x].attrFile & FILE_ARCHIVED))) | 
|---|
| 1811 | ret = FALSE; | 
|---|
| 1812 | else | 
|---|
| 1813 | if (((ad->mask.antiattr & FILE_HIDDEN) | 
|---|
| 1814 | && !(ad->afhead[x].attrFile & FILE_HIDDEN)) | 
|---|
| 1815 | || ((ad->mask.antiattr & FILE_SYSTEM) | 
|---|
| 1816 | && !(ad->afhead[x].attrFile & FILE_SYSTEM)) | 
|---|
| 1817 | || ((ad->mask.antiattr & FILE_READONLY) | 
|---|
| 1818 | && !(ad->afhead[x].attrFile & FILE_READONLY)) | 
|---|
| 1819 | || ((ad->mask.antiattr & FILE_ARCHIVED) | 
|---|
| 1820 | && !(ad->afhead[x].attrFile & FILE_ARCHIVED))) | 
|---|
| 1821 | ret = FALSE; | 
|---|
| 1822 | } | 
|---|
| 1823 |  | 
|---|
| 1824 | if (!ret) | 
|---|
| 1825 | ad->afhead[x].flags |= AF_FILTERED; | 
|---|
| 1826 | else | 
|---|
| 1827 | ad->afhead[x].flags &= (~AF_FILTERED); | 
|---|
| 1828 | } | 
|---|
| 1829 | ReSort(hwnd); | 
|---|
| 1830 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 1831 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 1832 | } | 
|---|
| 1833 | } | 
|---|
| 1834 |  | 
|---|
| 1835 | static ULONG RemoveDeleted(HWND hwnd) | 
|---|
| 1836 | { | 
|---|
| 1837 | ALLDATA *pAD = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1838 | ULONG oldaffiles = pAD->affiles; | 
|---|
| 1839 | register ULONG x, y; | 
|---|
| 1840 |  | 
|---|
| 1841 | for (x = 0; x < pAD->affiles; x++) { | 
|---|
| 1842 | if (pAD->afhead[x].flags & AF_DELETED) { | 
|---|
| 1843 | for (y = x; y < pAD->affiles; y++) { | 
|---|
| 1844 | if (~pAD->afhead[y].flags & AF_DELETED) | 
|---|
| 1845 | break; | 
|---|
| 1846 | if (pAD->afhead[y].flags & AF_SELECTED && | 
|---|
| 1847 | ~pAD->afhead[y].flags & AF_FILTERED) { | 
|---|
| 1848 | pAD->selected--; | 
|---|
| 1849 | pAD->ullSelectedBytes -= pAD->afhead[y].cbFile; | 
|---|
| 1850 | } | 
|---|
| 1851 | free(pAD->afhead[y].fullname); | 
|---|
| 1852 | } | 
|---|
| 1853 | memmove(&(pAD->afhead[x]), &(pAD->afhead[y]), | 
|---|
| 1854 | (pAD->affiles - y) * sizeof(ALLFILES)); | 
|---|
| 1855 | pAD->affiles -= (y - x); | 
|---|
| 1856 | } | 
|---|
| 1857 | }                                     // for x | 
|---|
| 1858 | if (pAD->affiles != oldaffiles) { | 
|---|
| 1859 |  | 
|---|
| 1860 | ALLFILES *tempa, **templ; | 
|---|
| 1861 |  | 
|---|
| 1862 | if (!pAD->affiles) | 
|---|
| 1863 | FreeAllFilesList(hwnd); | 
|---|
| 1864 | else { | 
|---|
| 1865 | tempa = | 
|---|
| 1866 | xrealloc(pAD->afhead, pAD->affiles * sizeof(ALLFILES), pszSrcFile, | 
|---|
| 1867 | __LINE__); | 
|---|
| 1868 | if (tempa) { | 
|---|
| 1869 | pAD->afhead = tempa; | 
|---|
| 1870 | pAD->afalloc = pAD->affiles; | 
|---|
| 1871 | } | 
|---|
| 1872 | templ = | 
|---|
| 1873 | xrealloc(pAD->afindex, pAD->affiles * sizeof(ALLFILES *), pszSrcFile, | 
|---|
| 1874 | __LINE__); | 
|---|
| 1875 | if (templ) | 
|---|
| 1876 | pAD->afindex = templ; | 
|---|
| 1877 | DosPostEventSem(CompactSem); | 
|---|
| 1878 | ReSort(hwnd); | 
|---|
| 1879 | } | 
|---|
| 1880 | } | 
|---|
| 1881 | return pAD->affiles; | 
|---|
| 1882 | } | 
|---|
| 1883 |  | 
|---|
| 1884 | static VOID DoADir(HWND hwnd, CHAR * pathname) | 
|---|
| 1885 | { | 
|---|
| 1886 | ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1887 | CHAR *filename, *enddir; | 
|---|
| 1888 | PFILEFINDBUF3L pffbArray, pffbFile; | 
|---|
| 1889 | HDIR hdir = HDIR_CREATE; | 
|---|
| 1890 | ULONG ulFindCnt; | 
|---|
| 1891 | ULONG ulFindMax; | 
|---|
| 1892 | ULONG ulBufBytes; | 
|---|
| 1893 | ULONG x; | 
|---|
| 1894 | APIRET rc; | 
|---|
| 1895 |  | 
|---|
| 1896 | filename = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__); | 
|---|
| 1897 | if (!filename) | 
|---|
| 1898 | return; | 
|---|
| 1899 |  | 
|---|
| 1900 | ulFindMax = FilesToGet; | 
|---|
| 1901 | if (fRemoteBug && isalpha(*pathname) && pathname[1] == ':' && | 
|---|
| 1902 | pathname[2] == '\\' && | 
|---|
| 1903 | (driveflags[toupper(*pathname) - 'A'] & DRIVE_REMOTE)) | 
|---|
| 1904 | ulFindMax = 1; | 
|---|
| 1905 |  | 
|---|
| 1906 | ulBufBytes = sizeof(FILEFINDBUF3L) * ulFindMax; | 
|---|
| 1907 | pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__); | 
|---|
| 1908 | if (!pffbArray) { | 
|---|
| 1909 | free(filename); | 
|---|
| 1910 | return; | 
|---|
| 1911 | } | 
|---|
| 1912 |  | 
|---|
| 1913 | strcpy(filename, pathname); | 
|---|
| 1914 | enddir = &filename[strlen(filename) - 1]; | 
|---|
| 1915 | if (*enddir != '\\') { | 
|---|
| 1916 | enddir++; | 
|---|
| 1917 | *enddir = '\\'; | 
|---|
| 1918 | } | 
|---|
| 1919 | enddir++; | 
|---|
| 1920 | strcpy(enddir, "*"); | 
|---|
| 1921 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 1922 | ulFindCnt = ulFindMax; | 
|---|
| 1923 | rc = xDosFindFirst(filename, &hdir, FILE_NORMAL | FILE_ARCHIVED | | 
|---|
| 1924 | FILE_READONLY | FILE_DIRECTORY | FILE_SYSTEM | | 
|---|
| 1925 | FILE_HIDDEN, | 
|---|
| 1926 | pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARDL); | 
|---|
| 1927 | if (!rc) { | 
|---|
| 1928 | do { | 
|---|
| 1929 | priority_normal(); | 
|---|
| 1930 | pffbFile = pffbArray; | 
|---|
| 1931 | for (x = 0; x < ulFindCnt; x++) { | 
|---|
| 1932 | if (pffbFile->attrFile & FILE_DIRECTORY) { | 
|---|
| 1933 | // Skip . and .. | 
|---|
| 1934 | if (pffbFile->achName[0] != '.' || | 
|---|
| 1935 | (pffbFile->achName[1] && | 
|---|
| 1936 | (pffbFile->achName[1] != '.' || pffbFile->achName[2]))) { | 
|---|
| 1937 | strcpy(enddir, pffbFile->achName); | 
|---|
| 1938 | DoADir(hwnd, filename); | 
|---|
| 1939 | } | 
|---|
| 1940 | } | 
|---|
| 1941 | else { | 
|---|
| 1942 | *enddir = 0; | 
|---|
| 1943 | strcpy(enddir, pffbFile->achName); | 
|---|
| 1944 | if (!ad->afalloc || ad->affiles > ad->afalloc - 1) { | 
|---|
| 1945 |  | 
|---|
| 1946 | ALLFILES *temp; | 
|---|
| 1947 |  | 
|---|
| 1948 | temp = xrealloc(ad->afhead, (ad->afalloc + 1000) * | 
|---|
| 1949 | sizeof(ALLFILES), pszSrcFile, __LINE__); | 
|---|
| 1950 | if (!temp) { | 
|---|
| 1951 | ad->stopflag = 1; | 
|---|
| 1952 | break; | 
|---|
| 1953 | } | 
|---|
| 1954 | else { | 
|---|
| 1955 | ad->afhead = temp; | 
|---|
| 1956 | if (ad->stopflag) | 
|---|
| 1957 | break; | 
|---|
| 1958 | ad->afalloc += 1000; | 
|---|
| 1959 | } | 
|---|
| 1960 | } | 
|---|
| 1961 | ad->afhead[ad->affiles].fullname = | 
|---|
| 1962 | xstrdup(filename, pszSrcFile, __LINE__); | 
|---|
| 1963 | if (!ad->afhead[ad->affiles].fullname) { | 
|---|
| 1964 | ad->stopflag = 1; | 
|---|
| 1965 | break; | 
|---|
| 1966 | } | 
|---|
| 1967 | else { | 
|---|
| 1968 | ad->afhead[ad->affiles].filename = | 
|---|
| 1969 | ad->afhead[ad->affiles].fullname + (enddir - filename); | 
|---|
| 1970 | ad->afhead[ad->affiles].cbFile = pffbFile->cbFile; | 
|---|
| 1971 | ad->afhead[ad->affiles].date = pffbFile->fdateLastWrite; | 
|---|
| 1972 | ad->afhead[ad->affiles].time = pffbFile->ftimeLastWrite; | 
|---|
| 1973 | ad->afhead[ad->affiles].attrFile = (USHORT) pffbFile->attrFile; | 
|---|
| 1974 | ad->afhead[ad->affiles].flags = 0; | 
|---|
| 1975 | ad->affiles++; | 
|---|
| 1976 | if (ad->longest < pffbFile->cchName) | 
|---|
| 1977 | ad->longest = pffbFile->cchName; | 
|---|
| 1978 | if (ad->longestw < pffbFile->cchName + (enddir - filename)) | 
|---|
| 1979 | ad->longestw = pffbFile->cchName + (enddir - filename); | 
|---|
| 1980 | } | 
|---|
| 1981 | } | 
|---|
| 1982 | pffbFile = (PFILEFINDBUF3L)((PBYTE)pffbFile + pffbFile->oNextEntryOffset); | 
|---|
| 1983 | } // for | 
|---|
| 1984 | if (ad->stopflag) | 
|---|
| 1985 | break; | 
|---|
| 1986 | ulFindCnt = ulFindMax; | 
|---|
| 1987 | rc = xDosFindNext(hdir, | 
|---|
| 1988 | pffbArray, | 
|---|
| 1989 | sizeof(FILEFINDBUF3L) * ulFindCnt, | 
|---|
| 1990 | &ulFindCnt, | 
|---|
| 1991 | FIL_STANDARDL); | 
|---|
| 1992 | } while (!rc); | 
|---|
| 1993 | DosFindClose(hdir); | 
|---|
| 1994 | } | 
|---|
| 1995 |  | 
|---|
| 1996 | if (rc && rc != ERROR_NO_MORE_FILES) { | 
|---|
| 1997 | Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1998 | GetPString(IDS_CANTFINDDIRTEXT), filename); | 
|---|
| 1999 | } | 
|---|
| 2000 |  | 
|---|
| 2001 | free(pffbArray); | 
|---|
| 2002 | free(filename); | 
|---|
| 2003 | } | 
|---|
| 2004 |  | 
|---|
| 2005 | static VOID FindAllThread(VOID * args) | 
|---|
| 2006 | { | 
|---|
| 2007 | ULONG ulDriveNum, ulDriveMap, x; | 
|---|
| 2008 | CHAR startname[] = " :\\"; | 
|---|
| 2009 | HWND hwnd = (HWND) args; | 
|---|
| 2010 | HAB hab2 = (HAB) 0; | 
|---|
| 2011 | HMQ hmq2 = (HMQ) 0; | 
|---|
| 2012 | ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 2013 |  | 
|---|
| 2014 | if (!DosRequestMutexSem(ad->hmtxScan, SEM_INDEFINITE_WAIT)) { | 
|---|
| 2015 | priority_normal(); | 
|---|
| 2016 | hab2 = WinInitialize(0); | 
|---|
| 2017 | if (hab2) { | 
|---|
| 2018 | hmq2 = WinCreateMsgQueue(hab2, 0); | 
|---|
| 2019 | if (hmq2) { | 
|---|
| 2020 | WinCancelShutdown(hmq2, TRUE); | 
|---|
| 2021 | IncrThreadUsage(); | 
|---|
| 2022 | if (!*ad->szFindPath) { | 
|---|
| 2023 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 2024 | if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) { | 
|---|
| 2025 | for (x = 2; x < 26 && !ad->stopflag; x++) { | 
|---|
| 2026 | if ((ulDriveMap & (1 << x)) && ad->abDrvFlags[x]) { | 
|---|
| 2027 | *startname = (CHAR) (x + 'A'); | 
|---|
| 2028 | DoADir(hwnd, startname); | 
|---|
| 2029 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 2030 | DosSleep(0); //26 Aug 07 GKY 1 | 
|---|
| 2031 | } | 
|---|
| 2032 | } | 
|---|
| 2033 | } | 
|---|
| 2034 | } | 
|---|
| 2035 | else | 
|---|
| 2036 | DoADir(hwnd, ad->szFindPath); | 
|---|
| 2037 | DosPostEventSem(CompactSem); | 
|---|
| 2038 | } | 
|---|
| 2039 | } | 
|---|
| 2040 | if (ad->afalloc != ad->affiles) { | 
|---|
| 2041 |  | 
|---|
| 2042 | ALLFILES *tempa, **templ; | 
|---|
| 2043 |  | 
|---|
| 2044 | tempa = | 
|---|
| 2045 | xrealloc(ad->afhead, sizeof(ALLFILES) * ad->affiles, pszSrcFile, | 
|---|
| 2046 | __LINE__); | 
|---|
| 2047 | if (tempa) { | 
|---|
| 2048 | ad->afhead = tempa; | 
|---|
| 2049 | ad->afalloc = ad->affiles; | 
|---|
| 2050 | } | 
|---|
| 2051 | templ = | 
|---|
| 2052 | xrealloc(ad->afindex, sizeof(ALLFILES *) * ad->affiles, pszSrcFile, | 
|---|
| 2053 | __LINE__); | 
|---|
| 2054 | if (templ) | 
|---|
| 2055 | ad->afindex = templ; | 
|---|
| 2056 | DosPostEventSem(CompactSem); | 
|---|
| 2057 | } | 
|---|
| 2058 |  | 
|---|
| 2059 | if (!ad->stopflag) { | 
|---|
| 2060 | PostMsg(hwnd, UM_RESCAN, MPFROMLONG(1), MPVOID); | 
|---|
| 2061 | ReSort(hwnd); | 
|---|
| 2062 | } | 
|---|
| 2063 | DosReleaseMutexSem(ad->hmtxScan); | 
|---|
| 2064 | } | 
|---|
| 2065 | if (hmq2) { | 
|---|
| 2066 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID); | 
|---|
| 2067 | WinDestroyMsgQueue(hmq2); | 
|---|
| 2068 | } | 
|---|
| 2069 | if (hab2) { | 
|---|
| 2070 | DecrThreadUsage(); | 
|---|
| 2071 | WinTerminate(hab2); | 
|---|
| 2072 | } | 
|---|
| 2073 | } | 
|---|
| 2074 |  | 
|---|
| 2075 | MRESULT EXPENTRY AFDrvsWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 2076 | { | 
|---|
| 2077 | switch (msg) { | 
|---|
| 2078 | case WM_INITDLG: | 
|---|
| 2079 | if (mp2) { | 
|---|
| 2080 |  | 
|---|
| 2081 | ULONG ulDriveNum, ulDriveMap, x; | 
|---|
| 2082 | CHAR startname[] = " :"; | 
|---|
| 2083 | SHORT sSelect; | 
|---|
| 2084 | ALLDATA *ad; | 
|---|
| 2085 |  | 
|---|
| 2086 | ad = (ALLDATA *) mp2; | 
|---|
| 2087 | WinSetWindowPtr(hwnd, QWL_USER, mp2); | 
|---|
| 2088 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 2089 | if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) { | 
|---|
| 2090 | for (x = 2; x < 26 && !ad->stopflag; x++) { | 
|---|
| 2091 | if (!(driveflags[x] & (DRIVE_IGNORE | DRIVE_INVALID))) { | 
|---|
| 2092 | if (ulDriveMap & (1 << x)) { | 
|---|
| 2093 | *startname = (CHAR) (x + 'A'); | 
|---|
| 2094 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, DRVS_LISTBOX, | 
|---|
| 2095 | LM_INSERTITEM, | 
|---|
| 2096 | MPFROM2SHORT(LIT_END, 0), | 
|---|
| 2097 | MPFROMP(startname)); | 
|---|
| 2098 | if (sSelect >= 0 && ad->abDrvFlags[x]) | 
|---|
| 2099 | WinSendDlgItemMsg(hwnd, DRVS_LISTBOX, LM_SELECTITEM, | 
|---|
| 2100 | MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE)); | 
|---|
| 2101 | } | 
|---|
| 2102 | } | 
|---|
| 2103 | } | 
|---|
| 2104 | } | 
|---|
| 2105 | } | 
|---|
| 2106 | else | 
|---|
| 2107 | WinDismissDlg(hwnd, 0); | 
|---|
| 2108 | break; | 
|---|
| 2109 |  | 
|---|
| 2110 | case WM_CONTROL: | 
|---|
| 2111 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 2112 | case DRVS_LISTBOX: | 
|---|
| 2113 | switch (SHORT2FROMMP(mp1)) { | 
|---|
| 2114 | case LN_ENTER: | 
|---|
| 2115 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID); | 
|---|
| 2116 | break; | 
|---|
| 2117 | } | 
|---|
| 2118 | break; | 
|---|
| 2119 | } | 
|---|
| 2120 | return 0; | 
|---|
| 2121 |  | 
|---|
| 2122 | case WM_COMMAND: | 
|---|
| 2123 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 2124 | case DID_OK: | 
|---|
| 2125 | { | 
|---|
| 2126 | INT x; | 
|---|
| 2127 | SHORT sSelect; | 
|---|
| 2128 | CHAR filename[3]; | 
|---|
| 2129 | ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 2130 |  | 
|---|
| 2131 | memset(ad->abDrvFlags, 0, sizeof(ad->abDrvFlags)); | 
|---|
| 2132 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, DRVS_LISTBOX, | 
|---|
| 2133 | LM_QUERYSELECTION, | 
|---|
| 2134 | MPFROM2SHORT(LIT_FIRST, 0), | 
|---|
| 2135 | MPVOID); | 
|---|
| 2136 | while (sSelect >= 0) { | 
|---|
| 2137 | *filename = 0; | 
|---|
| 2138 | if (WinSendDlgItemMsg(hwnd, DRVS_LISTBOX, LM_QUERYITEMTEXT, | 
|---|
| 2139 | MPFROM2SHORT(sSelect, 2), | 
|---|
| 2140 | MPFROMP(filename)) && *filename) | 
|---|
| 2141 | ad->abDrvFlags[*filename - 'A'] = 1; | 
|---|
| 2142 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, DRVS_LISTBOX, | 
|---|
| 2143 | LM_QUERYSELECTION, | 
|---|
| 2144 | MPFROM2SHORT(sSelect, 0), | 
|---|
| 2145 | MPVOID); | 
|---|
| 2146 | } | 
|---|
| 2147 | for (x = 2; x < 26; x++) { | 
|---|
| 2148 | if (ad->abDrvFlags[x]) { | 
|---|
| 2149 | WinDismissDlg(hwnd, 1); | 
|---|
| 2150 | return 0; | 
|---|
| 2151 | } | 
|---|
| 2152 | } | 
|---|
| 2153 | } | 
|---|
| 2154 | WinDismissDlg(hwnd, 0); | 
|---|
| 2155 | break; | 
|---|
| 2156 |  | 
|---|
| 2157 | case IDM_HELP: | 
|---|
| 2158 | if (hwndHelp) | 
|---|
| 2159 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 2160 | MPFROM2SHORT(HELP_DRVSWND, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 2161 | break; | 
|---|
| 2162 |  | 
|---|
| 2163 | case DID_CANCEL: | 
|---|
| 2164 | WinDismissDlg(hwnd, 0); | 
|---|
| 2165 | break; | 
|---|
| 2166 | } | 
|---|
| 2167 | return 0; | 
|---|
| 2168 | } | 
|---|
| 2169 | return WinDefDlgProc(hwnd, msg, mp1, mp2); | 
|---|
| 2170 | } | 
|---|
| 2171 |  | 
|---|
| 2172 | static HPS InitWindow(HWND hwnd) | 
|---|
| 2173 | { | 
|---|
| 2174 | ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 2175 | HPS hps = (HPS) 0; | 
|---|
| 2176 | SIZEL sizel; | 
|---|
| 2177 | FONTMETRICS FontMetrics; | 
|---|
| 2178 |  | 
|---|
| 2179 | if (ad) { | 
|---|
| 2180 | sizel.cx = sizel.cy = 0; | 
|---|
| 2181 | hps = GpiCreatePS(WinQueryAnchorBlock(hwnd), WinOpenWindowDC(hwnd), | 
|---|
| 2182 | (PSIZEL) & sizel, PU_PELS | GPIF_DEFAULT | GPIT_MICRO | | 
|---|
| 2183 | GPIA_ASSOC); | 
|---|
| 2184 | if (hps) { | 
|---|
| 2185 | GpiSetCp(hps, (ULONG) ad->fattrs.usCodePage); | 
|---|
| 2186 | GpiCreateLogFont(hps, NULL, FIXED_FONT_LCID, &ad->fattrs); | 
|---|
| 2187 | GpiSetCharSet(hps, FIXED_FONT_LCID); | 
|---|
| 2188 | GpiQueryFontMetrics(hps, sizeof(FontMetrics), &FontMetrics); | 
|---|
| 2189 | ad->fattrs.lAveCharWidth = FontMetrics.lAveCharWidth; | 
|---|
| 2190 | ad->fattrs.lMaxBaselineExt = FontMetrics.lMaxBaselineExt; | 
|---|
| 2191 | ad->lMaxAscender = max(FontMetrics.lMaxAscender, 0); | 
|---|
| 2192 | ad->lMaxDescender = max(FontMetrics.lMaxDescender, 0); | 
|---|
| 2193 | ad->lMaxHeight = ad->lMaxDescender + ad->lMaxAscender; | 
|---|
| 2194 | if (ad->fattrs.usCodePage != FontMetrics.usCodePage) { | 
|---|
| 2195 | ad->fattrs.usCodePage = FontMetrics.usCodePage; | 
|---|
| 2196 | Codepage = ad->fattrs.usCodePage; | 
|---|
| 2197 | PrfWriteProfileData(fmprof, | 
|---|
| 2198 | appname, | 
|---|
| 2199 | "Seeall.Codepage", | 
|---|
| 2200 | &ad->fattrs.usCodePage, sizeof(USHORT)); | 
|---|
| 2201 | } | 
|---|
| 2202 | else if (ad->fattrs.usCodePage) { | 
|---|
| 2203 |  | 
|---|
| 2204 | HMQ hmq; | 
|---|
| 2205 | ULONG cps[50], len, x; | 
|---|
| 2206 |  | 
|---|
| 2207 | if (!DosQueryCp(sizeof(cps), cps, &len)) { | 
|---|
| 2208 | for (x = 0; x < len / sizeof(ULONG); x++) { | 
|---|
| 2209 | if (cps[x] == (ULONG) ad->fattrs.usCodePage) { | 
|---|
| 2210 | hmq = WinQueryWindowULong(hwnd, QWL_HMQ); | 
|---|
| 2211 | WinSetCp(hmq, ad->fattrs.usCodePage); | 
|---|
| 2212 | break; | 
|---|
| 2213 | } | 
|---|
| 2214 | } | 
|---|
| 2215 | } | 
|---|
| 2216 | DosSetProcessCp((ULONG) ad->fattrs.usCodePage); | 
|---|
| 2217 | } | 
|---|
| 2218 | GpiSetBackMix(hps, BM_OVERPAINT); | 
|---|
| 2219 | } | 
|---|
| 2220 | } | 
|---|
| 2221 | return (hps); | 
|---|
| 2222 | } | 
|---|
| 2223 |  | 
|---|
| 2224 | static VOID PaintLine(HWND hwnd, HPS hps, ULONG whichfile, ULONG topfile, | 
|---|
| 2225 | RECTL * Rectl) | 
|---|
| 2226 | { | 
|---|
| 2227 | ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 2228 | POINTL ptl; | 
|---|
| 2229 | CHAR szBuff[CCHMAXPATH + 80], szCmmaFmtFileSize[81]; | 
|---|
| 2230 | ULONG len, y; | 
|---|
| 2231 |  | 
|---|
| 2232 | y = (ad->invertsort) ? (ad->afifiles - 1) - whichfile : whichfile; | 
|---|
| 2233 | ptl.y = (Rectl->yTop - | 
|---|
| 2234 | (ad->lMaxHeight * (((whichfile + 1) - topfile) + 1))); | 
|---|
| 2235 | ptl.x = ad->horzscroll; | 
|---|
| 2236 | if (ptl.y < Rectl->yBottom || ptl.y > Rectl->yTop || y > ad->afifiles) | 
|---|
| 2237 | return; | 
|---|
| 2238 | GpiSetBackMix(hps, BM_OVERPAINT); | 
|---|
| 2239 | if (ad->afindex[y]->flags & AF_SELECTED) { | 
|---|
| 2240 | GpiSetColor(hps, standardcolors[Colors[COLORS_SELECTEDNORMALFORE]]); | 
|---|
| 2241 | GpiSetBackColor(hps, (whichfile == ad->cursored - 1) ? | 
|---|
| 2242 | standardcolors[Colors[COLORS_CURSOREDSELECTEDBACK]] : | 
|---|
| 2243 | standardcolors[Colors[COLORS_SELECTEDBACK]]); | 
|---|
| 2244 | } | 
|---|
| 2245 | else { | 
|---|
| 2246 | GpiSetColor(hps, | 
|---|
| 2247 | ((ad->afindex[y]->attrFile & (FILE_SYSTEM | FILE_HIDDEN)) != | 
|---|
| 2248 | 0) ? standardcolors[Colors[COLORS_SYSTEMFORE]] : ((ad-> | 
|---|
| 2249 | afindex | 
|---|
| 2250 | [y]-> | 
|---|
| 2251 | attrFile & | 
|---|
| 2252 | FILE_READONLY) | 
|---|
| 2253 | != | 
|---|
| 2254 | 0) ? | 
|---|
| 2255 | standardcolors[Colors[COLORS_READONLYFORE]] : | 
|---|
| 2256 | standardcolors[Colors[COLORS_NORMALFORE]]); | 
|---|
| 2257 | GpiSetBackColor(hps, | 
|---|
| 2258 | (whichfile == | 
|---|
| 2259 | ad->cursored - | 
|---|
| 2260 | 1) ? standardcolors[Colors[COLORS_CURSOREDNORMALBACK]] : | 
|---|
| 2261 | standardcolors[Colors[COLORS_NORMALBACK]]); | 
|---|
| 2262 | } | 
|---|
| 2263 | CommaFmtULL(szCmmaFmtFileSize, | 
|---|
| 2264 | sizeof(szCmmaFmtFileSize), ad->afindex[y]->cbFile, ' '); | 
|---|
| 2265 | len = sprintf(szBuff, | 
|---|
| 2266 | "%c%-*.*s  %-12s  %c%c%c%c%c  %04u/%02u/%02u %02u:%02u:%02u ", | 
|---|
| 2267 | whichfile == ad->cursored - 1 ? '>' : ' ', | 
|---|
| 2268 | ad->fullnames ? ad->longestw : ad->longest, | 
|---|
| 2269 | ad->fullnames ? ad->longestw : ad->longest, | 
|---|
| 2270 | ad->fullnames ? ad->afindex[y]->fullname : | 
|---|
| 2271 | ad->afindex[y]->filename, | 
|---|
| 2272 | szCmmaFmtFileSize, | 
|---|
| 2273 | "-A"[((ad->afindex[y]->attrFile & FILE_ARCHIVED) != 0)], | 
|---|
| 2274 | "-R"[((ad->afindex[y]->attrFile & FILE_READONLY) != 0)], | 
|---|
| 2275 | "-H"[((ad->afindex[y]->attrFile & FILE_HIDDEN) != 0)], | 
|---|
| 2276 | "-S"[((ad->afindex[y]->attrFile & FILE_SYSTEM) != 0)], | 
|---|
| 2277 | "-D"[((ad->afindex[y]->attrFile & FILE_DIRECTORY) != 0)], | 
|---|
| 2278 | ad->afindex[y]->date.year + 1980, | 
|---|
| 2279 | ad->afindex[y]->date.month, | 
|---|
| 2280 | ad->afindex[y]->date.day, | 
|---|
| 2281 | ad->afindex[y]->time.hours, | 
|---|
| 2282 | ad->afindex[y]->time.minutes, | 
|---|
| 2283 | ad->afindex[y]->time.twosecs * 2); | 
|---|
| 2284 | GpiCharStringAt(hps, &ptl, len, szBuff); | 
|---|
| 2285 | GpiQueryCurrentPosition(hps, &ptl); | 
|---|
| 2286 | if (ptl.x + abs(ad->horzscroll) > ad->maxx) { | 
|---|
| 2287 | ad->maxx = ptl.x + abs(ad->horzscroll); | 
|---|
| 2288 | WinSendMsg(ad->hhscroll, SBM_SETTHUMBSIZE, | 
|---|
| 2289 | MPFROM2SHORT((SHORT) Rectl->xRight, (SHORT) ad->maxx), MPVOID); | 
|---|
| 2290 | } | 
|---|
| 2291 | } | 
|---|
| 2292 |  | 
|---|
| 2293 | MRESULT EXPENTRY SeeStatusProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 2294 | { | 
|---|
| 2295 | switch (msg) { | 
|---|
| 2296 | case WM_CREATE: | 
|---|
| 2297 | return CommonTextProc(hwnd, msg, mp1, mp2); | 
|---|
| 2298 |  | 
|---|
| 2299 | case WM_SETFOCUS: | 
|---|
| 2300 | if (mp2) | 
|---|
| 2301 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID); | 
|---|
| 2302 | break; | 
|---|
| 2303 |  | 
|---|
| 2304 | case WM_PAINT: | 
|---|
| 2305 | { | 
|---|
| 2306 | SWP swp; | 
|---|
| 2307 | POINTL ptl; | 
|---|
| 2308 | HPS hps; | 
|---|
| 2309 |  | 
|---|
| 2310 | PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE); | 
|---|
| 2311 | hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 2312 | if (hps) { | 
|---|
| 2313 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 2314 | ptl.x = swp.x - 1; | 
|---|
| 2315 | ptl.y = swp.y + swp.cy + 2; | 
|---|
| 2316 | GpiMove(hps, &ptl); | 
|---|
| 2317 | GpiSetColor(hps, CLR_WHITE); | 
|---|
| 2318 | ptl.x = swp.x + swp.cx; | 
|---|
| 2319 | GpiLine(hps, &ptl); | 
|---|
| 2320 | WinReleasePS(hps); | 
|---|
| 2321 | } | 
|---|
| 2322 | } | 
|---|
| 2323 | break; | 
|---|
| 2324 |  | 
|---|
| 2325 | case UM_FOCUSME: | 
|---|
| 2326 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 2327 | FID_CLIENT)); | 
|---|
| 2328 | return 0; | 
|---|
| 2329 | } | 
|---|
| 2330 | return PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 2331 | } | 
|---|
| 2332 |  | 
|---|
| 2333 | MRESULT EXPENTRY SeeFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 2334 | { | 
|---|
| 2335 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 2336 |  | 
|---|
| 2337 | switch (msg) { | 
|---|
| 2338 | case WM_BUTTON1UP: | 
|---|
| 2339 | case WM_BUTTON2UP: | 
|---|
| 2340 | case WM_BUTTON3UP: | 
|---|
| 2341 | case WM_MOUSEMOVE: | 
|---|
| 2342 | case WM_CHORD: | 
|---|
| 2343 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 2344 | break; | 
|---|
| 2345 |  | 
|---|
| 2346 | case WM_CHAR: | 
|---|
| 2347 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 2348 | break; | 
|---|
| 2349 |  | 
|---|
| 2350 | case WM_CALCFRAMERECT: | 
|---|
| 2351 | { | 
|---|
| 2352 | MRESULT mr; | 
|---|
| 2353 | PRECTL prectl; | 
|---|
| 2354 |  | 
|---|
| 2355 | mr = oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 2356 |  | 
|---|
| 2357 | /* | 
|---|
| 2358 | * Calculate the position of the client rectangle. | 
|---|
| 2359 | * Otherwise,  we'll see a lot of redraw when we move the | 
|---|
| 2360 | * client during WM_FORMATFRAME. | 
|---|
| 2361 | */ | 
|---|
| 2362 |  | 
|---|
| 2363 | if (mr && mp2) { | 
|---|
| 2364 | prectl = (PRECTL) mp1; | 
|---|
| 2365 | prectl->yBottom += 22; | 
|---|
| 2366 | prectl->yTop -= 24; | 
|---|
| 2367 | } | 
|---|
| 2368 | return mr; | 
|---|
| 2369 | } | 
|---|
| 2370 |  | 
|---|
| 2371 | case WM_FORMATFRAME: | 
|---|
| 2372 | { | 
|---|
| 2373 | SHORT sCount; | 
|---|
| 2374 | PSWP pswp, pswpClient, pswpNew; | 
|---|
| 2375 |  | 
|---|
| 2376 | sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 2377 |  | 
|---|
| 2378 | /* | 
|---|
| 2379 | * Reformat the frame to "squeeze" the client | 
|---|
| 2380 | * and make room for status window sibling beneath | 
|---|
| 2381 | */ | 
|---|
| 2382 |  | 
|---|
| 2383 | pswp = (PSWP) mp1; | 
|---|
| 2384 | { | 
|---|
| 2385 | SHORT x; | 
|---|
| 2386 |  | 
|---|
| 2387 | for (x = 0; x < sCount; x++) { | 
|---|
| 2388 | if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) { | 
|---|
| 2389 | pswpClient = pswp; | 
|---|
| 2390 | break; | 
|---|
| 2391 | } | 
|---|
| 2392 | pswp++; | 
|---|
| 2393 | } | 
|---|
| 2394 | } | 
|---|
| 2395 | pswpNew = (PSWP) mp1 + sCount; | 
|---|
| 2396 | *pswpNew = *pswpClient; | 
|---|
| 2397 | pswpNew->hwnd = WinWindowFromID(hwnd, SEEALL_STATUS); | 
|---|
| 2398 | pswpNew->x = pswpClient->x + 2; | 
|---|
| 2399 | pswpNew->y = pswpClient->y + 2; | 
|---|
| 2400 | pswpNew->cx = pswpClient->cx - 3; | 
|---|
| 2401 | pswpNew->cy = 20; | 
|---|
| 2402 | pswpClient->y = pswpNew->y + pswpNew->cy + 3; | 
|---|
| 2403 | pswpClient->cy = (pswpClient->cy - pswpNew->cy) - 5; | 
|---|
| 2404 | sCount++; | 
|---|
| 2405 | return MRFROMSHORT(sCount); | 
|---|
| 2406 | } | 
|---|
| 2407 |  | 
|---|
| 2408 | case WM_QUERYFRAMECTLCOUNT: | 
|---|
| 2409 | { | 
|---|
| 2410 | SHORT sCount; | 
|---|
| 2411 |  | 
|---|
| 2412 | sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 2413 | sCount++; | 
|---|
| 2414 | return MRFROMSHORT(sCount); | 
|---|
| 2415 | } | 
|---|
| 2416 | } | 
|---|
| 2417 | return oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 2418 | } | 
|---|
| 2419 |  | 
|---|
| 2420 | MRESULT EXPENTRY SeeAllWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 2421 | { | 
|---|
| 2422 | ALLDATA *pAD = WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 2423 |  | 
|---|
| 2424 | switch (msg) { | 
|---|
| 2425 | case WM_CREATE: | 
|---|
| 2426 | // fprintf(stderr,"Seeall: WM_CREATE\n"); | 
|---|
| 2427 | WinSetWindowPtr(hwnd, QWL_USER, NULL); | 
|---|
| 2428 | pAD = xmallocz(sizeof(ALLDATA), pszSrcFile, __LINE__); | 
|---|
| 2429 | if (pAD) { | 
|---|
| 2430 | HWND hwndFrame; | 
|---|
| 2431 |  | 
|---|
| 2432 | pAD->size = sizeof(ALLDATA); | 
|---|
| 2433 | hwndFrame = WinQueryWindow(hwnd, QW_PARENT); | 
|---|
| 2434 | pAD->hwndFrame = hwndFrame; | 
|---|
| 2435 | pAD->mask.attrFile = FILE_READONLY | FILE_HIDDEN | | 
|---|
| 2436 | FILE_SYSTEM | FILE_ARCHIVED; | 
|---|
| 2437 | pAD->mask.fNoDirs = TRUE; | 
|---|
| 2438 | *(pAD->mask.prompt) = 0; | 
|---|
| 2439 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) pAD); | 
|---|
| 2440 | pAD->pfnCompare = comparenames; | 
|---|
| 2441 | if (Firsttime) { | 
|---|
| 2442 |  | 
|---|
| 2443 | ULONG size; | 
|---|
| 2444 |  | 
|---|
| 2445 | size = sizeof(USHORT); | 
|---|
| 2446 | PrfQueryProfileData(fmprof, | 
|---|
| 2447 | appname, | 
|---|
| 2448 | "Seeall.Codepage", (PVOID) & Codepage, &size); | 
|---|
| 2449 | size = sizeof(BOOL); | 
|---|
| 2450 | PrfQueryProfileData(fmprof, | 
|---|
| 2451 | appname, | 
|---|
| 2452 | "Seeall.Fullnames", (PVOID) & Fullnames, &size); | 
|---|
| 2453 | size = sizeof(USHORT); | 
|---|
| 2454 | PrfQueryProfileData(fmprof, | 
|---|
| 2455 | appname, | 
|---|
| 2456 | "Seeall.Sort", (PVOID) & SortType, &size); | 
|---|
| 2457 | size = sizeof(BOOL); | 
|---|
| 2458 | PrfQueryProfileData(fmprof, | 
|---|
| 2459 | appname, | 
|---|
| 2460 | "Seeall.SortReverse", | 
|---|
| 2461 | (PVOID) & SortReverse, &size); | 
|---|
| 2462 | memset(&Fattrs, 0, sizeof(Fattrs)); | 
|---|
| 2463 | size = sizeof(Fattrs); | 
|---|
| 2464 | Fattrs.usRecordLength = sizeof(Fattrs); | 
|---|
| 2465 | Fattrs.lMaxBaselineExt = 16; | 
|---|
| 2466 | Fattrs.lAveCharWidth = 8; | 
|---|
| 2467 | Fattrs.usCodePage = Codepage; | 
|---|
| 2468 | strcpy(Fattrs.szFacename, GetPString(IDS_SYSMONOTEXT)); | 
|---|
| 2469 | PrfQueryProfileData(fmprof, | 
|---|
| 2470 | appname, | 
|---|
| 2471 | "Seeall.Fattrs", (PVOID) & Fattrs, &size); | 
|---|
| 2472 | size = sizeof(LONG) * COLORS_MAX; | 
|---|
| 2473 | PrfQueryProfileData(fmprof, | 
|---|
| 2474 | appname, "Seeall.Colors", (PVOID) Colors, &size); | 
|---|
| 2475 | Firsttime = FALSE; | 
|---|
| 2476 | } | 
|---|
| 2477 | switch (SortType) { | 
|---|
| 2478 | case IDM_SORTEASIZE: | 
|---|
| 2479 | pAD->pfnCompare = (PFNSORT) NULL; | 
|---|
| 2480 | break; | 
|---|
| 2481 | case IDM_SORTNAME: | 
|---|
| 2482 | pAD->pfnCompare = comparefullnames; | 
|---|
| 2483 | break; | 
|---|
| 2484 | case IDM_SORTFILENAME: | 
|---|
| 2485 | pAD->pfnCompare = comparenames; | 
|---|
| 2486 | break; | 
|---|
| 2487 | case IDM_SORTSIZE: | 
|---|
| 2488 | pAD->pfnCompare = comparesizes; | 
|---|
| 2489 | break; | 
|---|
| 2490 | case IDM_SORTLWDATE: | 
|---|
| 2491 | pAD->pfnCompare = comparedates; | 
|---|
| 2492 | break; | 
|---|
| 2493 | case IDM_SORTFIRST: | 
|---|
| 2494 | pAD->pfnCompare = compareexts; | 
|---|
| 2495 | break; | 
|---|
| 2496 | } | 
|---|
| 2497 | pAD->invertsort = SortReverse; | 
|---|
| 2498 | pAD->fattrs = Fattrs; | 
|---|
| 2499 | pAD->fullnames = Fullnames; | 
|---|
| 2500 | pAD->stopflag = 0; | 
|---|
| 2501 | pAD->cursored = pAD->topfile = 1; | 
|---|
| 2502 | pAD->fattrs.usCodePage = Codepage; | 
|---|
| 2503 | memcpy(pAD->aulColors, Colors, sizeof(LONG) * COLORS_MAX); | 
|---|
| 2504 | pAD->hwndMenu = WinWindowFromID(hwndFrame, FID_MENU); | 
|---|
| 2505 | SetConditionalCascade(pAD->hwndMenu, IDM_DELETESUBMENU, | 
|---|
| 2506 | (fDefaultDeletePerm) ? | 
|---|
| 2507 | IDM_PERMDELETE : IDM_DELETE); | 
|---|
| 2508 | SetConditionalCascade(pAD->hwndMenu, IDM_MOVEMENU, IDM_MOVE); | 
|---|
| 2509 | SetConditionalCascade(pAD->hwndMenu, IDM_COPYMENU, IDM_COPY); | 
|---|
| 2510 | SetConditionalCascade(pAD->hwndMenu, IDM_OPENSUBMENU, IDM_OPENDEFAULT); | 
|---|
| 2511 | SetConditionalCascade(pAD->hwndMenu, IDM_OBJECTSUBMENU, IDM_SHADOW); | 
|---|
| 2512 | if (fWorkPlace) { | 
|---|
| 2513 | WinSendMsg(pAD->hwndMenu, MM_DELETEITEM, | 
|---|
| 2514 | MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID); | 
|---|
| 2515 | WinSendMsg(pAD->hwndMenu, MM_DELETEITEM, | 
|---|
| 2516 | MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID); | 
|---|
| 2517 | } | 
|---|
| 2518 | pAD->hwndClient = hwnd; | 
|---|
| 2519 | pAD->hps = InitWindow(hwnd); | 
|---|
| 2520 | pAD->hvscroll = WinWindowFromID(hwndFrame, FID_VERTSCROLL); | 
|---|
| 2521 | pAD->hhscroll = WinWindowFromID(hwndFrame, FID_HORZSCROLL); | 
|---|
| 2522 | pAD->multiplier = 1; | 
|---|
| 2523 | if (_beginthread(MakeSeeObjWinThread, NULL, 122880, (PVOID) pAD) == -1) | 
|---|
| 2524 | Runtime_Error(pszSrcFile, __LINE__, | 
|---|
| 2525 | GetPString(IDS_COULDNTSTARTTHREADTEXT)); | 
|---|
| 2526 | else { | 
|---|
| 2527 | if (!DosCreateMutexSem(NULL, &pAD->hmtxScan, 0, FALSE)) { | 
|---|
| 2528 | pAD->hwndStatus = WinCreateWindow(hwndFrame, | 
|---|
| 2529 | WC_SEESTATUS, | 
|---|
| 2530 | NullStr, | 
|---|
| 2531 | WS_VISIBLE | SS_TEXT | | 
|---|
| 2532 | DT_LEFT | DT_VCENTER, | 
|---|
| 2533 | 0, | 
|---|
| 2534 | 0, | 
|---|
| 2535 | 0, | 
|---|
| 2536 | 0, | 
|---|
| 2537 | hwndFrame, | 
|---|
| 2538 | HWND_TOP, | 
|---|
| 2539 | SEEALL_STATUS, NULL, NULL); | 
|---|
| 2540 | if (!pAD->hwndStatus) | 
|---|
| 2541 | Win_Error2(hwndFrame, hwnd, pszSrcFile, __LINE__, | 
|---|
| 2542 | IDS_WINCREATEWINDOW); | 
|---|
| 2543 | else { | 
|---|
| 2544 | PFNWP oldproc; | 
|---|
| 2545 |  | 
|---|
| 2546 | oldproc = WinSubclassWindow(hwndFrame, SeeFrameWndProc); | 
|---|
| 2547 | WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc); | 
|---|
| 2548 | } | 
|---|
| 2549 | break; | 
|---|
| 2550 | } | 
|---|
| 2551 | } | 
|---|
| 2552 | } | 
|---|
| 2553 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 2554 | break; | 
|---|
| 2555 |  | 
|---|
| 2556 | case UM_SETUP5: | 
|---|
| 2557 | // fprintf(stderr,"Seeall: UM_SETUP5\n"); | 
|---|
| 2558 | if (pAD) { | 
|---|
| 2559 | if (mp1 && *((CHAR *) mp1)) | 
|---|
| 2560 | strcpy(pAD->szFindPath, (CHAR *) mp1); | 
|---|
| 2561 | else { | 
|---|
| 2562 | if (!WinDlgBox(HWND_DESKTOP, hwnd, AFDrvsWndProc, | 
|---|
| 2563 | FM3ModHandle, DRVS_FRAME, (PVOID) pAD)) { | 
|---|
| 2564 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 2565 | return 0; | 
|---|
| 2566 | } | 
|---|
| 2567 | } | 
|---|
| 2568 | if (_beginthread(FindAllThread, NULL, 524288, (PVOID) hwnd) == -1) { | 
|---|
| 2569 | Runtime_Error(pszSrcFile, __LINE__, | 
|---|
| 2570 | GetPString(IDS_COULDNTSTARTTHREADTEXT)); | 
|---|
| 2571 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 2572 | } | 
|---|
| 2573 | else { | 
|---|
| 2574 | DosSleep(50);//05 Aug 07 GKY 100 | 
|---|
| 2575 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 2576 | PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 2577 | } | 
|---|
| 2578 | } | 
|---|
| 2579 | else | 
|---|
| 2580 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 2581 | return 0; | 
|---|
| 2582 |  | 
|---|
| 2583 | case UM_UPDATERECORDLIST: | 
|---|
| 2584 | if (mp1) { | 
|---|
| 2585 |  | 
|---|
| 2586 | APIRET rc; | 
|---|
| 2587 |  | 
|---|
| 2588 | rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN); | 
|---|
| 2589 | if (!rc) { | 
|---|
| 2590 | WinSetPointer(HWND_DESKTOP, hptrBusy); | 
|---|
| 2591 | if (UpdateList(hwnd, mp1)) { | 
|---|
| 2592 | FreeList(mp1); | 
|---|
| 2593 | RemoveDeleted(hwnd); | 
|---|
| 2594 | ReSort(hwnd); | 
|---|
| 2595 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 2596 | } | 
|---|
| 2597 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 2598 | WinSetPointer(HWND_DESKTOP, hptrArrow); | 
|---|
| 2599 | } | 
|---|
| 2600 | } | 
|---|
| 2601 | return 0; | 
|---|
| 2602 |  | 
|---|
| 2603 | case UM_SETUP2: | 
|---|
| 2604 | // fprintf(stderr,"Seeall: UM_SETUP2\n"); | 
|---|
| 2605 | if (pAD) { | 
|---|
| 2606 |  | 
|---|
| 2607 | CHAR s[256]; | 
|---|
| 2608 | BOOL once = FALSE; | 
|---|
| 2609 | ULONG x, ulDriveNum, ulDriveMap; | 
|---|
| 2610 |  | 
|---|
| 2611 | strcpy(s, GetPString(IDS_SEEALLTITLETEXT)); | 
|---|
| 2612 | if (!*pAD->szFindPath) { | 
|---|
| 2613 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 2614 | if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) { | 
|---|
| 2615 | for (x = 2; x < 26 && !pAD->stopflag; x++) { | 
|---|
| 2616 | if ((ulDriveMap & (1 << x)) && pAD->abDrvFlags[x]) { | 
|---|
| 2617 | sprintf(&s[strlen(s)], "%s%c:", (once) ? ", " : " (", x + 'A'); | 
|---|
| 2618 | once = TRUE; | 
|---|
| 2619 | } | 
|---|
| 2620 | } | 
|---|
| 2621 | if (once) | 
|---|
| 2622 | strcat(s, ")"); | 
|---|
| 2623 | } | 
|---|
| 2624 | } | 
|---|
| 2625 | else { | 
|---|
| 2626 | strcat(s, " ("); | 
|---|
| 2627 | strcat(s, pAD->szFindPath); | 
|---|
| 2628 | strcat(s, ")"); | 
|---|
| 2629 | } | 
|---|
| 2630 | WinSetWindowText(WinQueryWindow(hwnd, QW_PARENT), s); | 
|---|
| 2631 | } | 
|---|
| 2632 | return 0; | 
|---|
| 2633 |  | 
|---|
| 2634 | case UM_SETUP3: | 
|---|
| 2635 | // fprintf(stderr,"Seeall: UM_SETUP3\n"); | 
|---|
| 2636 | if (pAD) { | 
|---|
| 2637 | pAD->multiplier = pAD->afifiles / 32767; | 
|---|
| 2638 | if (pAD->multiplier * 32767 != pAD->afifiles) | 
|---|
| 2639 | pAD->multiplier++; | 
|---|
| 2640 | if (!pAD->multiplier) | 
|---|
| 2641 | pAD->multiplier++; | 
|---|
| 2642 | { | 
|---|
| 2643 | RECTL Rectl; | 
|---|
| 2644 | ULONG numlines; | 
|---|
| 2645 |  | 
|---|
| 2646 | WinQueryWindowRect(hwnd, &Rectl); | 
|---|
| 2647 | numlines = NumLines(&Rectl, pAD); | 
|---|
| 2648 | if (numlines) { | 
|---|
| 2649 | WinSendMsg(pAD->hhscroll, SBM_SETTHUMBSIZE, | 
|---|
| 2650 | MPFROM2SHORT((SHORT) Rectl.xRight, (SHORT) pAD->maxx), | 
|---|
| 2651 | MPVOID); | 
|---|
| 2652 | WinSendMsg(pAD->hvscroll, SBM_SETTHUMBSIZE, | 
|---|
| 2653 | MPFROM2SHORT((SHORT) numlines, | 
|---|
| 2654 | (SHORT) min(pAD->afifiles, 32767)), | 
|---|
| 2655 | MPFROM2SHORT(1, pAD->afifiles + 1)); | 
|---|
| 2656 | WinSendMsg(pAD->hhscroll, SBM_SETSCROLLBAR, | 
|---|
| 2657 | MPFROMSHORT((SHORT) abs(pAD->horzscroll)), | 
|---|
| 2658 | MPFROM2SHORT(0, (SHORT) (pAD->maxx - Rectl.xRight))); | 
|---|
| 2659 | WinSendMsg(pAD->hvscroll, SBM_SETSCROLLBAR, | 
|---|
| 2660 | MPFROMSHORT((SHORT) (pAD->topfile / pAD->multiplier)), | 
|---|
| 2661 | MPFROM2SHORT(1, | 
|---|
| 2662 | (SHORT) (pAD->afifiles / pAD->multiplier) - | 
|---|
| 2663 | (numlines - 1))); | 
|---|
| 2664 | if (pAD->afifiles - pAD->topfile < numlines) { | 
|---|
| 2665 | pAD->topfile = ((pAD->afifiles - pAD->topfile) - numlines); | 
|---|
| 2666 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 2667 | } | 
|---|
| 2668 | } | 
|---|
| 2669 | } | 
|---|
| 2670 | } | 
|---|
| 2671 | return 0; | 
|---|
| 2672 |  | 
|---|
| 2673 | case UM_SETUP4: | 
|---|
| 2674 | // fprintf(stderr,"Seeall: UM_SETUP4\n"); | 
|---|
| 2675 | if (pAD) | 
|---|
| 2676 | pAD->killme = TRUE; | 
|---|
| 2677 | else | 
|---|
| 2678 | PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); | 
|---|
| 2679 | return 0; | 
|---|
| 2680 |  | 
|---|
| 2681 | case UM_RESCAN: | 
|---|
| 2682 | // fprintf(stderr,"Seeall: UM_RESCAN\n"); | 
|---|
| 2683 | if (pAD && !pAD->stopflag) { | 
|---|
| 2684 | if (DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) { | 
|---|
| 2685 | CHAR s[CCHMAXPATH + 80], tm[34]; | 
|---|
| 2686 |  | 
|---|
| 2687 | if (mp1) { | 
|---|
| 2688 | strcpy(s, GetPString(IDS_SORTINGTEXT)); | 
|---|
| 2689 | if (pAD->afifiles) { | 
|---|
| 2690 | commafmt(tm, sizeof(tm), pAD->afifiles); | 
|---|
| 2691 | strcat(s, tm); | 
|---|
| 2692 | } | 
|---|
| 2693 | } | 
|---|
| 2694 | else { | 
|---|
| 2695 | strcpy(s, GetPString(IDS_WORKINGTEXT)); | 
|---|
| 2696 | if (pAD->affiles) { | 
|---|
| 2697 | commafmt(tm, sizeof(tm), pAD->affiles); | 
|---|
| 2698 | strcat(s, tm); | 
|---|
| 2699 | } | 
|---|
| 2700 | } | 
|---|
| 2701 | if (mp2) { | 
|---|
| 2702 | strcat(s, " "); | 
|---|
| 2703 | strcat(s, (CHAR *) mp2); | 
|---|
| 2704 | } | 
|---|
| 2705 | WinSetWindowText(pAD->hwndStatus, s); | 
|---|
| 2706 | } | 
|---|
| 2707 | else { | 
|---|
| 2708 | CHAR s[(CCHMAXPATH * 2) + 80], tm[34], ts[34], tb[34]; | 
|---|
| 2709 | ULONG y; | 
|---|
| 2710 |  | 
|---|
| 2711 | if (mp1) { | 
|---|
| 2712 | strcpy(s, GetPString(IDS_SORTINGTEXT)); | 
|---|
| 2713 | if (pAD->afifiles) { | 
|---|
| 2714 | commafmt(tm, sizeof(tm), pAD->afifiles); | 
|---|
| 2715 | strcat(s, tm); | 
|---|
| 2716 | } | 
|---|
| 2717 | if (mp2) { | 
|---|
| 2718 | strcat(s, " "); | 
|---|
| 2719 | strcat(s, (CHAR *) mp2); | 
|---|
| 2720 | } | 
|---|
| 2721 | } | 
|---|
| 2722 | else if (pAD->afifiles) { | 
|---|
| 2723 | y = (pAD->invertsort) ? (pAD->afifiles - 1) - (pAD->cursored - 1) : | 
|---|
| 2724 | pAD->cursored - 1; | 
|---|
| 2725 | commafmt(tm, sizeof(tm), pAD->afifiles); | 
|---|
| 2726 | commafmt(ts, sizeof(ts), pAD->selected); | 
|---|
| 2727 | CommaFmtULL(tb, sizeof(tb), pAD->ullSelectedBytes, ' '); | 
|---|
| 2728 | sprintf(s, | 
|---|
| 2729 | " %s %s%s%s  %s %s (%s)  %s %s", | 
|---|
| 2730 | tm, | 
|---|
| 2731 | GetPString(IDS_FILETEXT), | 
|---|
| 2732 | &"s"[pAD->afifiles == 1], | 
|---|
| 2733 | (*pAD->mask.szMask || | 
|---|
| 2734 | (pAD->mask.attrFile & (~FILE_DIRECTORY)) != | 
|---|
| 2735 | (ALLATTRS & (~FILE_DIRECTORY)) || | 
|---|
| 2736 | pAD->mask.antiattr) ? | 
|---|
| 2737 | GetPString(IDS_FILTEREDTEXT) : | 
|---|
| 2738 | NullStr, | 
|---|
| 2739 | ts, | 
|---|
| 2740 | GetPString(IDS_SELECTEDTEXT), | 
|---|
| 2741 | tb, GetPString(IDS_CURRTEXT), pAD->afindex[y]->fullname); | 
|---|
| 2742 | } | 
|---|
| 2743 | else | 
|---|
| 2744 | sprintf(s, | 
|---|
| 2745 | GetPString(IDS_NOFILESPSTEXT), | 
|---|
| 2746 | (*pAD->mask.szMask || | 
|---|
| 2747 | (pAD->mask.attrFile & (~FILE_DIRECTORY)) != | 
|---|
| 2748 | (ALLATTRS & (~FILE_DIRECTORY)) || | 
|---|
| 2749 | pAD->mask.antiattr) ? | 
|---|
| 2750 | GetPString(IDS_FILTEREDTEXT) : NullStr); | 
|---|
| 2751 | WinSetWindowText(pAD->hwndStatus, s); | 
|---|
| 2752 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 2753 | } | 
|---|
| 2754 | } | 
|---|
| 2755 | return 0; | 
|---|
| 2756 |  | 
|---|
| 2757 | case UM_SETUP: | 
|---|
| 2758 | // fprintf(stderr,"Seeall: UM_SETUP\n"); | 
|---|
| 2759 | if (pAD) { | 
|---|
| 2760 | WinSendMsg(pAD->hvscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1), MPVOID); | 
|---|
| 2761 | WinSendMsg(pAD->hhscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1), MPVOID); | 
|---|
| 2762 | WinSetActiveWindow(HWND_DESKTOP, WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 2763 | } | 
|---|
| 2764 | return 0; | 
|---|
| 2765 |  | 
|---|
| 2766 | case WM_CHAR: | 
|---|
| 2767 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 2768 | if (pAD && !(SHORT1FROMMP(mp1) & KC_KEYUP)) { | 
|---|
| 2769 |  | 
|---|
| 2770 | register ULONG x; | 
|---|
| 2771 | ULONG numlines, y, wascursored = pAD->cursored, thistime, len; | 
|---|
| 2772 | BOOL found = FALSE; | 
|---|
| 2773 | RECTL rcl; | 
|---|
| 2774 |  | 
|---|
| 2775 | WinQueryWindowRect(hwnd, &rcl); | 
|---|
| 2776 | numlines = NumLines(&rcl, pAD); | 
|---|
| 2777 | if (numlines) { | 
|---|
| 2778 | if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) { | 
|---|
| 2779 | pAD->lasttime = 0; | 
|---|
| 2780 | *pAD->szCommonName = 0; | 
|---|
| 2781 | switch (SHORT2FROMMP(mp2)) { | 
|---|
| 2782 | case VK_DELETE: | 
|---|
| 2783 | if ((shiftstate & KC_CTRL) == KC_CTRL) | 
|---|
| 2784 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), | 
|---|
| 2785 | MPVOID); | 
|---|
| 2786 | else if ((shiftstate & KC_SHIFT) == KC_SHIFT) | 
|---|
| 2787 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), | 
|---|
| 2788 | MPVOID); | 
|---|
| 2789 | else | 
|---|
| 2790 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID); | 
|---|
| 2791 | break; | 
|---|
| 2792 | case VK_LEFT: | 
|---|
| 2793 | WinSendMsg(hwnd, WM_HSCROLL, MPFROM2SHORT(FID_HORZSCROLL, 0), | 
|---|
| 2794 | MPFROM2SHORT(0, SB_LINELEFT)); | 
|---|
| 2795 | break; | 
|---|
| 2796 | case VK_RIGHT: | 
|---|
| 2797 | WinSendMsg(hwnd, WM_HSCROLL, MPFROM2SHORT(FID_HORZSCROLL, 0), | 
|---|
| 2798 | MPFROM2SHORT(0, SB_LINERIGHT)); | 
|---|
| 2799 | break; | 
|---|
| 2800 | case VK_PAGEUP: | 
|---|
| 2801 | WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0), | 
|---|
| 2802 | MPFROM2SHORT(0, SB_PAGEUP)); | 
|---|
| 2803 | break; | 
|---|
| 2804 | case VK_PAGEDOWN: | 
|---|
| 2805 | WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0), | 
|---|
| 2806 | MPFROM2SHORT(0, SB_PAGEDOWN)); | 
|---|
| 2807 | break; | 
|---|
| 2808 | case VK_UP: | 
|---|
| 2809 | if (pAD->cursored > 1) { | 
|---|
| 2810 | if (shiftstate & KC_SHIFT) | 
|---|
| 2811 | WinSendMsg(hwnd, WM_BUTTON1CLICK, | 
|---|
| 2812 | MPFROM2SHORT(pAD->fattrs.lAveCharWidth + 2, | 
|---|
| 2813 | ((rcl.yTop - (pAD->lMaxHeight * | 
|---|
| 2814 | ((pAD->cursored) - | 
|---|
| 2815 | pAD->topfile))) - | 
|---|
| 2816 | pAD->lMaxDescender) - 1), | 
|---|
| 2817 | MPFROM2SHORT(TRUE, 0)); | 
|---|
| 2818 | pAD->cursored--; | 
|---|
| 2819 | if (pAD->cursored < pAD->topfile) { | 
|---|
| 2820 | PaintLine(hwnd, pAD->hps, pAD->cursored, pAD->topfile, &rcl); | 
|---|
| 2821 | WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0), | 
|---|
| 2822 | MPFROM2SHORT(0, SB_LINEUP)); | 
|---|
| 2823 | } | 
|---|
| 2824 | else { | 
|---|
| 2825 | PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile, | 
|---|
| 2826 | &rcl); | 
|---|
| 2827 | PaintLine(hwnd, pAD->hps, pAD->cursored, pAD->topfile, &rcl); | 
|---|
| 2828 | } | 
|---|
| 2829 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 2830 | } | 
|---|
| 2831 | break; | 
|---|
| 2832 | case VK_DOWN: | 
|---|
| 2833 | if (pAD->cursored < pAD->afifiles | 
|---|
| 2834 | && pAD->cursored < pAD->topfile + numlines) { | 
|---|
| 2835 | if (shiftstate & KC_SHIFT) | 
|---|
| 2836 | WinSendMsg(hwnd, WM_BUTTON1CLICK, | 
|---|
| 2837 | MPFROM2SHORT(pAD->fattrs.lAveCharWidth + 2, | 
|---|
| 2838 | ((rcl.yTop - (pAD->lMaxHeight * | 
|---|
| 2839 | ((pAD->cursored) - | 
|---|
| 2840 | pAD->topfile))) - | 
|---|
| 2841 | pAD->lMaxDescender) - 1), | 
|---|
| 2842 | MPFROM2SHORT(TRUE, 0)); | 
|---|
| 2843 | pAD->cursored++; | 
|---|
| 2844 | if (pAD->cursored >= pAD->topfile + numlines) { | 
|---|
| 2845 | PaintLine(hwnd, pAD->hps, pAD->cursored - 2, pAD->topfile, | 
|---|
| 2846 | &rcl); | 
|---|
| 2847 | WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0), | 
|---|
| 2848 | MPFROM2SHORT(0, SB_LINEDOWN)); | 
|---|
| 2849 | } | 
|---|
| 2850 | else { | 
|---|
| 2851 | PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile, | 
|---|
| 2852 | &rcl); | 
|---|
| 2853 | PaintLine(hwnd, pAD->hps, pAD->cursored - 2, pAD->topfile, | 
|---|
| 2854 | &rcl); | 
|---|
| 2855 | } | 
|---|
| 2856 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 2857 | } | 
|---|
| 2858 | break; | 
|---|
| 2859 | case VK_END: | 
|---|
| 2860 | if ((shiftstate & KC_CTRL) || | 
|---|
| 2861 | pAD->cursored == (pAD->topfile - 1) + numlines) { | 
|---|
| 2862 | pAD->cursored = pAD->afifiles; | 
|---|
| 2863 | pAD->topfile = (pAD->afifiles + 1) - numlines; | 
|---|
| 2864 | if (pAD->topfile > pAD->afifiles) | 
|---|
| 2865 | pAD->topfile = 1; | 
|---|
| 2866 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 2867 | } | 
|---|
| 2868 | else { | 
|---|
| 2869 | pAD->cursored = (pAD->topfile - 1) + numlines; | 
|---|
| 2870 | if (pAD->cursored > pAD->afifiles) | 
|---|
| 2871 | pAD->cursored = pAD->afifiles; | 
|---|
| 2872 | PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile, | 
|---|
| 2873 | &rcl); | 
|---|
| 2874 | PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile, &rcl); | 
|---|
| 2875 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 2876 | } | 
|---|
| 2877 | break; | 
|---|
| 2878 | case VK_HOME: | 
|---|
| 2879 | if ((shiftstate & KC_CTRL) || pAD->cursored == pAD->topfile) { | 
|---|
| 2880 | pAD->topfile = 1; | 
|---|
| 2881 | pAD->cursored = 1; | 
|---|
| 2882 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 2883 | } | 
|---|
| 2884 | else { | 
|---|
| 2885 | pAD->cursored = pAD->topfile; | 
|---|
| 2886 | PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile, | 
|---|
| 2887 | &rcl); | 
|---|
| 2888 | PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile, &rcl); | 
|---|
| 2889 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 2890 | } | 
|---|
| 2891 | break; | 
|---|
| 2892 | case VK_SPACE: | 
|---|
| 2893 | WinSendMsg(hwnd, WM_BUTTON1CLICK, | 
|---|
| 2894 | MPFROM2SHORT(pAD->fattrs.lAveCharWidth + 2, | 
|---|
| 2895 | ((rcl.yTop - (pAD->lMaxHeight * | 
|---|
| 2896 | ((pAD->cursored) - | 
|---|
| 2897 | pAD->topfile))) - | 
|---|
| 2898 | pAD->lMaxDescender) - 1), | 
|---|
| 2899 | MPFROM2SHORT(TRUE, 0)); | 
|---|
| 2900 | break; | 
|---|
| 2901 | case VK_NEWLINE: | 
|---|
| 2902 | case VK_ENTER: | 
|---|
| 2903 | WinSendMsg(hwnd, WM_BUTTON1DBLCLK, | 
|---|
| 2904 | MPFROM2SHORT(pAD->fattrs.lAveCharWidth + 2, | 
|---|
| 2905 | ((rcl.yTop - (pAD->lMaxHeight * | 
|---|
| 2906 | ((pAD->cursored) - | 
|---|
| 2907 | pAD->topfile))) - | 
|---|
| 2908 | pAD->lMaxDescender) - 1), MPFROM2SHORT(0, | 
|---|
| 2909 | 0)); | 
|---|
| 2910 | break; | 
|---|
| 2911 | } | 
|---|
| 2912 | } | 
|---|
| 2913 | else if (SHORT1FROMMP(mp1) & KC_CHAR) { | 
|---|
| 2914 | switch (SHORT1FROMMP(mp2)) { | 
|---|
| 2915 | case '\x1b': | 
|---|
| 2916 | case '\r': | 
|---|
| 2917 | case '\n': | 
|---|
| 2918 | WinSendMsg(hwnd, WM_BUTTON1DBLCLK, | 
|---|
| 2919 | MPFROM2SHORT(pAD->fattrs.lAveCharWidth + 2, | 
|---|
| 2920 | (rcl.yTop - (pAD->lMaxHeight * | 
|---|
| 2921 | ((pAD->cursored) - | 
|---|
| 2922 | pAD->topfile))) - 1), | 
|---|
| 2923 | MPFROM2SHORT(0, 0)); | 
|---|
| 2924 | pAD->lasttime = 0; | 
|---|
| 2925 | *pAD->szCommonName = 0; | 
|---|
| 2926 | break; | 
|---|
| 2927 | default: | 
|---|
| 2928 | thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd)); | 
|---|
| 2929 | if (thistime > pAD->lasttime + 1000) | 
|---|
| 2930 | *pAD->szCommonName = 0; | 
|---|
| 2931 | pAD->lasttime = thistime; | 
|---|
| 2932 | KbdRetry: | 
|---|
| 2933 | len = strlen(pAD->szCommonName); | 
|---|
| 2934 | if (len >= CCHMAXPATH - 1) { | 
|---|
| 2935 | *pAD->szCommonName = 0; | 
|---|
| 2936 | len = 0; | 
|---|
| 2937 | } | 
|---|
| 2938 | pAD->szCommonName[len] = toupper(SHORT1FROMMP(mp2)); | 
|---|
| 2939 | pAD->szCommonName[len + 1] = 0; | 
|---|
| 2940 | for (x = pAD->cursored - (len > 0); x < pAD->afifiles; x++) { | 
|---|
| 2941 | y = (pAD->invertsort) ? (pAD->afifiles - 1) - x : x; | 
|---|
| 2942 | if (pAD->fullnames) { | 
|---|
| 2943 | if (!strnicmp(pAD->afindex[y]->fullname, pAD->szCommonName, | 
|---|
| 2944 | len + 1)) { | 
|---|
| 2945 | found = TRUE; | 
|---|
| 2946 | break; | 
|---|
| 2947 | } | 
|---|
| 2948 | } | 
|---|
| 2949 | else { | 
|---|
| 2950 | if (!strnicmp(pAD->afindex[y]->filename, pAD->szCommonName, | 
|---|
| 2951 | len + 1)) { | 
|---|
| 2952 | found = TRUE; | 
|---|
| 2953 | break; | 
|---|
| 2954 | } | 
|---|
| 2955 | } | 
|---|
| 2956 | } | 
|---|
| 2957 | if (!found) { | 
|---|
| 2958 | for (x = 0; x < pAD->cursored - (len > 0); x++) { | 
|---|
| 2959 | y = (pAD->invertsort) ? (pAD->afifiles - 1) - x : x; | 
|---|
| 2960 | if (pAD->fullnames) { | 
|---|
| 2961 | if (!strnicmp(pAD->afindex[y]->fullname, pAD->szCommonName, | 
|---|
| 2962 | len + 1)) { | 
|---|
| 2963 | found = TRUE; | 
|---|
| 2964 | break; | 
|---|
| 2965 | } | 
|---|
| 2966 | } | 
|---|
| 2967 | else { | 
|---|
| 2968 | if (!strnicmp(pAD->afindex[y]->filename, pAD->szCommonName, | 
|---|
| 2969 | len + 1)) { | 
|---|
| 2970 | found = TRUE; | 
|---|
| 2971 | break; | 
|---|
| 2972 | } | 
|---|
| 2973 | } | 
|---|
| 2974 | } | 
|---|
| 2975 | } | 
|---|
| 2976 | if (found) { | 
|---|
| 2977 | if (x + 1 != pAD->cursored) { | 
|---|
| 2978 | pAD->cursored = x + 1; | 
|---|
| 2979 | if (pAD->cursored >= pAD->topfile && | 
|---|
| 2980 | pAD->cursored < pAD->topfile + numlines && | 
|---|
| 2981 | wascursored != pAD->cursored) { | 
|---|
| 2982 | PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile, | 
|---|
| 2983 | &rcl); | 
|---|
| 2984 | PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile, | 
|---|
| 2985 | &rcl); | 
|---|
| 2986 | } | 
|---|
| 2987 | else { | 
|---|
| 2988 | if (pAD->cursored < numlines) | 
|---|
| 2989 | pAD->topfile = 1; | 
|---|
| 2990 | else if (pAD->cursored > | 
|---|
| 2991 | (pAD->afifiles + 1) - (numlines / 2)) | 
|---|
| 2992 | pAD->topfile = (pAD->afifiles + 1) - numlines; | 
|---|
| 2993 | else | 
|---|
| 2994 | pAD->topfile = pAD->cursored - (numlines / 2); | 
|---|
| 2995 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 2996 | } | 
|---|
| 2997 | } | 
|---|
| 2998 | } | 
|---|
| 2999 | else { | 
|---|
| 3000 | *pAD->szCommonName = 0; | 
|---|
| 3001 | pAD->lasttime = 0; | 
|---|
| 3002 | if (len)                  // retry as first letter if no match | 
|---|
| 3003 | goto KbdRetry; | 
|---|
| 3004 | } | 
|---|
| 3005 | break; | 
|---|
| 3006 | } | 
|---|
| 3007 | } | 
|---|
| 3008 | } | 
|---|
| 3009 | } | 
|---|
| 3010 | break; | 
|---|
| 3011 |  | 
|---|
| 3012 | case DM_PRINTOBJECT: | 
|---|
| 3013 | return MRFROMLONG(DRR_TARGET); | 
|---|
| 3014 |  | 
|---|
| 3015 | case DM_DISCARDOBJECT: | 
|---|
| 3016 | return MRFROMLONG(DRR_TARGET); | 
|---|
| 3017 |  | 
|---|
| 3018 | case WM_BEGINDRAG: | 
|---|
| 3019 | { | 
|---|
| 3020 | CHAR **list; | 
|---|
| 3021 |  | 
|---|
| 3022 | list = BuildAList(hwnd); | 
|---|
| 3023 | if (!list) | 
|---|
| 3024 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); | 
|---|
| 3025 | else { | 
|---|
| 3026 | WinSetWindowText(pAD->hwndStatus, GetPString(IDS_DRAGGINGFILESTEXT)); | 
|---|
| 3027 | DragList(hwnd, (HWND) 0, list, TRUE); | 
|---|
| 3028 | FreeList(list); | 
|---|
| 3029 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 3030 | } | 
|---|
| 3031 | } | 
|---|
| 3032 | break; | 
|---|
| 3033 |  | 
|---|
| 3034 | case WM_BUTTON1MOTIONSTART: | 
|---|
| 3035 | if (pAD && !pAD->stopflag && | 
|---|
| 3036 | !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) { | 
|---|
| 3037 | pAD->mousecaptured = TRUE; | 
|---|
| 3038 | pAD->lastselected = (ULONG) - 1; | 
|---|
| 3039 | pAD->lastdirection = 0; | 
|---|
| 3040 | WinSetCapture(HWND_DESKTOP, hwnd); | 
|---|
| 3041 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3042 | WinSendMsg(hwnd, WM_BUTTON1CLICK, mp1, MPFROM2SHORT(TRUE, 0)); | 
|---|
| 3043 | } | 
|---|
| 3044 | break; | 
|---|
| 3045 |  | 
|---|
| 3046 | case WM_MOUSEMOVE: | 
|---|
| 3047 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 3048 | if (pAD && pAD->mousecaptured) { | 
|---|
| 3049 |  | 
|---|
| 3050 | ULONG numlines, whichfile, y, x; | 
|---|
| 3051 | LONG inc; | 
|---|
| 3052 | RECTL Rectl; | 
|---|
| 3053 | POINTS pts; | 
|---|
| 3054 | BOOL outofwindow = FALSE; | 
|---|
| 3055 |  | 
|---|
| 3056 | WinQueryWindowRect(hwnd, &Rectl); | 
|---|
| 3057 | numlines = NumLines(&Rectl, pAD); | 
|---|
| 3058 | if (numlines) { | 
|---|
| 3059 | pts.x = SHORT1FROMMP(mp1); | 
|---|
| 3060 | pts.y = SHORT2FROMMP(mp1); | 
|---|
| 3061 | if (pts.y < 0) { | 
|---|
| 3062 | WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0), | 
|---|
| 3063 | MPFROM2SHORT(0, SB_LINEDOWN)); | 
|---|
| 3064 | pts.y = 1; | 
|---|
| 3065 | outofwindow = TRUE; | 
|---|
| 3066 | } | 
|---|
| 3067 | else if (pts.y > Rectl.yTop - Rectl.yBottom) { | 
|---|
| 3068 | WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0), | 
|---|
| 3069 | MPFROM2SHORT(0, SB_LINEUP)); | 
|---|
| 3070 | pts.y = (Rectl.yTop - Rectl.yBottom) - 1; | 
|---|
| 3071 | outofwindow = TRUE; | 
|---|
| 3072 | } | 
|---|
| 3073 | whichfile = ((Rectl.yTop - Rectl.yBottom) - | 
|---|
| 3074 | ((LONG) pts.y + pAD->lMaxDescender)) / pAD->lMaxHeight; | 
|---|
| 3075 | if (whichfile > numlines - 1) | 
|---|
| 3076 | whichfile = numlines - 1; | 
|---|
| 3077 | whichfile += (pAD->topfile - 1); | 
|---|
| 3078 | y = (pAD->invertsort) ? (pAD->afifiles - 1) - whichfile : whichfile; | 
|---|
| 3079 | if (y < pAD->afifiles && pAD->lastselected != whichfile) { | 
|---|
| 3080 | if (pAD->lastselected != (ULONG) - 1) { | 
|---|
| 3081 | inc = (pAD->lastselected < whichfile) ? 1 : -1; | 
|---|
| 3082 | for (x = pAD->lastselected + inc; | 
|---|
| 3083 | x != whichfile && x < pAD->afifiles; | 
|---|
| 3084 | (pAD->lastselected < whichfile) ? x++ : x--) { | 
|---|
| 3085 | y = (pAD->invertsort) ? (pAD->afifiles - 1) - x : x; | 
|---|
| 3086 | if (pAD->afindex[y]->flags & AF_SELECTED) { | 
|---|
| 3087 | pAD->afindex[y]->flags &= ~AF_SELECTED; | 
|---|
| 3088 | pAD->selected--; | 
|---|
| 3089 | pAD->ullSelectedBytes -= pAD->afindex[y]->cbFile; | 
|---|
| 3090 | } | 
|---|
| 3091 | else { | 
|---|
| 3092 | pAD->afindex[y]->flags |= AF_SELECTED; | 
|---|
| 3093 | pAD->selected++; | 
|---|
| 3094 | pAD->ullSelectedBytes += pAD->afindex[y]->cbFile; | 
|---|
| 3095 | } | 
|---|
| 3096 | PaintLine(hwnd, pAD->hps, x, pAD->topfile, &Rectl); | 
|---|
| 3097 | } | 
|---|
| 3098 | } | 
|---|
| 3099 | WinSendMsg(hwnd, WM_BUTTON1CLICK, MPFROM2SHORT(pts.x, pts.y), | 
|---|
| 3100 | MPFROM2SHORT(TRUE, 0)); | 
|---|
| 3101 | } | 
|---|
| 3102 | } | 
|---|
| 3103 | if (outofwindow) { | 
|---|
| 3104 |  | 
|---|
| 3105 | POINTL ptl; | 
|---|
| 3106 |  | 
|---|
| 3107 | WinQueryPointerPos(HWND_DESKTOP, &ptl); | 
|---|
| 3108 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1); | 
|---|
| 3109 | if ((SHORT) ptl.y == (SHORT) SHORT2FROMMP(mp1) && | 
|---|
| 3110 | (SHORT) ptl.x == (SHORT) SHORT1FROMMP(mp1) && | 
|---|
| 3111 | ((SHORT) ptl.y < 0 || ptl.y > (Rectl.yTop - Rectl.yBottom))) { | 
|---|
| 3112 | PostMsg(hwnd, UM_MOUSEMOVE, mp1, MPVOID); | 
|---|
| 3113 | DosSleep(1); | 
|---|
| 3114 | } | 
|---|
| 3115 | } | 
|---|
| 3116 | } | 
|---|
| 3117 | break; | 
|---|
| 3118 |  | 
|---|
| 3119 | case UM_MOUSEMOVE: | 
|---|
| 3120 | if (pAD && pAD->mousecaptured) { | 
|---|
| 3121 |  | 
|---|
| 3122 | POINTL ptl; | 
|---|
| 3123 | RECTL Rectl; | 
|---|
| 3124 |  | 
|---|
| 3125 | WinQueryWindowRect(hwnd, &Rectl); | 
|---|
| 3126 | WinQueryPointerPos(HWND_DESKTOP, &ptl); | 
|---|
| 3127 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1); | 
|---|
| 3128 | if ((SHORT) ptl.y == (SHORT) SHORT2FROMMP(mp1) && | 
|---|
| 3129 | (SHORT) ptl.x == (SHORT) SHORT1FROMMP(mp1) && | 
|---|
| 3130 | ((SHORT) ptl.y < 0 || ptl.y > (Rectl.yTop - Rectl.yBottom))) { | 
|---|
| 3131 | DosSleep(1); | 
|---|
| 3132 | PostMsg(hwnd, WM_MOUSEMOVE, mp1, MPFROM2SHORT(TRUE, 0)); | 
|---|
| 3133 | } | 
|---|
| 3134 | } | 
|---|
| 3135 | return 0; | 
|---|
| 3136 |  | 
|---|
| 3137 | case WM_BUTTON1UP: | 
|---|
| 3138 | case WM_BUTTON1MOTIONEND: | 
|---|
| 3139 | if (pAD) { | 
|---|
| 3140 | pAD->mousecaptured = FALSE; | 
|---|
| 3141 | pAD->lastselected = (ULONG) - 1; | 
|---|
| 3142 | pAD->lastdirection = 0; | 
|---|
| 3143 | WinSetCapture(HWND_DESKTOP, NULLHANDLE); | 
|---|
| 3144 | } | 
|---|
| 3145 | break; | 
|---|
| 3146 |  | 
|---|
| 3147 | case WM_BUTTON1CLICK: | 
|---|
| 3148 | case WM_BUTTON1DBLCLK: | 
|---|
| 3149 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 3150 | if (pAD && !pAD->stopflag && | 
|---|
| 3151 | !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) { | 
|---|
| 3152 |  | 
|---|
| 3153 | ULONG numlines, whichfile, y, wascursored; | 
|---|
| 3154 | RECTL Rectl; | 
|---|
| 3155 | POINTS pts; | 
|---|
| 3156 |  | 
|---|
| 3157 | if (pAD->afifiles) { | 
|---|
| 3158 | WinQueryWindowRect(hwnd, &Rectl); | 
|---|
| 3159 | numlines = NumLines(&Rectl, pAD); | 
|---|
| 3160 | if (numlines) { | 
|---|
| 3161 | pts.x = SHORT1FROMMP(mp1); | 
|---|
| 3162 | pts.y = SHORT2FROMMP(mp1); | 
|---|
| 3163 | whichfile = ((Rectl.yTop - Rectl.yBottom) - | 
|---|
| 3164 | ((LONG) pts.y + pAD->lMaxDescender)) / pAD->lMaxHeight; | 
|---|
| 3165 | if (whichfile > numlines - 1) | 
|---|
| 3166 | whichfile = numlines - 1; | 
|---|
| 3167 | whichfile += (pAD->topfile - 1); | 
|---|
| 3168 | if (whichfile + 1 > pAD->afifiles) | 
|---|
| 3169 | break; | 
|---|
| 3170 | y = (pAD->invertsort) ? (pAD->afifiles - 1) - whichfile : whichfile; | 
|---|
| 3171 | wascursored = pAD->cursored; | 
|---|
| 3172 | pAD->cursored = whichfile + 1; | 
|---|
| 3173 | if (pAD->cursored != wascursored) | 
|---|
| 3174 | PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile, &Rectl); | 
|---|
| 3175 | if (y < pAD->afifiles) { | 
|---|
| 3176 | if (msg == WM_BUTTON1CLICK || fUnHilite) { | 
|---|
| 3177 | if (pAD->afindex[y]->flags & AF_SELECTED) { | 
|---|
| 3178 | pAD->afindex[y]->flags &= ~AF_SELECTED; | 
|---|
| 3179 | pAD->selected--; | 
|---|
| 3180 | pAD->ullSelectedBytes -= pAD->afindex[y]->cbFile; | 
|---|
| 3181 | } | 
|---|
| 3182 | else { | 
|---|
| 3183 | pAD->afindex[y]->flags |= AF_SELECTED; | 
|---|
| 3184 | pAD->selected++; | 
|---|
| 3185 | pAD->ullSelectedBytes += pAD->afindex[y]->cbFile; | 
|---|
| 3186 | } | 
|---|
| 3187 | PaintLine(hwnd, pAD->hps, whichfile, pAD->topfile, &Rectl); | 
|---|
| 3188 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 3189 | } | 
|---|
| 3190 | } | 
|---|
| 3191 | if (msg == WM_BUTTON1CLICK) { | 
|---|
| 3192 | if (pAD->lastselected != (ULONG) - 1) { | 
|---|
| 3193 | if (whichfile > pAD->lastselected) | 
|---|
| 3194 | pAD->lastdirection = 1; | 
|---|
| 3195 | else | 
|---|
| 3196 | pAD->lastdirection = 2; | 
|---|
| 3197 | } | 
|---|
| 3198 | else | 
|---|
| 3199 | pAD->lastdirection = 0; | 
|---|
| 3200 | pAD->lastselected = whichfile; | 
|---|
| 3201 | } | 
|---|
| 3202 | else | 
|---|
| 3203 | DefaultViewKeys(hwnd, pAD->hwndFrame, HWND_DESKTOP, NULL, | 
|---|
| 3204 | pAD->afindex[y]->fullname); | 
|---|
| 3205 | } | 
|---|
| 3206 | } | 
|---|
| 3207 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3208 | } | 
|---|
| 3209 | break; | 
|---|
| 3210 |  | 
|---|
| 3211 | case WM_MENUEND: | 
|---|
| 3212 | if (pAD && (HWND) mp2 == pAD->hwndPopup) { | 
|---|
| 3213 | WinDestroyWindow(pAD->hwndPopup); | 
|---|
| 3214 | pAD->hwndPopup = (HWND) 0; | 
|---|
| 3215 | } | 
|---|
| 3216 | break; | 
|---|
| 3217 |  | 
|---|
| 3218 | case WM_CONTEXTMENU: | 
|---|
| 3219 | if (pAD) { | 
|---|
| 3220 | if (!pAD->hwndPopup) { | 
|---|
| 3221 | pAD->hwndPopup = | 
|---|
| 3222 | WinLoadMenu(HWND_DESKTOP, FM3ModHandle, SEEALL_POPUP); | 
|---|
| 3223 | if (pAD->hwndPopup) { | 
|---|
| 3224 | WinSetPresParam(pAD->hwndPopup, PP_FONTNAMESIZE, | 
|---|
| 3225 | (ULONG) strlen(GetPString(IDS_8HELVTEXT)) + 1, | 
|---|
| 3226 | (PVOID) GetPString(IDS_8HELVTEXT)); | 
|---|
| 3227 | SetConditionalCascade(pAD->hwndPopup, | 
|---|
| 3228 | IDM_DELETESUBMENU, | 
|---|
| 3229 | (fDefaultDeletePerm) ? | 
|---|
| 3230 | IDM_PERMDELETE : IDM_DELETE); | 
|---|
| 3231 | SetConditionalCascade(pAD->hwndPopup, IDM_MOVEMENU, IDM_MOVE); | 
|---|
| 3232 | SetConditionalCascade(pAD->hwndPopup, IDM_COPYMENU, IDM_COPY); | 
|---|
| 3233 | SetConditionalCascade(pAD->hwndPopup, IDM_OPENSUBMENU, | 
|---|
| 3234 | IDM_OPENDEFAULT); | 
|---|
| 3235 | SetConditionalCascade(pAD->hwndMenu, IDM_OBJECTSUBMENU, IDM_SHADOW); | 
|---|
| 3236 | if (fWorkPlace) { | 
|---|
| 3237 | WinSendMsg(pAD->hwndPopup, MM_DELETEITEM, | 
|---|
| 3238 | MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID); | 
|---|
| 3239 | WinSendMsg(pAD->hwndPopup, MM_DELETEITEM, | 
|---|
| 3240 | MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID); | 
|---|
| 3241 | } | 
|---|
| 3242 | } | 
|---|
| 3243 | } | 
|---|
| 3244 | if (pAD->hwndPopup) { | 
|---|
| 3245 |  | 
|---|
| 3246 | APIRET rc; | 
|---|
| 3247 |  | 
|---|
| 3248 | rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN); | 
|---|
| 3249 | WinEnableMenuItem(pAD->hwndPopup, IDM_EAS, (rc == 0 && | 
|---|
| 3250 | pAD->selected != 0)); | 
|---|
| 3251 | WinEnableMenuItem(pAD->hwndPopup, IDM_UUDECODE, (rc == 0 && | 
|---|
| 3252 | pAD->selected != 0)); | 
|---|
| 3253 | WinEnableMenuItem(pAD->hwndPopup, IDM_EXTRACT, (rc == 0 && | 
|---|
| 3254 | pAD->selected != 0)); | 
|---|
| 3255 | WinEnableMenuItem(pAD->hwndPopup, IDM_ARCHIVE, (rc == 0 && | 
|---|
| 3256 | pAD->selected != 0)); | 
|---|
| 3257 | WinEnableMenuItem(pAD->hwndPopup, IDM_MOVEMENU, (rc == 0 && | 
|---|
| 3258 | pAD->selected != 0)); | 
|---|
| 3259 | WinEnableMenuItem(pAD->hwndPopup, IDM_COPYMENU, (rc == 0 && | 
|---|
| 3260 | pAD->selected != 0)); | 
|---|
| 3261 | WinEnableMenuItem(pAD->hwndPopup, IDM_RENAME, (rc == 0 && | 
|---|
| 3262 | pAD->selected != 0)); | 
|---|
| 3263 | WinEnableMenuItem(pAD->hwndPopup, IDM_PRINT, (rc == 0 && | 
|---|
| 3264 | pAD->selected != 0)); | 
|---|
| 3265 | WinEnableMenuItem(pAD->hwndPopup, IDM_SUBJECT, (rc == 0 && | 
|---|
| 3266 | pAD->selected != 0)); | 
|---|
| 3267 | WinEnableMenuItem(pAD->hwndPopup, IDM_OPENSUBMENU, (rc == 0 && | 
|---|
| 3268 | pAD->selected != | 
|---|
| 3269 | 0)); | 
|---|
| 3270 | WinEnableMenuItem(pAD->hwndPopup, IDM_OBJECTSUBMENU, | 
|---|
| 3271 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3272 | WinEnableMenuItem(pAD->hwndPopup, IDM_DELETESUBMENU, | 
|---|
| 3273 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3274 | WinEnableMenuItem(pAD->hwndPopup, IDM_INFO, | 
|---|
| 3275 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3276 | WinEnableMenuItem(pAD->hwndPopup, IDM_ATTRS, | 
|---|
| 3277 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3278 | WinEnableMenuItem(pAD->hwndPopup, IDM_COLLECT, | 
|---|
| 3279 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3280 | WinEnableMenuItem(pAD->hwndPopup, IDM_SAVETOCLIP, | 
|---|
| 3281 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3282 | WinEnableMenuItem(pAD->hwndPopup, IDM_APPENDTOCLIP, | 
|---|
| 3283 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3284 | WinEnableMenuItem(pAD->hwndPopup, IDM_SAVETOLIST, | 
|---|
| 3285 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3286 | WinEnableMenuItem(pAD->hwndPopup, IDM_REMOVE, | 
|---|
| 3287 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3288 | WinEnableMenuItem(pAD->hwndPopup, IDM_HIDEALL, | 
|---|
| 3289 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3290 | WinEnableMenuItem(pAD->hwndPopup, IDM_SELECTALL, | 
|---|
| 3291 | (rc == 0 && pAD->afifiles != 0)); | 
|---|
| 3292 | WinEnableMenuItem(pAD->hwndPopup, IDM_SELECTMASK, | 
|---|
| 3293 | (rc == 0 && pAD->afifiles != 0)); | 
|---|
| 3294 | WinEnableMenuItem(pAD->hwndPopup, IDM_DESELECTALL, | 
|---|
| 3295 | (rc == 0 && pAD->afifiles != 0)); | 
|---|
| 3296 | WinEnableMenuItem(pAD->hwndPopup, IDM_DESELECTMASK, | 
|---|
| 3297 | (rc == 0 && pAD->afifiles != 0)); | 
|---|
| 3298 | WinEnableMenuItem(pAD->hwndPopup, IDM_INVERT, | 
|---|
| 3299 | (rc == 0 && pAD->afifiles != 0)); | 
|---|
| 3300 | WinEnableMenuItem(pAD->hwndPopup, IDM_FILTER, | 
|---|
| 3301 | (rc == 0 && pAD->affiles != 0)); | 
|---|
| 3302 | if (!rc) | 
|---|
| 3303 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3304 | if (WinPopupMenu(hwnd, hwnd, pAD->hwndPopup, SHORT1FROMMP(mp1), | 
|---|
| 3305 | SHORT2FROMMP(mp1), 0, | 
|---|
| 3306 | PU_HCONSTRAIN | PU_VCONSTRAIN | | 
|---|
| 3307 | PU_KEYBOARD | PU_MOUSEBUTTON1)) | 
|---|
| 3308 | CenterOverWindow(pAD->hwndPopup); | 
|---|
| 3309 | } | 
|---|
| 3310 | } | 
|---|
| 3311 | break; | 
|---|
| 3312 |  | 
|---|
| 3313 | case UM_CONTAINER_FILLED: | 
|---|
| 3314 | if (pAD) { | 
|---|
| 3315 | pAD->stopflag = 0; | 
|---|
| 3316 | pAD->topfile = 1; | 
|---|
| 3317 | pAD->cursored = 1; | 
|---|
| 3318 | pAD->multiplier = 1; | 
|---|
| 3319 | if (!pAD->afifiles) { | 
|---|
| 3320 | DosBeep(250, 50); | 
|---|
| 3321 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 3322 | } | 
|---|
| 3323 | else { | 
|---|
| 3324 | DosBeep(1000, 25); | 
|---|
| 3325 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3326 | PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID); | 
|---|
| 3327 | } | 
|---|
| 3328 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0, | 
|---|
| 3329 | SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE | SWP_ZORDER); | 
|---|
| 3330 | } | 
|---|
| 3331 | return 0; | 
|---|
| 3332 |  | 
|---|
| 3333 | case WM_ERASEBACKGROUND: | 
|---|
| 3334 | WinFillRect((HPS) mp1, (PRECTL) mp2, | 
|---|
| 3335 | standardcolors[Colors[COLORS_NORMALBACK]]); | 
|---|
| 3336 | return 0; | 
|---|
| 3337 |  | 
|---|
| 3338 | case WM_PAINT: | 
|---|
| 3339 | // fprintf(stderr,"Seeall: WM_PAINT\n"); | 
|---|
| 3340 | if (pAD) { | 
|---|
| 3341 |  | 
|---|
| 3342 | HPS hpsp; | 
|---|
| 3343 | RECTL Rectl; | 
|---|
| 3344 | POINTL ptl; | 
|---|
| 3345 | register ULONG x; | 
|---|
| 3346 | ULONG y, len, numlines; | 
|---|
| 3347 | CHAR szBuff[CCHMAXPATH + 80], szCmmaFmtFileSize[81]; | 
|---|
| 3348 | BOOL inverted, hidsys, reado, wascursored; | 
|---|
| 3349 |  | 
|---|
| 3350 | hpsp = WinBeginPaint(hwnd, pAD->hps, &Rectl); | 
|---|
| 3351 | WinFillRect(hpsp, &Rectl, standardcolors[Colors[COLORS_NORMALBACK]]); | 
|---|
| 3352 | if (!pAD->stopflag && | 
|---|
| 3353 | !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) { | 
|---|
| 3354 | WinQueryWindowRect(hwnd, &Rectl); | 
|---|
| 3355 | numlines = NumLines(&Rectl, pAD); | 
|---|
| 3356 | if (pAD->afifiles && numlines) { | 
|---|
| 3357 | if (pAD->topfile > (pAD->afifiles + 1) - numlines) | 
|---|
| 3358 | pAD->topfile = (pAD->afifiles + 1) - numlines; | 
|---|
| 3359 | if (pAD->topfile > pAD->afifiles) | 
|---|
| 3360 | pAD->topfile = 1; | 
|---|
| 3361 | if (!pAD->topfile) | 
|---|
| 3362 | pAD->topfile = 1; | 
|---|
| 3363 | if (pAD->cursored < pAD->topfile) | 
|---|
| 3364 | pAD->cursored = pAD->topfile; | 
|---|
| 3365 | else if (pAD->cursored > (pAD->topfile + numlines) - 1) | 
|---|
| 3366 | pAD->cursored = (pAD->topfile + numlines) - 1; | 
|---|
| 3367 | if (pAD->cursored > pAD->afifiles) | 
|---|
| 3368 | pAD->cursored = pAD->afifiles; | 
|---|
| 3369 | } | 
|---|
| 3370 | else | 
|---|
| 3371 | pAD->topfile = pAD->cursored = 1; | 
|---|
| 3372 | if (numlines && pAD->afifiles) { | 
|---|
| 3373 | GpiSetBackMix(hpsp, BM_OVERPAINT); | 
|---|
| 3374 | wascursored = TRUE; | 
|---|
| 3375 | for (x = pAD->topfile - 1; x < pAD->afifiles; x++) { | 
|---|
| 3376 | ptl.x = pAD->horzscroll; | 
|---|
| 3377 | if (wascursored) {          /* reestablish normal colors */ | 
|---|
| 3378 | GpiSetColor(pAD->hps, | 
|---|
| 3379 | standardcolors[Colors[COLORS_NORMALFORE]]); | 
|---|
| 3380 | GpiSetBackColor(pAD->hps, | 
|---|
| 3381 | standardcolors[Colors[COLORS_NORMALBACK]]); | 
|---|
| 3382 | wascursored = inverted = hidsys = reado = FALSE; | 
|---|
| 3383 | } | 
|---|
| 3384 | if (x == pAD->cursored - 1) | 
|---|
| 3385 | wascursored = TRUE; | 
|---|
| 3386 | y = (pAD->invertsort) ? (pAD->afifiles - 1) - x : x; | 
|---|
| 3387 | ptl.y = (Rectl.yTop - | 
|---|
| 3388 | (pAD->lMaxHeight * (((x + 1) - pAD->topfile) + 1))); | 
|---|
| 3389 | if (ptl.y - pAD->lMaxDescender <= 0) | 
|---|
| 3390 | break; | 
|---|
| 3391 | if (pAD->afindex[y]->flags & AF_SELECTED) { | 
|---|
| 3392 | if (!inverted) { | 
|---|
| 3393 | GpiSetColor(pAD->hps, | 
|---|
| 3394 | standardcolors[Colors | 
|---|
| 3395 | [COLORS_SELECTEDNORMALFORE]]); | 
|---|
| 3396 | GpiSetBackColor(pAD->hps, | 
|---|
| 3397 | (wascursored) ? | 
|---|
| 3398 | standardcolors[Colors | 
|---|
| 3399 | [COLORS_CURSOREDSELECTEDBACK]] | 
|---|
| 3400 | : | 
|---|
| 3401 | standardcolors[Colors[COLORS_SELECTEDBACK]]); | 
|---|
| 3402 | inverted = TRUE; | 
|---|
| 3403 | } | 
|---|
| 3404 | } | 
|---|
| 3405 | else if (inverted || | 
|---|
| 3406 | ((pAD->afindex[y]->attrFile & | 
|---|
| 3407 | (FILE_SYSTEM | FILE_HIDDEN)) != 0) != hidsys || | 
|---|
| 3408 | ((pAD->afindex[y]->attrFile & FILE_READONLY) != 0) != | 
|---|
| 3409 | reado) { | 
|---|
| 3410 | if (pAD->afindex[y]->attrFile & (FILE_SYSTEM | FILE_HIDDEN)) { | 
|---|
| 3411 | GpiSetColor(pAD->hps, | 
|---|
| 3412 | standardcolors[Colors[COLORS_SYSTEMFORE]]); | 
|---|
| 3413 | hidsys = TRUE; | 
|---|
| 3414 | } | 
|---|
| 3415 | else if ((pAD->afindex[y]->attrFile & FILE_READONLY) != 0) { | 
|---|
| 3416 | GpiSetColor(pAD->hps, | 
|---|
| 3417 | standardcolors[Colors[COLORS_READONLYFORE]]); | 
|---|
| 3418 | reado = TRUE; | 
|---|
| 3419 | } | 
|---|
| 3420 | else | 
|---|
| 3421 | GpiSetColor(pAD->hps, | 
|---|
| 3422 | standardcolors[Colors[COLORS_NORMALFORE]]); | 
|---|
| 3423 | GpiSetBackColor(pAD->hps, | 
|---|
| 3424 | (wascursored) ? | 
|---|
| 3425 | standardcolors[Colors | 
|---|
| 3426 | [COLORS_CURSOREDNORMALBACK]] : | 
|---|
| 3427 | standardcolors[Colors[COLORS_NORMALBACK]]); | 
|---|
| 3428 | inverted = FALSE; | 
|---|
| 3429 | } | 
|---|
| 3430 | else if (wascursored) | 
|---|
| 3431 | GpiSetBackColor(pAD->hps, | 
|---|
| 3432 | standardcolors[Colors | 
|---|
| 3433 | [COLORS_CURSOREDNORMALBACK]]); | 
|---|
| 3434 | CommaFmtULL(szCmmaFmtFileSize, | 
|---|
| 3435 | sizeof(szCmmaFmtFileSize), pAD->afindex[y]->cbFile, ' '); | 
|---|
| 3436 | len = | 
|---|
| 3437 | sprintf(szBuff, | 
|---|
| 3438 | "%c%-*.*s  %-12s  %c%c%c%c%c  %04u/%02u/%02u %02u:%02u:%02u ", | 
|---|
| 3439 | wascursored ? '>' : ' ', | 
|---|
| 3440 | pAD->fullnames ? pAD->longestw : pAD->longest, | 
|---|
| 3441 | pAD->fullnames ? pAD->longestw : pAD->longest, | 
|---|
| 3442 | (pAD->fullnames) ? pAD->afindex[y]->fullname : pAD-> | 
|---|
| 3443 | afindex[y]->filename, szCmmaFmtFileSize, | 
|---|
| 3444 | "-A"[((pAD->afindex[y]->attrFile & FILE_ARCHIVED) != | 
|---|
| 3445 | 0)], | 
|---|
| 3446 | "-R"[((pAD->afindex[y]->attrFile & FILE_READONLY) != | 
|---|
| 3447 | 0)], | 
|---|
| 3448 | "-H"[((pAD->afindex[y]->attrFile & FILE_HIDDEN) != 0)], | 
|---|
| 3449 | "-S"[((pAD->afindex[y]->attrFile & FILE_SYSTEM) != 0)], | 
|---|
| 3450 | "-D"[((pAD->afindex[y]->attrFile & FILE_DIRECTORY) != | 
|---|
| 3451 | 0)], pAD->afindex[y]->date.year + 1980, | 
|---|
| 3452 | pAD->afindex[y]->date.month, pAD->afindex[y]->date.day, | 
|---|
| 3453 | pAD->afindex[y]->time.hours, | 
|---|
| 3454 | pAD->afindex[y]->time.minutes, | 
|---|
| 3455 | pAD->afindex[y]->time.twosecs * 2); | 
|---|
| 3456 | GpiCharStringAt(hpsp, &ptl, len, szBuff); | 
|---|
| 3457 | GpiQueryCurrentPosition(hpsp, &ptl); | 
|---|
| 3458 | if (ptl.x + abs(pAD->horzscroll) > pAD->maxx) { | 
|---|
| 3459 | pAD->maxx = ptl.x + abs(pAD->horzscroll); | 
|---|
| 3460 | WinSendMsg(pAD->hhscroll, SBM_SETTHUMBSIZE, | 
|---|
| 3461 | MPFROM2SHORT((SHORT) Rectl.xRight, | 
|---|
| 3462 | (SHORT) pAD->maxx), MPVOID); | 
|---|
| 3463 | } | 
|---|
| 3464 | } | 
|---|
| 3465 | } | 
|---|
| 3466 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3467 | } | 
|---|
| 3468 | WinEndPaint(hpsp); | 
|---|
| 3469 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 3470 | if (!pAD->stopflag) | 
|---|
| 3471 | WinSendMsg(pAD->hvscroll, SBM_SETSCROLLBAR, | 
|---|
| 3472 | MPFROMSHORT((SHORT) (pAD->topfile / pAD->multiplier)), | 
|---|
| 3473 | MPFROM2SHORT(1, | 
|---|
| 3474 | (SHORT) (pAD->afifiles / pAD->multiplier) - | 
|---|
| 3475 | (numlines - 1))); | 
|---|
| 3476 | WinSendMsg(pAD->hhscroll, SBM_SETSCROLLBAR, | 
|---|
| 3477 | MPFROMSHORT((SHORT) abs(pAD->horzscroll)), | 
|---|
| 3478 | MPFROM2SHORT(0, (SHORT) (pAD->maxx - Rectl.xRight))); | 
|---|
| 3479 | WinSendMsg(pAD->hhscroll, SBM_SETTHUMBSIZE, | 
|---|
| 3480 | MPFROM2SHORT((SHORT) Rectl.xRight, (SHORT) pAD->maxx), | 
|---|
| 3481 | MPVOID); | 
|---|
| 3482 | } | 
|---|
| 3483 | break; | 
|---|
| 3484 |  | 
|---|
| 3485 | case WM_HSCROLL: | 
|---|
| 3486 | { | 
|---|
| 3487 | RECTL rectl; | 
|---|
| 3488 | BOOL invalidate = TRUE; | 
|---|
| 3489 |  | 
|---|
| 3490 | WinQueryWindowRect(hwnd, &rectl); | 
|---|
| 3491 | switch (SHORT2FROMMP(mp2)) { | 
|---|
| 3492 | case SB_PAGERIGHT: | 
|---|
| 3493 | if (abs(pAD->horzscroll) < pAD->maxx - rectl.xRight) { | 
|---|
| 3494 | pAD->horzscroll -= rectl.xRight; | 
|---|
| 3495 | if (abs(pAD->horzscroll) > pAD->maxx - rectl.xRight) | 
|---|
| 3496 | pAD->horzscroll = -(pAD->maxx - rectl.xRight); | 
|---|
| 3497 | } | 
|---|
| 3498 | break; | 
|---|
| 3499 |  | 
|---|
| 3500 | case SB_PAGELEFT: | 
|---|
| 3501 | if (pAD->horzscroll < 0) { | 
|---|
| 3502 | pAD->horzscroll += rectl.xRight; | 
|---|
| 3503 | if (pAD->horzscroll > 0) | 
|---|
| 3504 | pAD->horzscroll = 0; | 
|---|
| 3505 | } | 
|---|
| 3506 | break; | 
|---|
| 3507 |  | 
|---|
| 3508 | case SB_LINERIGHT: | 
|---|
| 3509 | if (abs(pAD->horzscroll) < pAD->maxx - rectl.xRight) | 
|---|
| 3510 | pAD->horzscroll -= pAD->fattrs.lAveCharWidth; | 
|---|
| 3511 | break; | 
|---|
| 3512 |  | 
|---|
| 3513 | case SB_LINELEFT: | 
|---|
| 3514 | if (pAD->horzscroll < 0) | 
|---|
| 3515 | pAD->horzscroll += pAD->fattrs.lAveCharWidth; | 
|---|
| 3516 | break; | 
|---|
| 3517 |  | 
|---|
| 3518 | case SB_SLIDERTRACK: | 
|---|
| 3519 | pAD->horzscroll = SHORT1FROMMP(mp2); | 
|---|
| 3520 | pAD->horzscroll = -(pAD->horzscroll); | 
|---|
| 3521 | if (pAD->horzscroll > 0) | 
|---|
| 3522 | pAD->horzscroll = 0; | 
|---|
| 3523 | if (abs(pAD->horzscroll) > pAD->maxx - rectl.xRight) | 
|---|
| 3524 | pAD->horzscroll = -(pAD->maxx - rectl.xRight); | 
|---|
| 3525 | break; | 
|---|
| 3526 |  | 
|---|
| 3527 | default: | 
|---|
| 3528 | invalidate = FALSE; | 
|---|
| 3529 | break; | 
|---|
| 3530 | } | 
|---|
| 3531 | if (invalidate) | 
|---|
| 3532 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3533 | } | 
|---|
| 3534 | break; | 
|---|
| 3535 |  | 
|---|
| 3536 | case WM_VSCROLL: | 
|---|
| 3537 | // fprintf(stderr,"Seeall: WM_VSCROLL\n"); | 
|---|
| 3538 | if (pAD && !pAD->stopflag && | 
|---|
| 3539 | !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) { | 
|---|
| 3540 |  | 
|---|
| 3541 | ULONG numlines, wascursored; | 
|---|
| 3542 | RECTL rcl; | 
|---|
| 3543 |  | 
|---|
| 3544 | if (pAD->afifiles) { | 
|---|
| 3545 | WinQueryWindowRect(hwnd, &rcl); | 
|---|
| 3546 | numlines = NumLines(&rcl, pAD); | 
|---|
| 3547 | if (numlines) { | 
|---|
| 3548 | wascursored = pAD->cursored; | 
|---|
| 3549 | switch (SHORT2FROMMP(mp2)) { | 
|---|
| 3550 | case SB_PAGEUP: | 
|---|
| 3551 | if (pAD->topfile > 1) { | 
|---|
| 3552 | pAD->topfile -= numlines; | 
|---|
| 3553 | if (pAD->topfile > pAD->afifiles || | 
|---|
| 3554 | pAD->topfile > (pAD->afifiles + 1) - numlines) | 
|---|
| 3555 | pAD->topfile = 1; | 
|---|
| 3556 | if (pAD->cursored > pAD->topfile + numlines) | 
|---|
| 3557 | pAD->cursored = pAD->topfile + numlines; | 
|---|
| 3558 | if (pAD->cursored > pAD->afifiles) | 
|---|
| 3559 | pAD->cursored = pAD->afifiles; | 
|---|
| 3560 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3561 | } | 
|---|
| 3562 | break; | 
|---|
| 3563 | case SB_PAGEDOWN: | 
|---|
| 3564 | if (pAD->topfile <= pAD->afifiles - numlines) { | 
|---|
| 3565 | pAD->topfile += numlines; | 
|---|
| 3566 | if (pAD->topfile > (pAD->afifiles + 1) - numlines) | 
|---|
| 3567 | pAD->topfile = (pAD->afifiles + 1) - numlines; | 
|---|
| 3568 | if (pAD->cursored < pAD->topfile) | 
|---|
| 3569 | pAD->cursored = pAD->topfile; | 
|---|
| 3570 | if (pAD->cursored > (pAD->topfile + numlines) - 1) | 
|---|
| 3571 | pAD->cursored = (pAD->topfile + numlines) - 1; | 
|---|
| 3572 | if (pAD->cursored > pAD->afifiles) | 
|---|
| 3573 | pAD->cursored = pAD->afifiles; | 
|---|
| 3574 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3575 | } | 
|---|
| 3576 | break; | 
|---|
| 3577 | case SB_LINEDOWN: | 
|---|
| 3578 | if (pAD->topfile <= pAD->afifiles - numlines) { | 
|---|
| 3579 |  | 
|---|
| 3580 | RECTL Rectl, iRectl; | 
|---|
| 3581 |  | 
|---|
| 3582 | pAD->topfile++; | 
|---|
| 3583 | if (pAD->cursored < pAD->topfile) | 
|---|
| 3584 | pAD->cursored = pAD->topfile; | 
|---|
| 3585 | else if (pAD->cursored > (pAD->topfile + numlines) - 1) | 
|---|
| 3586 | pAD->cursored = (pAD->topfile + numlines) - 1; | 
|---|
| 3587 | if (pAD->cursored > pAD->afifiles) | 
|---|
| 3588 | pAD->cursored = pAD->afifiles; | 
|---|
| 3589 | WinQueryWindowRect(hwnd, &Rectl); | 
|---|
| 3590 | WinScrollWindow(hwnd, 0, pAD->lMaxHeight, | 
|---|
| 3591 | NULL, NULL, NULLHANDLE, &iRectl, 0); | 
|---|
| 3592 | WinFillRect(pAD->hps, &iRectl, | 
|---|
| 3593 | standardcolors[Colors[COLORS_NORMALBACK]]); | 
|---|
| 3594 | PaintLine(hwnd, pAD->hps, (pAD->topfile + numlines) - 2, | 
|---|
| 3595 | pAD->topfile, &Rectl); | 
|---|
| 3596 | if (pAD->cursored != pAD->topfile + numlines) | 
|---|
| 3597 | PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile, | 
|---|
| 3598 | &Rectl); | 
|---|
| 3599 | if (wascursored != pAD->cursored | 
|---|
| 3600 | && wascursored < pAD->topfile + numlines | 
|---|
| 3601 | && wascursored >= pAD->topfile) | 
|---|
| 3602 | PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile, | 
|---|
| 3603 | &Rectl); | 
|---|
| 3604 | if (wascursored != pAD->cursored) | 
|---|
| 3605 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 3606 | WinSendMsg(pAD->hhscroll, SBM_SETSCROLLBAR, | 
|---|
| 3607 | MPFROMSHORT((SHORT) abs(pAD->horzscroll)), | 
|---|
| 3608 | MPFROM2SHORT(0, (SHORT) (pAD->maxx - Rectl.xRight))); | 
|---|
| 3609 | WinSendMsg(pAD->hvscroll, SBM_SETSCROLLBAR, | 
|---|
| 3610 | MPFROMSHORT((SHORT) (pAD->topfile / | 
|---|
| 3611 | pAD->multiplier)), | 
|---|
| 3612 | MPFROM2SHORT(1, (SHORT) (pAD->afifiles / | 
|---|
| 3613 | pAD->multiplier) - | 
|---|
| 3614 | (numlines - 1))); | 
|---|
| 3615 | } | 
|---|
| 3616 | break; | 
|---|
| 3617 | case SB_LINEUP: | 
|---|
| 3618 | if (pAD->topfile > 1) { | 
|---|
| 3619 |  | 
|---|
| 3620 | RECTL Rectl, iRectl; | 
|---|
| 3621 |  | 
|---|
| 3622 | pAD->topfile--; | 
|---|
| 3623 | if (pAD->cursored < pAD->topfile) | 
|---|
| 3624 | pAD->cursored = pAD->topfile; | 
|---|
| 3625 | else if (pAD->cursored > (pAD->topfile + numlines) - 1) | 
|---|
| 3626 | pAD->cursored = (pAD->topfile + numlines) - 1; | 
|---|
| 3627 | if (pAD->cursored > pAD->afifiles) | 
|---|
| 3628 | pAD->cursored = pAD->afifiles; | 
|---|
| 3629 | WinQueryWindowRect(hwnd, &Rectl); | 
|---|
| 3630 | WinScrollWindow(hwnd, 0, -pAD->lMaxHeight, | 
|---|
| 3631 | NULL, NULL, NULLHANDLE, &iRectl, 0); | 
|---|
| 3632 | WinFillRect(pAD->hps, &iRectl, | 
|---|
| 3633 | standardcolors[Colors[COLORS_NORMALBACK]]); | 
|---|
| 3634 | iRectl = Rectl; | 
|---|
| 3635 | iRectl.yTop -= ((numlines * pAD->lMaxHeight) + | 
|---|
| 3636 | pAD->lMaxDescender); | 
|---|
| 3637 | WinFillRect(pAD->hps, &iRectl, | 
|---|
| 3638 | standardcolors[pAD->aulColors[COLORS_NORMALBACK]]); | 
|---|
| 3639 | PaintLine(hwnd, pAD->hps, pAD->topfile - 1, pAD->topfile, | 
|---|
| 3640 | &Rectl); | 
|---|
| 3641 | if (pAD->cursored != pAD->topfile) | 
|---|
| 3642 | PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile, | 
|---|
| 3643 | &Rectl); | 
|---|
| 3644 | if (pAD->cursored != wascursored && wascursored >= pAD->topfile | 
|---|
| 3645 | && wascursored < pAD->topfile + numlines) | 
|---|
| 3646 | PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile, | 
|---|
| 3647 | &Rectl); | 
|---|
| 3648 | if (pAD->cursored != wascursored) | 
|---|
| 3649 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 3650 | WinSendMsg(pAD->hhscroll, SBM_SETSCROLLBAR, | 
|---|
| 3651 | MPFROMSHORT((SHORT) abs(pAD->horzscroll)), | 
|---|
| 3652 | MPFROM2SHORT(0, (SHORT) (pAD->maxx - Rectl.xRight))); | 
|---|
| 3653 | WinSendMsg(pAD->hvscroll, SBM_SETSCROLLBAR, | 
|---|
| 3654 | MPFROMSHORT((SHORT) (pAD->topfile / | 
|---|
| 3655 | pAD->multiplier)), | 
|---|
| 3656 | MPFROM2SHORT(1, (SHORT) (pAD->afifiles / | 
|---|
| 3657 | pAD->multiplier) - | 
|---|
| 3658 | (numlines - 1))); | 
|---|
| 3659 | } | 
|---|
| 3660 | break; | 
|---|
| 3661 | case SB_SLIDERTRACK: | 
|---|
| 3662 | if ((SHORT1FROMMP(mp2) >= 1) || | 
|---|
| 3663 | (SHORT1FROMMP(mp2)) <= pAD->afifiles) { | 
|---|
| 3664 | pAD->topfile = (ULONG) SHORT1FROMMP(mp2) * pAD->multiplier; | 
|---|
| 3665 | if (pAD->topfile > (pAD->afifiles + 1) - numlines) | 
|---|
| 3666 | pAD->topfile = (pAD->afifiles + 1) - numlines; | 
|---|
| 3667 | if (!pAD->topfile) | 
|---|
| 3668 | pAD->topfile = 1; | 
|---|
| 3669 | if (pAD->cursored < pAD->topfile) | 
|---|
| 3670 | pAD->cursored = pAD->topfile; | 
|---|
| 3671 | else if (pAD->cursored > pAD->topfile + numlines) | 
|---|
| 3672 | pAD->cursored = pAD->topfile + numlines; | 
|---|
| 3673 | if (pAD->cursored > pAD->afifiles) | 
|---|
| 3674 | pAD->cursored = pAD->afifiles; | 
|---|
| 3675 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3676 | } | 
|---|
| 3677 | else | 
|---|
| 3678 | WinAlarm(HWND_DESKTOP, WA_NOTE); | 
|---|
| 3679 | break; | 
|---|
| 3680 | } | 
|---|
| 3681 | } | 
|---|
| 3682 | } | 
|---|
| 3683 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3684 | } | 
|---|
| 3685 | break; | 
|---|
| 3686 |  | 
|---|
| 3687 | case WM_INITMENU: | 
|---|
| 3688 | if (pAD) { | 
|---|
| 3689 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 3690 | case IDM_FILESMENU: | 
|---|
| 3691 | { | 
|---|
| 3692 | APIRET rc; | 
|---|
| 3693 |  | 
|---|
| 3694 | rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN); | 
|---|
| 3695 | WinEnableMenuItem((HWND) mp2, IDM_DUPES, (rc == 0)); | 
|---|
| 3696 | WinEnableMenuItem((HWND) mp2, IDM_COLLECT, (rc == 0 && | 
|---|
| 3697 | pAD->selected != 0)); | 
|---|
| 3698 | WinEnableMenuItem((HWND) mp2, IDM_SAVETOCLIP, (rc == 0 && | 
|---|
| 3699 | pAD->selected != 0)); | 
|---|
| 3700 | WinEnableMenuItem((HWND) mp2, IDM_APPENDTOCLIP, (rc == 0 && | 
|---|
| 3701 | pAD->selected != | 
|---|
| 3702 | 0)); | 
|---|
| 3703 | WinEnableMenuItem((HWND) mp2, IDM_SAVETOLIST, | 
|---|
| 3704 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3705 | WinEnableMenuItem((HWND) mp2, IDM_REMOVE, | 
|---|
| 3706 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3707 | WinEnableMenuItem((HWND) mp2, IDM_HIDEALL, | 
|---|
| 3708 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3709 | WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, | 
|---|
| 3710 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3711 | WinEnableMenuItem((HWND) mp2, IDM_INFO, | 
|---|
| 3712 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3713 | WinEnableMenuItem((HWND) mp2, IDM_ATTRS, | 
|---|
| 3714 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3715 | WinEnableMenuItem((HWND) mp2, IDM_EAS, | 
|---|
| 3716 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3717 | WinEnableMenuItem((HWND) mp2, IDM_UUDECODE, | 
|---|
| 3718 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3719 | WinEnableMenuItem((HWND) mp2, IDM_EXTRACT, | 
|---|
| 3720 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3721 | WinEnableMenuItem((HWND) mp2, IDM_ARCHIVE, | 
|---|
| 3722 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3723 | WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, | 
|---|
| 3724 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3725 | WinEnableMenuItem((HWND) mp2, IDM_COPYMENU, | 
|---|
| 3726 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3727 | WinEnableMenuItem((HWND) mp2, IDM_RENAME, | 
|---|
| 3728 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3729 | WinEnableMenuItem((HWND) mp2, IDM_PRINT, | 
|---|
| 3730 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3731 | WinEnableMenuItem((HWND) mp2, IDM_SUBJECT, | 
|---|
| 3732 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3733 | WinEnableMenuItem((HWND) mp2, IDM_OPENSUBMENU, | 
|---|
| 3734 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3735 | WinEnableMenuItem((HWND) mp2, IDM_OBJECTSUBMENU, | 
|---|
| 3736 | (rc == 0 && pAD->selected != 0)); | 
|---|
| 3737 | if (!rc) | 
|---|
| 3738 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3739 | } | 
|---|
| 3740 | break; | 
|---|
| 3741 |  | 
|---|
| 3742 | case IDM_SELECTSUBMENU: | 
|---|
| 3743 | { | 
|---|
| 3744 | APIRET rc; | 
|---|
| 3745 |  | 
|---|
| 3746 | rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN); | 
|---|
| 3747 | WinEnableMenuItem((HWND) mp2, IDM_SELECTALL, (rc == 0 && | 
|---|
| 3748 | pAD->afifiles != 0 && | 
|---|
| 3749 | (pAD->afifiles != | 
|---|
| 3750 | pAD->selected || | 
|---|
| 3751 | !pAD->selected))); | 
|---|
| 3752 | WinEnableMenuItem((HWND) mp2, IDM_SELECTMASK, (rc == 0 && | 
|---|
| 3753 | pAD->afifiles != 0 && | 
|---|
| 3754 | (pAD->afifiles != | 
|---|
| 3755 | pAD->selected || | 
|---|
| 3756 | !pAD->selected))); | 
|---|
| 3757 | WinEnableMenuItem((HWND) mp2, IDM_DESELECTALL, (rc == 0 && | 
|---|
| 3758 | pAD->afifiles != 0 | 
|---|
| 3759 | && pAD->selected)); | 
|---|
| 3760 | WinEnableMenuItem((HWND) mp2, IDM_DESELECTMASK, | 
|---|
| 3761 | (rc == 0 && pAD->afifiles != 0) && pAD->selected); | 
|---|
| 3762 | WinEnableMenuItem((HWND) mp2, IDM_INVERT, | 
|---|
| 3763 | (rc == 0 && pAD->afifiles != 0)); | 
|---|
| 3764 | if (!rc) | 
|---|
| 3765 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3766 | } | 
|---|
| 3767 | break; | 
|---|
| 3768 |  | 
|---|
| 3769 | case IDM_SORTSUBMENU: | 
|---|
| 3770 | { | 
|---|
| 3771 | APIRET rc; | 
|---|
| 3772 |  | 
|---|
| 3773 | rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN); | 
|---|
| 3774 | WinEnableMenuItem((HWND) mp2, IDM_SORTNAME, (rc == 0)); | 
|---|
| 3775 | WinEnableMenuItem((HWND) mp2, IDM_SORTEASIZE, (rc == 0)); | 
|---|
| 3776 | WinEnableMenuItem((HWND) mp2, IDM_SORTSIZE, (rc == 0)); | 
|---|
| 3777 | WinEnableMenuItem((HWND) mp2, IDM_SORTLWDATE, (rc == 0)); | 
|---|
| 3778 | WinEnableMenuItem((HWND) mp2, IDM_SORTFILENAME, (rc == 0)); | 
|---|
| 3779 | WinEnableMenuItem((HWND) mp2, IDM_SORTFIRST, (rc == 0)); | 
|---|
| 3780 | if (!rc) | 
|---|
| 3781 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3782 | } | 
|---|
| 3783 | WinCheckMenuItem((HWND) mp2, IDM_SORTNAME, | 
|---|
| 3784 | (pAD->pfnCompare == comparefullnames)); | 
|---|
| 3785 | WinCheckMenuItem((HWND) mp2, IDM_SORTEASIZE, | 
|---|
| 3786 | (pAD->pfnCompare == (PFNSORT) NULL)); | 
|---|
| 3787 | WinCheckMenuItem((HWND) mp2, IDM_SORTSIZE, | 
|---|
| 3788 | (pAD->pfnCompare == comparesizes)); | 
|---|
| 3789 | WinCheckMenuItem((HWND) mp2, IDM_SORTLWDATE, | 
|---|
| 3790 | (pAD->pfnCompare == comparedates)); | 
|---|
| 3791 | WinCheckMenuItem((HWND) mp2, IDM_SORTFILENAME, | 
|---|
| 3792 | (pAD->pfnCompare == comparenames)); | 
|---|
| 3793 | WinCheckMenuItem((HWND) mp2, IDM_SORTREVERSE, pAD->invertsort); | 
|---|
| 3794 | WinCheckMenuItem((HWND) mp2, IDM_SORTFIRST, | 
|---|
| 3795 | (pAD->pfnCompare == compareexts)); | 
|---|
| 3796 | break; | 
|---|
| 3797 |  | 
|---|
| 3798 | case IDM_VIEWSMENU: | 
|---|
| 3799 | { | 
|---|
| 3800 | APIRET rc; | 
|---|
| 3801 |  | 
|---|
| 3802 | rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN); | 
|---|
| 3803 | WinEnableMenuItem((HWND) mp2, IDM_RESCAN, (rc == 0)); | 
|---|
| 3804 | WinEnableMenuItem((HWND) mp2, IDM_FILTER, (rc == 0 && | 
|---|
| 3805 | pAD->affiles != 0)); | 
|---|
| 3806 | if (!rc) | 
|---|
| 3807 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3808 | } | 
|---|
| 3809 | WinCheckMenuItem((HWND) mp2, IDM_SHOWLNAMES, pAD->fullnames); | 
|---|
| 3810 | break; | 
|---|
| 3811 | } | 
|---|
| 3812 | } | 
|---|
| 3813 | break; | 
|---|
| 3814 |  | 
|---|
| 3815 | case WM_COMMAND: | 
|---|
| 3816 | if (!pAD) { | 
|---|
| 3817 | Runtime_Error(pszSrcFile, __LINE__, "no data"); | 
|---|
| 3818 | return 0; | 
|---|
| 3819 | } | 
|---|
| 3820 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 3821 | case IDM_SETTARGET: | 
|---|
| 3822 | SetTargetDir(hwnd, FALSE); | 
|---|
| 3823 | break; | 
|---|
| 3824 |  | 
|---|
| 3825 | case IDM_DUPES: | 
|---|
| 3826 | if (!pAD->stopflag && | 
|---|
| 3827 | !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) { | 
|---|
| 3828 | pAD->dupeflags = (USHORT) WinDlgBox(HWND_DESKTOP, | 
|---|
| 3829 | hwnd, | 
|---|
| 3830 | DupeDlgProc, | 
|---|
| 3831 | FM3ModHandle, | 
|---|
| 3832 | DUPE_FRAME, | 
|---|
| 3833 | MPFROM2SHORT(pAD->dupeflags, 0)); | 
|---|
| 3834 | if (pAD->dupeflags) { | 
|---|
| 3835 | if (_beginthread(FindDupesThread, NULL, 65536, (PVOID) hwnd) == -1) | 
|---|
| 3836 | Runtime_Error(pszSrcFile, __LINE__, | 
|---|
| 3837 | GetPString(IDS_COULDNTSTARTTHREADTEXT)); | 
|---|
| 3838 | } | 
|---|
| 3839 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3840 | } | 
|---|
| 3841 | break; | 
|---|
| 3842 |  | 
|---|
| 3843 | case IDM_COLORPALETTE: | 
|---|
| 3844 | { | 
|---|
| 3845 | COLORS co; | 
|---|
| 3846 | LONG temp[COLORS_MAX]; | 
|---|
| 3847 |  | 
|---|
| 3848 | memset(&co, 0, sizeof(co)); | 
|---|
| 3849 | co.size = sizeof(co); | 
|---|
| 3850 | co.numcolors = COLORS_MAX; | 
|---|
| 3851 | co.colors = pAD->aulColors; | 
|---|
| 3852 | co.descriptions = IDS_SACOLORS1TEXT; | 
|---|
| 3853 | co.origs = temp; | 
|---|
| 3854 | co.prompt = IDS_SACOLORSPROMPTTEXT; | 
|---|
| 3855 | memcpy(temp, pAD->aulColors, sizeof(LONG) * COLORS_MAX); | 
|---|
| 3856 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 3857 | hwnd, | 
|---|
| 3858 | ColorDlgProc, | 
|---|
| 3859 | FM3ModHandle, COLOR_FRAME, (PVOID) & co)) { | 
|---|
| 3860 | memcpy(Colors, pAD->aulColors, sizeof(LONG) * COLORS_MAX); | 
|---|
| 3861 | PrfWriteProfileData(fmprof, | 
|---|
| 3862 | appname, | 
|---|
| 3863 | "Seeall.Colors", | 
|---|
| 3864 | &pAD->aulColors, sizeof(LONG) * COLORS_MAX); | 
|---|
| 3865 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3866 | } | 
|---|
| 3867 | } | 
|---|
| 3868 | break; | 
|---|
| 3869 |  | 
|---|
| 3870 | case IDM_CODEPAGE: | 
|---|
| 3871 | { | 
|---|
| 3872 | INT cp; | 
|---|
| 3873 |  | 
|---|
| 3874 | cp = PickCodepage(hwnd); | 
|---|
| 3875 | if (cp != -1) { | 
|---|
| 3876 | pAD->fattrs.usCodePage = (USHORT) cp; | 
|---|
| 3877 | Codepage = pAD->fattrs.usCodePage; | 
|---|
| 3878 | PrfWriteProfileData(fmprof, | 
|---|
| 3879 | appname, | 
|---|
| 3880 | "Seeall.Codepage", | 
|---|
| 3881 | &pAD->fattrs.usCodePage, sizeof(USHORT)); | 
|---|
| 3882 | GpiDeleteSetId(pAD->hps, FIXED_FONT_LCID); | 
|---|
| 3883 | GpiAssociate(pAD->hps, 0); | 
|---|
| 3884 | GpiDestroyPS(pAD->hps); | 
|---|
| 3885 | pAD->hps = InitWindow(hwnd); | 
|---|
| 3886 | pAD->maxx = pAD->horzscroll = 0; | 
|---|
| 3887 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3888 | } | 
|---|
| 3889 | } | 
|---|
| 3890 | break; | 
|---|
| 3891 |  | 
|---|
| 3892 | case IDM_FONTPALETTE: | 
|---|
| 3893 | SetMLEFont(hwnd, &pAD->fattrs, 11); | 
|---|
| 3894 | PrfWriteProfileData(fmprof, | 
|---|
| 3895 | appname, | 
|---|
| 3896 | "Seeall.Fattrs", &pAD->fattrs, sizeof(pAD->fattrs)); | 
|---|
| 3897 | Fattrs = pAD->fattrs; | 
|---|
| 3898 | GpiDeleteSetId(pAD->hps, FIXED_FONT_LCID); | 
|---|
| 3899 | GpiAssociate(pAD->hps, 0); | 
|---|
| 3900 | GpiDestroyPS(pAD->hps); | 
|---|
| 3901 | pAD->hps = InitWindow(hwnd); | 
|---|
| 3902 | pAD->maxx = pAD->horzscroll = 0; | 
|---|
| 3903 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3904 | break; | 
|---|
| 3905 |  | 
|---|
| 3906 | case IDM_SHOWLNAMES: | 
|---|
| 3907 | pAD->fullnames = (pAD->fullnames) ? FALSE : TRUE; | 
|---|
| 3908 | PrfWriteProfileData(fmprof, | 
|---|
| 3909 | appname, | 
|---|
| 3910 | "Seeall.Fullnames", &pAD->fullnames, sizeof(BOOL)); | 
|---|
| 3911 | Fullnames = pAD->fullnames; | 
|---|
| 3912 | pAD->maxx = pAD->horzscroll = 0; | 
|---|
| 3913 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3914 | break; | 
|---|
| 3915 |  | 
|---|
| 3916 | case IDM_SORTREVERSE: | 
|---|
| 3917 | pAD->invertsort = (pAD->invertsort) ? FALSE : TRUE; | 
|---|
| 3918 | SortReverse = pAD->invertsort; | 
|---|
| 3919 | PrfWriteProfileData(fmprof, | 
|---|
| 3920 | appname, | 
|---|
| 3921 | "Seeall.SortReverse", | 
|---|
| 3922 | (PVOID) & pAD->invertsort, sizeof(BOOL)); | 
|---|
| 3923 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3924 | break; | 
|---|
| 3925 |  | 
|---|
| 3926 | case IDM_SORTEASIZE: | 
|---|
| 3927 | case IDM_SORTNAME: | 
|---|
| 3928 | case IDM_SORTFILENAME: | 
|---|
| 3929 | case IDM_SORTSIZE: | 
|---|
| 3930 | case IDM_SORTLWDATE: | 
|---|
| 3931 | case IDM_SORTFIRST: | 
|---|
| 3932 | if (!pAD->stopflag && | 
|---|
| 3933 | !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) { | 
|---|
| 3934 | { | 
|---|
| 3935 | USHORT dummy = SHORT1FROMMP(mp1); | 
|---|
| 3936 |  | 
|---|
| 3937 | PrfWriteProfileData(fmprof, | 
|---|
| 3938 | appname, | 
|---|
| 3939 | "Seeall.Sort", (PVOID) & dummy, sizeof(USHORT)); | 
|---|
| 3940 | SortType = SHORT1FROMMP(mp1); | 
|---|
| 3941 | } | 
|---|
| 3942 | WinSetPointer(HWND_DESKTOP, hptrBusy); | 
|---|
| 3943 | WinSendMsg(hwnd, UM_RESCAN, MPFROMLONG(1), MPVOID); | 
|---|
| 3944 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 3945 | case IDM_SORTEASIZE: | 
|---|
| 3946 | pAD->pfnCompare = (PFNSORT) NULL; | 
|---|
| 3947 | ReSort(hwnd); | 
|---|
| 3948 | break; | 
|---|
| 3949 |  | 
|---|
| 3950 | case IDM_SORTNAME: | 
|---|
| 3951 | pAD->pfnCompare = comparefullnames; | 
|---|
| 3952 | ReSort(hwnd); | 
|---|
| 3953 | break; | 
|---|
| 3954 |  | 
|---|
| 3955 | case IDM_SORTFILENAME: | 
|---|
| 3956 | pAD->pfnCompare = comparenames; | 
|---|
| 3957 | ReSort(hwnd); | 
|---|
| 3958 | break; | 
|---|
| 3959 |  | 
|---|
| 3960 | case IDM_SORTSIZE: | 
|---|
| 3961 | pAD->pfnCompare = comparesizes; | 
|---|
| 3962 | ReSort(hwnd); | 
|---|
| 3963 | break; | 
|---|
| 3964 |  | 
|---|
| 3965 | case IDM_SORTLWDATE: | 
|---|
| 3966 | pAD->pfnCompare = comparedates; | 
|---|
| 3967 | ReSort(hwnd); | 
|---|
| 3968 | break; | 
|---|
| 3969 |  | 
|---|
| 3970 | case IDM_SORTFIRST: | 
|---|
| 3971 | pAD->pfnCompare = compareexts; | 
|---|
| 3972 | ReSort(hwnd); | 
|---|
| 3973 | break; | 
|---|
| 3974 | } | 
|---|
| 3975 | WinSetPointer(HWND_DESKTOP, hptrArrow); | 
|---|
| 3976 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3977 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 3978 | } | 
|---|
| 3979 | break; | 
|---|
| 3980 |  | 
|---|
| 3981 | case IDM_FILTER: | 
|---|
| 3982 | if (!pAD->stopflag && | 
|---|
| 3983 | !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) { | 
|---|
| 3984 | FilterList(hwnd); | 
|---|
| 3985 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 3986 | } | 
|---|
| 3987 | break; | 
|---|
| 3988 |  | 
|---|
| 3989 | case IDM_RESCAN: | 
|---|
| 3990 | if (!pAD->stopflag && | 
|---|
| 3991 | !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) { | 
|---|
| 3992 |  | 
|---|
| 3993 | CHAR tempflags[26]; | 
|---|
| 3994 |  | 
|---|
| 3995 | memcpy(tempflags, pAD->abDrvFlags, sizeof(tempflags)); | 
|---|
| 3996 | if (!WinDlgBox(HWND_DESKTOP, hwnd, AFDrvsWndProc, FM3ModHandle, | 
|---|
| 3997 | DRVS_FRAME, (PVOID) pAD)) { | 
|---|
| 3998 | memcpy(pAD->abDrvFlags, tempflags, sizeof(tempflags)); | 
|---|
| 3999 | *pAD->szFindPath = 0; | 
|---|
| 4000 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 4001 | break; | 
|---|
| 4002 | } | 
|---|
| 4003 | WinSendMsg(pAD->hhscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1), | 
|---|
| 4004 | MPVOID); | 
|---|
| 4005 | WinSendMsg(pAD->hvscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1), | 
|---|
| 4006 | MPVOID); | 
|---|
| 4007 | pAD->topfile = 1; | 
|---|
| 4008 | pAD->cursored = 1; | 
|---|
| 4009 | pAD->selected = 0; | 
|---|
| 4010 | pAD->ullSelectedBytes = 0; | 
|---|
| 4011 | pAD->maxx = pAD->horzscroll = 0; | 
|---|
| 4012 | FreeAllFilesList(hwnd); | 
|---|
| 4013 | pAD->stopflag = 0; | 
|---|
| 4014 | if (_beginthread(FindAllThread, NULL, 524288, (PVOID) hwnd) == -1) { | 
|---|
| 4015 | Runtime_Error(pszSrcFile, __LINE__, | 
|---|
| 4016 | GetPString(IDS_COULDNTSTARTTHREADTEXT)); | 
|---|
| 4017 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 4018 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 4019 | } | 
|---|
| 4020 | else { | 
|---|
| 4021 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 4022 | DosSleep(50);//05 Aug 07 GKY 100 | 
|---|
| 4023 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 4024 | PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID); | 
|---|
| 4025 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 4026 | } | 
|---|
| 4027 | } | 
|---|
| 4028 | break; | 
|---|
| 4029 |  | 
|---|
| 4030 | case IDM_DELETE: | 
|---|
| 4031 | case IDM_PERMDELETE: | 
|---|
| 4032 | case IDM_SELECTALL: | 
|---|
| 4033 | case IDM_DESELECTALL: | 
|---|
| 4034 | case IDM_INVERT: | 
|---|
| 4035 | case IDM_SELECTMASK: | 
|---|
| 4036 | case IDM_DESELECTMASK: | 
|---|
| 4037 | case IDM_REMOVE: | 
|---|
| 4038 | case IDM_HIDEALL: | 
|---|
| 4039 | case IDM_COLLECT: | 
|---|
| 4040 | case IDM_COLLECTOR: | 
|---|
| 4041 | case IDM_SAVETOCLIP: | 
|---|
| 4042 | case IDM_APPENDTOCLIP: | 
|---|
| 4043 | case IDM_SAVETOLIST: | 
|---|
| 4044 | case IDM_INFO: | 
|---|
| 4045 | case IDM_ATTRS: | 
|---|
| 4046 | case IDM_MOVE: | 
|---|
| 4047 | case IDM_COPY: | 
|---|
| 4048 | case IDM_RENAME: | 
|---|
| 4049 | case IDM_MOVEPRESERVE: | 
|---|
| 4050 | case IDM_COPYPRESERVE: | 
|---|
| 4051 | case IDM_WILDMOVE: | 
|---|
| 4052 | case IDM_WILDCOPY: | 
|---|
| 4053 | case IDM_SUBJECT: | 
|---|
| 4054 | case IDM_EAS: | 
|---|
| 4055 | case IDM_PRINT: | 
|---|
| 4056 | case IDM_ARCHIVE: | 
|---|
| 4057 | case IDM_EXTRACT: | 
|---|
| 4058 | case IDM_UUDECODE: | 
|---|
| 4059 | case IDM_SHADOW: | 
|---|
| 4060 | case IDM_OBJECT: | 
|---|
| 4061 | case IDM_OPENSETTINGS: | 
|---|
| 4062 | case IDM_OPENDEFAULT: | 
|---|
| 4063 | if (!pAD->stopflag && | 
|---|
| 4064 | !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) { | 
|---|
| 4065 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 4066 | case IDM_SELECTALL: | 
|---|
| 4067 | case IDM_DESELECTALL: | 
|---|
| 4068 | case IDM_INVERT: | 
|---|
| 4069 | case IDM_HIDEALL: | 
|---|
| 4070 | case IDM_REMOVE: | 
|---|
| 4071 | Mark(hwnd, (SHORT1FROMMP(mp1) == IDM_DESELECTALL) ? | 
|---|
| 4072 | AFM_UNMARK : (SHORT1FROMMP(mp1) == IDM_INVERT) ? | 
|---|
| 4073 | AFM_INVERT : (SHORT1FROMMP(mp1) == IDM_HIDEALL) ? | 
|---|
| 4074 | AFM_FILTER : (SHORT1FROMMP(mp1) == IDM_REMOVE) ? | 
|---|
| 4075 | AFM_MARKDELETED : 0, NULL); | 
|---|
| 4076 | if (SHORT1FROMMP(mp1) == IDM_REMOVE || | 
|---|
| 4077 | SHORT1FROMMP(mp1) == IDM_HIDEALL) { | 
|---|
| 4078 | if (SHORT1FROMMP(mp1) == IDM_REMOVE) | 
|---|
| 4079 | RemoveDeleted(hwnd); | 
|---|
| 4080 | else | 
|---|
| 4081 | ReSort(hwnd); | 
|---|
| 4082 | } | 
|---|
| 4083 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 4084 | break; | 
|---|
| 4085 |  | 
|---|
| 4086 | case IDM_SELECTMASK: | 
|---|
| 4087 | case IDM_DESELECTMASK: | 
|---|
| 4088 | SelectMask(hwnd, (SHORT1FROMMP(mp1) == IDM_DESELECTMASK)); | 
|---|
| 4089 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 4090 | break; | 
|---|
| 4091 |  | 
|---|
| 4092 | case IDM_DELETE: | 
|---|
| 4093 | case IDM_PERMDELETE: | 
|---|
| 4094 | case IDM_APPENDTOCLIP: | 
|---|
| 4095 | case IDM_SAVETOCLIP: | 
|---|
| 4096 | case IDM_SAVETOLIST: | 
|---|
| 4097 | case IDM_COLLECT: | 
|---|
| 4098 | case IDM_INFO: | 
|---|
| 4099 | case IDM_ATTRS: | 
|---|
| 4100 | case IDM_MOVE: | 
|---|
| 4101 | case IDM_COPY: | 
|---|
| 4102 | case IDM_RENAME: | 
|---|
| 4103 | case IDM_MOVEPRESERVE: | 
|---|
| 4104 | case IDM_COPYPRESERVE: | 
|---|
| 4105 | case IDM_WILDMOVE: | 
|---|
| 4106 | case IDM_WILDCOPY: | 
|---|
| 4107 | case IDM_SUBJECT: | 
|---|
| 4108 | case IDM_PRINT: | 
|---|
| 4109 | case IDM_EAS: | 
|---|
| 4110 | case IDM_ARCHIVE: | 
|---|
| 4111 | case IDM_EXTRACT: | 
|---|
| 4112 | case IDM_SHADOW: | 
|---|
| 4113 | case IDM_OBJECT: | 
|---|
| 4114 | case IDM_OPENSETTINGS: | 
|---|
| 4115 | case IDM_OPENDEFAULT: | 
|---|
| 4116 | case IDM_UUDECODE: | 
|---|
| 4117 | { | 
|---|
| 4118 | CHAR **list = BuildAList(hwnd); | 
|---|
| 4119 |  | 
|---|
| 4120 | if (!list) | 
|---|
| 4121 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); | 
|---|
| 4122 | else { | 
|---|
| 4123 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 4124 | case IDM_COLLECT: | 
|---|
| 4125 | CollectList(hwnd, list); | 
|---|
| 4126 | break; | 
|---|
| 4127 | case IDM_DELETE: | 
|---|
| 4128 | case IDM_PERMDELETE: | 
|---|
| 4129 | case IDM_APPENDTOCLIP: | 
|---|
| 4130 | case IDM_SAVETOCLIP: | 
|---|
| 4131 | case IDM_SAVETOLIST: | 
|---|
| 4132 | case IDM_INFO: | 
|---|
| 4133 | case IDM_ATTRS: | 
|---|
| 4134 | case IDM_MOVE: | 
|---|
| 4135 | case IDM_COPY: | 
|---|
| 4136 | case IDM_RENAME: | 
|---|
| 4137 | case IDM_MOVEPRESERVE: | 
|---|
| 4138 | case IDM_COPYPRESERVE: | 
|---|
| 4139 | case IDM_WILDMOVE: | 
|---|
| 4140 | case IDM_WILDCOPY: | 
|---|
| 4141 | case IDM_SUBJECT: | 
|---|
| 4142 | case IDM_PRINT: | 
|---|
| 4143 | case IDM_EAS: | 
|---|
| 4144 | case IDM_ARCHIVE: | 
|---|
| 4145 | case IDM_EXTRACT: | 
|---|
| 4146 | case IDM_UUDECODE: | 
|---|
| 4147 | case IDM_OBJECT: | 
|---|
| 4148 | case IDM_SHADOW: | 
|---|
| 4149 | case IDM_OPENSETTINGS: | 
|---|
| 4150 | case IDM_OPENDEFAULT: | 
|---|
| 4151 | if (!PostMsg(pAD->hwndObj, UM_MASSACTION, mp1, MPFROMP(list))) | 
|---|
| 4152 | FreeList(list); | 
|---|
| 4153 | break; | 
|---|
| 4154 | } | 
|---|
| 4155 | if (fUnHilite) { | 
|---|
| 4156 | Mark(hwnd, AFM_UNMARK, NULL); | 
|---|
| 4157 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 4158 | } | 
|---|
| 4159 | } | 
|---|
| 4160 | } | 
|---|
| 4161 | break; | 
|---|
| 4162 |  | 
|---|
| 4163 | case IDM_COLLECTOR: | 
|---|
| 4164 | if (mp2) { | 
|---|
| 4165 |  | 
|---|
| 4166 | CHAR **list = mp2; | 
|---|
| 4167 |  | 
|---|
| 4168 | if (Collector) { | 
|---|
| 4169 | if (!PostMsg(Collector, WM_COMMAND, | 
|---|
| 4170 | MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list))) | 
|---|
| 4171 | FreeList(list); | 
|---|
| 4172 | else if (fUnHilite) { | 
|---|
| 4173 | Mark(hwnd, AFM_UNMARK, NULL); | 
|---|
| 4174 | WinInvalidateRect(hwnd, NULL, FALSE); | 
|---|
| 4175 | } | 
|---|
| 4176 | } | 
|---|
| 4177 | else | 
|---|
| 4178 | FreeList(list); | 
|---|
| 4179 | } | 
|---|
| 4180 | break; | 
|---|
| 4181 | } | 
|---|
| 4182 | DosReleaseMutexSem(pAD->hmtxScan); | 
|---|
| 4183 | } | 
|---|
| 4184 | else if (SHORT1FROMMP(mp1) == IDM_COLLECTOR) { | 
|---|
| 4185 | DosSleep(50);//05 Aug 07 GKY 100 | 
|---|
| 4186 | if (!PostMsg(hwnd, msg, mp1, mp2)) | 
|---|
| 4187 | WinSendMsg(hwnd, msg, mp1, mp2); | 
|---|
| 4188 | } | 
|---|
| 4189 | break; | 
|---|
| 4190 |  | 
|---|
| 4191 | case IDM_HELP: | 
|---|
| 4192 | if (hwndHelp) | 
|---|
| 4193 | WinSendMsg(hwndHelp, | 
|---|
| 4194 | HM_DISPLAY_HELP, | 
|---|
| 4195 | MPFROM2SHORT(HELP_SEEALL, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 4196 | break; | 
|---|
| 4197 | } | 
|---|
| 4198 | return 0; | 
|---|
| 4199 |  | 
|---|
| 4200 | case WM_SIZE: | 
|---|
| 4201 | // fprintf(stderr,"Seeall: WM_SIZE\n"); | 
|---|
| 4202 | PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID); | 
|---|
| 4203 | break; | 
|---|
| 4204 |  | 
|---|
| 4205 | case WM_CLOSE: | 
|---|
| 4206 | // fprintf(stderr,"Seeall: WM_CLOSE\n"); | 
|---|
| 4207 | if (pAD) | 
|---|
| 4208 | pAD->stopflag = 1; | 
|---|
| 4209 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 4210 | return 0; | 
|---|
| 4211 |  | 
|---|
| 4212 | case WM_DESTROY: | 
|---|
| 4213 | // fprintf(stderr,"Seeall: WM_DESTROY\n"); | 
|---|
| 4214 | if (pAD) { | 
|---|
| 4215 | pAD->stopflag = 1; | 
|---|
| 4216 | if (pAD->hmtxScan) { | 
|---|
| 4217 | DosRequestMutexSem(pAD->hmtxScan, 15000); | 
|---|
| 4218 | DosCloseMutexSem(pAD->hmtxScan); | 
|---|
| 4219 | } | 
|---|
| 4220 | if (pAD->hwndPopup) | 
|---|
| 4221 | WinDestroyWindow(pAD->hwndPopup); | 
|---|
| 4222 | if (pAD->hwndObj) { | 
|---|
| 4223 | if (!PostMsg(pAD->hwndObj, WM_CLOSE, MPVOID, MPVOID)) | 
|---|
| 4224 | WinSendMsg(pAD->hwndObj, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 4225 | } | 
|---|
| 4226 | if (pAD->hps) { | 
|---|
| 4227 | GpiDeleteSetId(pAD->hps, FIXED_FONT_LCID); | 
|---|
| 4228 | GpiAssociate(pAD->hps, 0); | 
|---|
| 4229 | GpiDestroyPS(pAD->hps); | 
|---|
| 4230 | } | 
|---|
| 4231 | if (pAD->killme) { | 
|---|
| 4232 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID)) | 
|---|
| 4233 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); | 
|---|
| 4234 | } | 
|---|
| 4235 | FreeAllFilesList(hwnd); | 
|---|
| 4236 | free(pAD); | 
|---|
| 4237 | } | 
|---|
| 4238 | break; | 
|---|
| 4239 | } | 
|---|
| 4240 |  | 
|---|
| 4241 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 4242 | } | 
|---|
| 4243 |  | 
|---|
| 4244 | HWND StartSeeAll(HWND hwndParent, BOOL standalone,      // called by applet | 
|---|
| 4245 | CHAR * pszStartPath)   // pathname or NULL | 
|---|
| 4246 | { | 
|---|
| 4247 | HWND hwndFrame = (HWND) 0, hwndClient; | 
|---|
| 4248 | ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU | | 
|---|
| 4249 | FCF_SIZEBORDER | FCF_MINMAX | | 
|---|
| 4250 | FCF_NOBYTEALIGN | FCF_VERTSCROLL | | 
|---|
| 4251 | FCF_MENU | FCF_ICON | FCF_ACCELTABLE | FCF_HORZSCROLL; | 
|---|
| 4252 |  | 
|---|
| 4253 | if (ParentIsDesktop(hwndParent, hwndParent)) | 
|---|
| 4254 | FrameFlags |= (FCF_TASKLIST | FCF_SHELLPOSITION); | 
|---|
| 4255 | hwndFrame = WinCreateStdWindow(hwndParent, | 
|---|
| 4256 | WS_VISIBLE, | 
|---|
| 4257 | &FrameFlags, | 
|---|
| 4258 | WC_SEEALL, | 
|---|
| 4259 | GetPString(IDS_SEEALLTITLETEXT), | 
|---|
| 4260 | WS_VISIBLE | fwsAnimate, | 
|---|
| 4261 | FM3ModHandle, SEEALL_FRAME, &hwndClient); | 
|---|
| 4262 | if (hwndFrame) { | 
|---|
| 4263 | static CHAR *pszDir; | 
|---|
| 4264 |  | 
|---|
| 4265 | if (standalone) { | 
|---|
| 4266 | if (!PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 4267 | UM_SETUP4, MPVOID, MPVOID)) { | 
|---|
| 4268 | PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); | 
|---|
| 4269 | return (HWND) 0; | 
|---|
| 4270 | } | 
|---|
| 4271 | } | 
|---|
| 4272 | if (pszStartPath) { | 
|---|
| 4273 | // Needs to be static for other thread | 
|---|
| 4274 | if (!pszDir) | 
|---|
| 4275 | pszDir = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__); | 
|---|
| 4276 | if (pszDir) { | 
|---|
| 4277 | strcpy(pszDir, pszStartPath); | 
|---|
| 4278 | pszStartPath = pszDir; | 
|---|
| 4279 | } | 
|---|
| 4280 | } | 
|---|
| 4281 | PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT), | 
|---|
| 4282 | UM_SETUP5, MPFROMP(pszStartPath), MPVOID); | 
|---|
| 4283 | } | 
|---|
| 4284 | else if (standalone) | 
|---|
| 4285 | PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); | 
|---|
| 4286 | return hwndFrame; | 
|---|
| 4287 | } | 
|---|
| 4288 |  | 
|---|
| 4289 | #pragma alloc_text(SEEALL,comparefullnames,comparenames,comparesizes) | 
|---|
| 4290 | #pragma alloc_text(SEEALL,comparedates,compareexts,SeeStatusProc) | 
|---|
| 4291 | #pragma alloc_text(SEEALL,InitWindow,PaintLine,SeeAllWndProc) | 
|---|
| 4292 | #pragma alloc_text(SEEALL,UpdateList,CollectList,ReSort,Mark) | 
|---|
| 4293 | #pragma alloc_text(SEEALL,BuildAList,RemoveDeleted,SeeFrameWndProc,FilterList) | 
|---|
| 4294 | #pragma alloc_text(SEEALL2,SeeObjWndProc,MakeSeeObjWinThread,FindDupesThread,DupeDlgProc) | 
|---|
| 4295 | #pragma alloc_text(SEEALL3,FreeAllFilesList,DoADir,FindAllThread,AFDrvsWndProc) | 
|---|
| 4296 | #pragma alloc_text(SEEALL3,StartSeeAll) | 
|---|
| 4297 |  | 
|---|