source: trunk/dll/seeall.c@ 1038

Last change on this file since 1038 was 1038, checked in by Gregg Young, 17 years ago

More fortify cleanup

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