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