source: trunk/dll/seeall.c@ 1037

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

Newview is used used when view is selected from menus in dircnrs, collector, arccnrs etc (ticket 244); Removed Fortify_Leavescope wrapper other minor fortify changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 118.0 KB
Line 
1
2/***********************************************************************
3
4 $Id: seeall.c 1037 2008-07-04 16:39:08Z 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 hmq2 = WinCreateMsgQueue(hab2, 256);
1135 if (hmq2) {
1136 DosError(FERR_DISABLEHARDERR);
1137 WinRegisterClass(hab2,
1138 WC_OBJECTWINDOW,
1139 SeeObjWndProc, 0, sizeof(PVOID));
1140 hwndObj = WinCreateWindow(HWND_OBJECT,
1141 WC_OBJECTWINDOW,
1142 (PSZ) NULL,
1143 0,
1144 0,
1145 0,
1146 0,
1147 0, 0, HWND_TOP, SEEALL_OBJ, NULL, NULL);
1148 if (!hwndObj) {
1149 Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
1150 IDS_WINCREATEWINDOW);
1151 if (!PostMsg(ad->hwndClient, WM_CLOSE, MPVOID, MPVOID))
1152 WinSendMsg(ad->hwndClient, WM_CLOSE, MPVOID, MPVOID);
1153 }
1154 else {
1155 ad->hwndObj = hwndObj;
1156 WinSetWindowULong(hwndObj, QWL_USER, ad->hwndFrame);
1157 priority_normal();
1158 while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
1159 WinDispatchMsg(hab2, &qmsg2);
1160 WinDestroyWindow(hwndObj);
1161 }
1162 WinDestroyMsgQueue(hmq2);
1163 }
1164 else
1165 WinTerminate(hab2);
1166 }
1167 }
1168}
1169
1170static VOID SelectMask(HWND hwnd, BOOL deselect)
1171{
1172 MASK mask;
1173 register ULONG x, y, z;
1174 BOOL ret;
1175 ALLDATA *pAD = WinQueryWindowPtr(hwnd, QWL_USER);
1176
1177 memset(&mask, 0, sizeof(mask));
1178 mask.fNoAttribs = FALSE;
1179 mask.fNoDirs = TRUE;
1180 mask.attrFile = pAD->mask.attrFile;
1181 mask.antiattr = pAD->mask.antiattr;
1182 mask.fIsSeeAll = TRUE;
1183 strcpy(mask.prompt,
1184 GetPString((!deselect) ?
1185 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
1186 if (WinDlgBox(HWND_DESKTOP,
1187 hwnd,
1188 PickMaskDlgProc,
1189 FM3ModHandle,
1190 MSK_FRAME,
1191 MPFROMP(&mask)) &&
1192 (*mask.szMask ||
1193 mask.attrFile != pAD->mask.attrFile ||
1194 mask.antiattr != pAD->mask.antiattr)) {
1195 for (x = 0; x < pAD->afindexcnt; x++) {
1196 y = (pAD->invertsort) ? (pAD->afindexcnt - 1) - x : x;
1197 ret = FALSE;
1198 if (mask.pszMasks[1]) {
1199 for (z = 0; mask.pszMasks[z]; z++) {
1200 if (*mask.pszMasks[z]) {
1201 if (*mask.pszMasks[z] != '/') {
1202 if (wildcard((strchr(mask.pszMasks[z], '\\') ||
1203 strchr(mask.pszMasks[z], ':')) ?
1204 pAD->afindex[y]->fullname : pAD->afindex[y]->
1205 filename, mask.pszMasks[z], FALSE))
1206 ret = TRUE;
1207 }
1208 else {
1209 if (wildcard((strchr(mask.pszMasks[z], '\\') ||
1210 strchr(mask.pszMasks[z], ':')) ?
1211 pAD->afindex[y]->fullname : pAD->afindex[y]->
1212 filename, mask.pszMasks[y] + 1, FALSE)) {
1213 ret = FALSE;
1214 break;
1215 }
1216 }
1217 }
1218 }
1219 }
1220 else if (*mask.szMask) {
1221 if (wildcard((strchr(mask.szMask, '\\') ||
1222 strchr(mask.szMask, ':')) ?
1223 pAD->afindex[y]->fullname : pAD->afindex[y]->filename,
1224 mask.szMask, FALSE))
1225 ret = TRUE;
1226 }
1227 else
1228 ret = TRUE;
1229 if (ret) {
1230 if ((!(mask.attrFile & FILE_HIDDEN)
1231 && (pAD->afindex[y]->attrFile & FILE_HIDDEN))
1232 || (!(mask.attrFile & FILE_SYSTEM)
1233 && (pAD->afindex[y]->attrFile & FILE_SYSTEM))
1234 || (!(mask.attrFile & FILE_READONLY)
1235 && (pAD->afindex[y]->attrFile & FILE_READONLY))
1236 || (!(mask.attrFile & FILE_ARCHIVED)
1237 && (pAD->afindex[y]->attrFile & FILE_ARCHIVED)))
1238 ret = FALSE;
1239 else
1240 if (((mask.antiattr & FILE_HIDDEN)
1241 && !(pAD->afindex[y]->attrFile & FILE_HIDDEN))
1242 || ((mask.antiattr & FILE_SYSTEM)
1243 && !(pAD->afindex[y]->attrFile & FILE_SYSTEM))
1244 || ((mask.antiattr & FILE_READONLY)
1245 && !(pAD->afindex[y]->attrFile & FILE_READONLY))
1246 || ((mask.antiattr & FILE_ARCHIVED)
1247 && !(pAD->afindex[y]->attrFile & FILE_ARCHIVED)))
1248 ret = FALSE;
1249 }
1250 if (ret) {
1251 if (deselect) {
1252 if (pAD->afindex[y]->flags & AF_SELECTED) {
1253 pAD->selected--;
1254 pAD->ullSelectedBytes -= pAD->afindex[y]->cbFile;
1255 pAD->afindex[y]->flags &= ~AF_SELECTED;
1256 }
1257 }
1258 else {
1259 if (~pAD->afindex[y]->flags & AF_SELECTED) {
1260 pAD->selected++;
1261 pAD->ullSelectedBytes += pAD->afindex[y]->cbFile;
1262 pAD->afindex[y]->flags |= AF_SELECTED;
1263 }
1264 }
1265 }
1266 } // for
1267 }
1268}
1269
1270static VOID CollectList(HWND hwnd, CHAR ** list)
1271{
1272 if (!Collector) {
1273 if (hwndMain && !fExternalCollector && !strcmp(realappname, FM3Str)) {
1274
1275 HWND hwndC;
1276 SWP swp;
1277
1278 if (!fAutoTile)
1279 GetNextWindowPos(hwndMain, &swp, NULL, NULL);
1280 hwndC = StartCollector(hwndMain, 4);
1281 if (hwndC) {
1282 if (!fAutoTile)
1283 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
1284 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
1285 SWP_SHOW | SWP_ZORDER);
1286 else
1287 TileChildren(hwndMain, TRUE);
1288 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
1289 DosSleep(100);//05 Aug 07 GKY 250
1290 }
1291 }
1292 else {
1293 StartCollector(HWND_DESKTOP, 4);
1294 DosSleep(100);//05 Aug 07 GKY 250
1295 }
1296 }
1297 if (!PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0),
1298 MPFROMP(list)))
1299 FreeList(list);
1300}
1301
1302static VOID FreeAllFilesList(HWND hwnd)
1303{
1304 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
1305 register ULONG x;
1306
1307 if (ad->afhead && ad->afheadcnt) {
1308 for (x = 0; x < ad->afheadcnt; x++) {
1309 xfree(ad->afhead[x].fullname, pszSrcFile, __LINE__);
1310 }
1311 xfree(ad->afhead, pszSrcFile, __LINE__);
1312 ad->afhead = NULL;
1313 xfree(ad->afindex, pszSrcFile, __LINE__);
1314 ad->afindex = NULL;
1315 }
1316 DosPostEventSem(CompactSem);
1317 ad->afalloc = ad->afindexcnt = ad->afheadcnt = ad->longest = ad->longestw =
1318 ad->maxx = ad->horzscroll = 0;
1319}
1320
1321static CHAR **BuildAList(HWND hwnd)
1322{
1323 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
1324 ULONG x;
1325 ULONG y;
1326 ULONG z = 0;
1327 CHAR **list = NULL;
1328 UINT numfiles = 0;
1329 UINT numalloc = 0;
1330 INT error;
1331
1332 if (ad->selected) {
1333 for (x = 0; x < ad->afindexcnt; x++) {
1334 y = (ad->invertsort) ? (ad->afindexcnt - 1) - x : x;
1335 if (ad->afindex[y]->flags & AF_SELECTED) {
1336 error = AddToList(ad->afindex[y]->fullname, &list,
1337 &numfiles, &numalloc);
1338 if (error)
1339 break;
1340 z++;
1341 if (z >= ad->selected)
1342 break;
1343 }
1344 }
1345 }
1346 return list;
1347}
1348
1349static BOOL Mark(HWND hwnd, INT command, CHAR ** list)
1350{
1351 /* Marks only unfiltered files */
1352
1353 ALLDATA *pAD = WinQueryWindowPtr(hwnd, QWL_USER);
1354 register ULONG x, y, z;
1355 BOOL ret = TRUE;
1356 BOOL didone = FALSE;
1357
1358 for (x = 0; x < pAD->afindexcnt; x++) {
1359 y = (pAD->invertsort) ? (pAD->afindexcnt - 1) - x : x;
1360 if (list) {
1361 ret = FALSE;
1362 for (z = 0; list[z]; z++) {
1363 if (!stricmp(list[z], pAD->afindex[y]->fullname)) {
1364 ret = TRUE;
1365 break;
1366 }
1367 }
1368 }
1369 if (ret) {
1370 didone = TRUE;
1371 if (command == AFM_UNMARK) {
1372 if (pAD->afindex[y]->flags & AF_SELECTED) {
1373 pAD->selected--;
1374 pAD->ullSelectedBytes -= pAD->afindex[y]->cbFile;
1375 pAD->afindex[y]->flags &= ~AF_SELECTED;
1376 }
1377 }
1378 else if (command == AFM_MARK) {
1379 if (~pAD->afindex[y]->flags & AF_SELECTED) {
1380 pAD->selected++;
1381 pAD->ullSelectedBytes += pAD->afindex[y]->cbFile;
1382 pAD->afindex[y]->flags |= AF_SELECTED;
1383 }
1384 }
1385 else if (command == AFM_INVERT) {
1386 if (pAD->afindex[y]->flags & AF_SELECTED) {
1387 pAD->selected--;
1388 pAD->ullSelectedBytes -= pAD->afindex[y]->cbFile;
1389 pAD->afindex[y]->flags &= ~AF_SELECTED;
1390 }
1391 else {
1392 pAD->selected++;
1393 pAD->ullSelectedBytes += pAD->afindex[y]->cbFile;
1394 pAD->afindex[y]->flags |= AF_SELECTED;
1395 }
1396 }
1397 else if (command == AFM_MARKDELETED) {
1398 if (pAD->afindex[y]->flags & AF_SELECTED)
1399 pAD->afindex[y]->flags |= AF_DELETED;
1400 }
1401 else if (command == AFM_FILTER) {
1402 if (pAD->afindex[y]->flags & AF_SELECTED)
1403 pAD->afindex[y]->flags |= AF_FILTERED;
1404 }
1405 }
1406 } // for x
1407 return didone;
1408}
1409
1410static BOOL UpdateList(HWND hwnd, CHAR **list)
1411{
1412 /* Updates files in the list */
1413
1414 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
1415 ULONG x, z;
1416 BOOL ret, didone = FALSE;
1417 FILEFINDBUF3L ffb;
1418 ULONG ulFindCnt;
1419 HDIR hdir;
1420 CHAR *p;
1421
1422 if (list) {
1423 for (z = 0; list[z] && !ad->stopflag; z++) {
1424 ret = FALSE;
1425 for (x = 0; x < ad->afheadcnt; x++) {
1426 if (!stricmp(list[z], ad->afhead[x].fullname)) {
1427 ret = TRUE;
1428 break;
1429 }
1430 }
1431 if (ret) {
1432 didone = TRUE;
1433 hdir = HDIR_CREATE;
1434 ulFindCnt = 1;
1435 if (!xDosFindFirst(list[z], &hdir, FILE_NORMAL | FILE_ARCHIVED |
1436 FILE_DIRECTORY | FILE_READONLY | FILE_SYSTEM |
1437 FILE_HIDDEN, &ffb, sizeof(ffb), &ulFindCnt,
1438 FIL_STANDARDL)) {
1439 DosFindClose(hdir);
1440 if (!(ffb.attrFile & FILE_DIRECTORY)) {
1441 ad->afhead[x].attrFile = (USHORT) ffb.attrFile;
1442 ad->afhead[x].cbFile = ffb.cbFile;
1443 ad->afhead[x].date = ffb.fdateLastWrite;
1444 ad->afhead[x].time = ffb.ftimeLastWrite;
1445 }
1446 else
1447 ad->afhead[x].flags |= AF_DELETED;
1448 }
1449 else
1450 ad->afhead[x].flags |= AF_DELETED;
1451 }
1452 else if (isalpha(*list[z]) && ad->abDrvFlags[toupper(*list[z]) - 'A']) {
1453 didone = TRUE;
1454 hdir = HDIR_CREATE;
1455 ulFindCnt = 1;
1456 if (!xDosFindFirst(list[z], &hdir, FILE_NORMAL | FILE_ARCHIVED |
1457 FILE_DIRECTORY | FILE_READONLY | FILE_SYSTEM |
1458 FILE_HIDDEN, &ffb, sizeof(ffb), &ulFindCnt,
1459 FIL_STANDARDL)) {
1460 DosFindClose(hdir);
1461 if (!(ffb.attrFile & FILE_DIRECTORY)) {
1462 if (!ad->afalloc || ad->afheadcnt > ad->afalloc - 1) {
1463
1464 ALLFILES *temp, **templ;
1465
1466 temp =
1467 xrealloc(ad->afhead, (ad->afalloc + 1) * sizeof(ALLFILES),
1468 pszSrcFile, __LINE__);
1469 if (!temp) {
1470 ad->stopflag = 1;
1471 break;
1472 }
1473 else {
1474 ad->afhead = temp;
1475 templ =
1476 xrealloc(ad->afindex,
1477 (ad->afalloc + 1) * sizeof(ALLFILES *), pszSrcFile,
1478 __LINE__);
1479 if (!templ) {
1480 ad->stopflag = 1;
1481 break;
1482 }
1483 else
1484 ad->afindex = templ;
1485 ad->afalloc++;
1486 }
1487 }
1488 ad->afhead[ad->afheadcnt].fullname =
1489 xstrdup(list[z], pszSrcFile, __LINE__);
1490 if (ad->afhead[ad->afheadcnt].fullname) {
1491 p = strrchr(ad->afhead[ad->afheadcnt].fullname, '\\');
1492 if (!p)
1493 p = ad->afhead[ad->afheadcnt].fullname;
1494 else
1495 p++;
1496 ad->afhead[ad->afheadcnt].filename = p;
1497 ad->afhead[ad->afheadcnt].cbFile = ffb.cbFile;
1498 ad->afhead[ad->afheadcnt].date = ffb.fdateLastWrite;
1499 ad->afhead[ad->afheadcnt].time = ffb.ftimeLastWrite;
1500 ad->afhead[ad->afheadcnt].attrFile = (USHORT) ffb.attrFile;
1501 ad->afhead[ad->afheadcnt].flags = 0;
1502 if (ad->longest < strlen(ad->afhead[ad->afheadcnt].filename))
1503 ad->longest = strlen(ad->afhead[ad->afheadcnt].filename);
1504 if (ad->longestw < strlen(ad->afhead[ad->afheadcnt].fullname))
1505 ad->longestw = strlen(ad->afhead[ad->afheadcnt].fullname);
1506
1507 ad->afheadcnt++;
1508 }
1509 else {
1510 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Strdup failed.");
1511 ad->stopflag = 1;
1512 break;
1513 }
1514 }
1515 }
1516 }
1517 }
1518 }
1519 return didone;
1520}
1521
1522static int comparefullnames(const void *v1, const void *v2)
1523{
1524 ALLFILES *d1 = *(ALLFILES **) v1;
1525 ALLFILES *d2 = *(ALLFILES **) v2;
1526 int ret;
1527
1528 ret = stricmp(d1->fullname, d2->fullname);
1529 return ret;
1530}
1531
1532static int comparenames(const void *v1, const void *v2)
1533{
1534 ALLFILES *d1 = *(ALLFILES **) v1;
1535 ALLFILES *d2 = *(ALLFILES **) v2;
1536 int ret;
1537
1538 ret = stricmp(d1->filename, d2->filename);
1539 if (!ret)
1540 ret = comparefullnames(v1, v2);
1541 return ret;
1542}
1543
1544static int compareexts(const void *v1, const void *v2)
1545{
1546 ALLFILES *d1 = *(ALLFILES **) v1;
1547 ALLFILES *d2 = *(ALLFILES **) v2;
1548 register CHAR *p1, *p2;
1549 int ret;
1550
1551 p1 = strrchr(d1->filename, '.');
1552 p2 = strrchr(d2->filename, '.');
1553 if (!p1)
1554 p1 = NullStr;
1555 else
1556 p1++;
1557 if (!p2)
1558 p2 = NullStr;
1559 else
1560 p2++;
1561 ret = stricmp(p1, p2);
1562 if (!ret)
1563 ret = comparenames(v1, v2);
1564 return ret;
1565}
1566
1567static int comparesizes(const void *v1, const void *v2)
1568{
1569 ALLFILES *d1 = *(ALLFILES **) v1;
1570 ALLFILES *d2 = *(ALLFILES **) v2;
1571 int ret;
1572
1573 ret = (d1->cbFile > d2->cbFile) ? 1 : (d1->cbFile == d2->cbFile) ? 0 : -1;
1574 if (!ret)
1575 ret = comparenames(v1, v2);
1576 return ret;
1577}
1578
1579static int comparedates(const void *v1, const void *v2)
1580{
1581 ALLFILES *d1 = *(ALLFILES **) v1;
1582 ALLFILES *d2 = *(ALLFILES **) v2;
1583 int ret;
1584
1585 ret = TestFDates(NULL, NULL,
1586 &d2->date, &d2->time,
1587 &d1->date, &d1->time);
1588 /*(d1->date.year > d2->date.year) ? 1 :
1589 (d1->date.year < d2->date.year) ? -1 :
1590 (d1->date.month > d2->date.month) ? 1 :
1591 (d1->date.month < d2->date.month) ? -1 :
1592 (d1->date.day > d2->date.day) ? 1 :
1593 (d1->date.day < d2->date.day) ? -1 :
1594 (d1->time.hours > d2->time.hours) ? 1 :
1595 (d1->time.hours < d2->time.hours) ? -1 :
1596 (d1->time.minutes > d2->time.minutes) ? 1 :
1597 (d1->time.minutes < d2->time.minutes) ? -1 :
1598 (d1->time.twosecs > d2->time.twosecs) ? 1 :
1599 (d1->time.twosecs < d2->time.twosecs) ? -1 : 0;*/
1600
1601 if (!ret)
1602 ret = comparenames(v1, v2);
1603 return ret;
1604}
1605
1606static VOID ReSort(HWND hwnd)
1607{
1608 ALLDATA *pAD = WinQueryWindowPtr(hwnd, QWL_USER);
1609 register ULONG x, y;
1610
1611 pAD->selected = 0;
1612 pAD->ullSelectedBytes = 0;
1613 for (x = 0, y = 0; x < pAD->afheadcnt; x++) {
1614 if (!(pAD->afhead[x].flags & (AF_DELETED | AF_FILTERED))) {
1615 if (pAD->afhead[x].flags & AF_SELECTED) {
1616 pAD->selected++;
1617 pAD->ullSelectedBytes += pAD->afhead[x].cbFile;
1618 }
1619 pAD->afindex[y++] = &(pAD->afhead[x]);
1620 }
1621 } // for x
1622 pAD->afindexcnt = y;
1623 PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
1624 if (!pAD->stopflag && pAD->pfnCompare && pAD->afindexcnt) {
1625 WinSendMsg(hwnd, UM_RESCAN, MPFROMLONG(1), MPVOID);
1626 qsort(pAD->afindex, pAD->afindexcnt, sizeof(ALLFILES *), pAD->pfnCompare);
1627 }
1628}
1629
1630VOID FindDupesThread(VOID * args)
1631{
1632 register ULONG x, z;
1633 register CHAR *px, *pz;
1634 CHAR s[80];
1635 INT error;
1636 HWND hwnd = (HWND) args;
1637 HAB hab2 = (HAB) 0;
1638 HMQ hmq2 = (HMQ) 0;
1639 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
1640
1641 if (!DosRequestMutexSem(ad->hmtxScan, SEM_INDEFINITE_WAIT)) {
1642 priority_normal();
1643 hab2 = WinInitialize(0);
1644 if (hab2) {
1645 hmq2 = WinCreateMsgQueue(hab2, 0);
1646 if (hmq2) {
1647 WinCancelShutdown(hmq2, TRUE);
1648 IncrThreadUsage();
1649 if (ad->cursored <= ad->afindexcnt) {
1650 for (x = 0; x < ad->afheadcnt; x++)
1651 ad->afhead[x].flags &= (~(AF_DUPE | AF_SELECTED));
1652 DosSleep(0); //26 Aug 07 GKY 1
1653 for (x = 0; x < ad->afheadcnt && !ad->stopflag; x++) {
1654 if (!(ad->afhead[x].flags & (AF_DUPE | AF_FILTERED))) {
1655 if (!(x % 50)) {
1656 sprintf(s,
1657 GetPString(IDS_DUPECHECKINGOFTEXT), x, ad->afheadcnt);
1658 WinSetWindowText(ad->hwndStatus, s);
1659 }
1660 for (z = 0; z < ad->afheadcnt && !ad->stopflag; z++) {
1661 if (x != z &&
1662 !(ad->afhead[z].flags & (AF_DUPE | AF_FILTERED)))
1663 {
1664 if (ad->dupeflags & DP_SIZES) {
1665 if (ad->afhead[x].cbFile != ad->afhead[z].cbFile)
1666 goto SkipNonDupe;
1667 }
1668 if (ad->dupeflags & DP_DATES) {
1669 if (*(INT *) & ad->afhead[x].date !=
1670 *(INT *) & ad->afhead[z].date ||
1671 *(INT *) & ad->afhead[x].time !=
1672 *(INT *) & ad->afhead[z].time)
1673 goto SkipNonDupe;
1674 }
1675 if (ad->dupeflags & DP_NAMES) {
1676 if (ad->dupeflags & DP_EXTS) {
1677 px = strrchr(ad->afhead[x].filename, '.');
1678 pz = strrchr(ad->afhead[z].filename, '.');
1679 if ((px || pz) && (!px || !pz))
1680 goto SkipNonDupe;
1681 if (px) {
1682 *px = 0;
1683 *pz = 0;
1684 }
1685 }
1686 if (stricmp(ad->afhead[x].filename,
1687 ad->afhead[z].filename)) {
1688 if (ad->dupeflags & DP_EXTS) {
1689 if (px) {
1690 *px = '.';
1691 *pz = '.';
1692 }
1693 }
1694 goto SkipNonDupe;
1695 }
1696 if (ad->dupeflags & DP_EXTS) {
1697 if (px) {
1698 *px = '.';
1699 *pz = '.';
1700 }
1701 }
1702 }
1703 if (ad->dupeflags & DP_CRCS) {
1704 if (!(ad->afhead[x].flags & AF_CRCED)) {
1705 ad->afhead[x].CRC = CRCFile(ad->afhead[x].fullname,
1706 &error);
1707 if (!error)
1708 ad->afhead[x].flags |= AF_CRCED;
1709 }
1710 if (!(ad->afhead[z].flags & AF_CRCED)) {
1711 ad->afhead[z].CRC = CRCFile(ad->afhead[z].fullname,
1712 &error);
1713 if (!error)
1714 ad->afhead[z].flags |= AF_CRCED;
1715 }
1716 if ((ad->afhead[x].flags & AF_CRCED) &&
1717 (ad->afhead[z].flags & AF_CRCED)) {
1718 if (ad->afhead[x].CRC != ad->afhead[z].CRC)
1719 goto SkipNonDupe;
1720 }
1721 DosSleep(0);
1722 }
1723 ad->afhead[x].flags |= AF_DUPE;
1724 ad->afhead[z].flags |= AF_DUPE;
1725 SkipNonDupe:
1726 ;
1727 }
1728 } // for
1729 DosSleep(0);
1730 }
1731 } // for
1732 for (x = 0; x < ad->afheadcnt && !ad->stopflag; x++) {
1733 if (!(ad->afhead[x].flags & AF_DUPE))
1734 ad->afhead[x].flags |= AF_FILTERED;
1735 }
1736 ReSort(hwnd);
1737 WinInvalidateRect(hwnd, NULL, FALSE);
1738 }
1739 }
1740 }
1741 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1742 DosReleaseMutexSem(ad->hmtxScan);
1743 } // if got sem
1744 if (hmq2) {
1745 PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
1746 WinDestroyMsgQueue(hmq2);
1747 }
1748 if (hab2) {
1749 DecrThreadUsage();
1750 WinTerminate(hab2);
1751 }
1752}
1753
1754static VOID FilterAll(HWND hwnd, ALLDATA *ad);
1755
1756static VOID FilterList(HWND hwnd)
1757{
1758 ULONG x;
1759 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
1760 CHAR *p;
1761
1762 if (ad->cursored <= ad->afindexcnt) {
1763 x = ad->cursored - 1;
1764 x = (ad->invertsort) ? (ad->afindexcnt - 1) - x : x;
1765 p = strrchr(ad->afindex[x]->filename, '.');
1766 if (p) {
1767 strcpy(ad->mask.szMask, "*");
1768 strcat(ad->mask.szMask, p);
1769 }
1770 }
1771 *(ad->mask.prompt) = 0;
1772 ad->mask.fIsSeeAll = TRUE;
1773 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
1774 FM3ModHandle, MSK_FRAME, MPFROMP(&ad->mask)))
1775 FilterAll(hwnd, ad);
1776}
1777
1778static VOID FilterAll(HWND hwnd, ALLDATA *ad)
1779{
1780 ULONG x, z;
1781 BOOL ret;
1782
1783 if (ad) {
1784 for (x = 0; x < ad->afheadcnt; x++) {
1785 ret = FALSE;
1786 if (ad->mask.pszMasks[1]) {
1787 for (z = 0; ad->mask.pszMasks[z]; z++) {
1788 if (*ad->mask.pszMasks[z]) {
1789 if (*ad->mask.pszMasks[z] != '/') {
1790 if (wildcard((strchr(ad->mask.pszMasks[z], '\\') ||
1791 strchr(ad->mask.pszMasks[z], ':')) ?
1792 ad->afhead[x].fullname : ad->afhead[x].filename,
1793 ad->mask.pszMasks[z], FALSE))
1794 ret = TRUE;
1795 }
1796 else {
1797 if (wildcard((strchr(ad->mask.pszMasks[z], '\\') ||
1798 strchr(ad->mask.pszMasks[z], ':')) ?
1799 ad->afhead[x].fullname : ad->afhead[x].filename,
1800 ad->mask.pszMasks[z] + 1, FALSE)) {
1801 ret = FALSE;
1802 break;
1803 }
1804 }
1805 }
1806 }
1807 }
1808 else if (*ad->mask.szMask) {
1809 if (wildcard((strchr(ad->mask.szMask, '\\') ||
1810 strchr(ad->mask.szMask, ':')) ?
1811 ad->afhead[x].fullname : ad->afhead[x].filename,
1812 ad->mask.szMask, FALSE))
1813 ret = TRUE;
1814 }
1815 else
1816 ret = TRUE;
1817
1818 if (ret) {
1819 if ((!(ad->mask.attrFile & FILE_HIDDEN)
1820 && (ad->afhead[x].attrFile & FILE_HIDDEN))
1821 || (!(ad->mask.attrFile & FILE_SYSTEM)
1822 && (ad->afhead[x].attrFile & FILE_SYSTEM))
1823 || (!(ad->mask.attrFile & FILE_READONLY)
1824 && (ad->afhead[x].attrFile & FILE_READONLY))
1825 || (!(ad->mask.attrFile & FILE_ARCHIVED)
1826 && (ad->afhead[x].attrFile & FILE_ARCHIVED)))
1827 ret = FALSE;
1828 else
1829 if (((ad->mask.antiattr & FILE_HIDDEN)
1830 && !(ad->afhead[x].attrFile & FILE_HIDDEN))
1831 || ((ad->mask.antiattr & FILE_SYSTEM)
1832 && !(ad->afhead[x].attrFile & FILE_SYSTEM))
1833 || ((ad->mask.antiattr & FILE_READONLY)
1834 && !(ad->afhead[x].attrFile & FILE_READONLY))
1835 || ((ad->mask.antiattr & FILE_ARCHIVED)
1836 && !(ad->afhead[x].attrFile & FILE_ARCHIVED)))
1837 ret = FALSE;
1838 }
1839
1840 if (!ret)
1841 ad->afhead[x].flags |= AF_FILTERED;
1842 else
1843 ad->afhead[x].flags &= (~AF_FILTERED);
1844 }
1845 ReSort(hwnd);
1846 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1847 WinInvalidateRect(hwnd, NULL, FALSE);
1848 }
1849}
1850
1851static ULONG RemoveDeleted(HWND hwnd)
1852{
1853 ALLDATA *pAD = WinQueryWindowPtr(hwnd, QWL_USER);
1854 ULONG oldafheadcnt = pAD->afheadcnt;
1855 register ULONG x, y;
1856
1857 for (x = 0; x < pAD->afheadcnt; x++) {
1858 if (pAD->afhead[x].flags & AF_DELETED) {
1859 for (y = x; y < pAD->afheadcnt; y++) {
1860 if (~pAD->afhead[y].flags & AF_DELETED)
1861 break;
1862 if (pAD->afhead[y].flags & AF_SELECTED &&
1863 ~pAD->afhead[y].flags & AF_FILTERED) {
1864 pAD->selected--;
1865 pAD->ullSelectedBytes -= pAD->afhead[y].cbFile;
1866 }
1867 xfree(pAD->afhead[y].fullname, pszSrcFile, __LINE__);
1868 }
1869 memmove(&(pAD->afhead[x]), &(pAD->afhead[y]),
1870 (pAD->afheadcnt - y) * sizeof(ALLFILES));
1871 pAD->afheadcnt -= (y - x);
1872 }
1873 } // for x
1874 if (pAD->afheadcnt != oldafheadcnt) {
1875
1876 ALLFILES *tempa, **templ;
1877
1878 if (!pAD->afheadcnt)
1879 FreeAllFilesList(hwnd);
1880 else {
1881 tempa =
1882 xrealloc(pAD->afhead, pAD->afheadcnt * sizeof(ALLFILES), pszSrcFile,
1883 __LINE__);
1884 if (tempa) {
1885 pAD->afhead = tempa;
1886 pAD->afalloc = pAD->afheadcnt;
1887 }
1888 templ =
1889 xrealloc(pAD->afindex, pAD->afheadcnt * sizeof(ALLFILES *), pszSrcFile,
1890 __LINE__);
1891 if (templ)
1892 pAD->afindex = templ;
1893 DosPostEventSem(CompactSem);
1894 ReSort(hwnd);
1895 }
1896 }
1897 return pAD->afheadcnt;
1898}
1899
1900static VOID DoADir(HWND hwnd, CHAR * pathname)
1901{
1902 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
1903 CHAR *filename, *enddir;
1904 PFILEFINDBUF3L pffbArray, pffbFile;
1905 HDIR hdir = HDIR_CREATE;
1906 ULONG ulFindCnt;
1907 ULONG ulFindMax;
1908 ULONG ulBufBytes;
1909 ULONG x;
1910 APIRET rc;
1911 static BOOL fDone;
1912
1913 filename = xmalloc(CCHMAXPATH + 100, pszSrcFile, __LINE__);
1914 if (!filename)
1915 return;
1916
1917 ulFindMax = FilesToGet;
1918 if (fRemoteBug && isalpha(*pathname) && pathname[1] == ':' &&
1919 pathname[2] == '\\' &&
1920 (driveflags[toupper(*pathname) - 'A'] & DRIVE_REMOTE))
1921 ulFindMax = 1;
1922
1923 ulBufBytes = sizeof(FILEFINDBUF3L) * ulFindMax;
1924 pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__);
1925 if (!pffbArray) {
1926 xfree(filename, pszSrcFile, __LINE__);
1927 return;
1928 }
1929
1930 strcpy(filename, pathname);
1931 enddir = &filename[strlen(filename) - 1];
1932 if (*enddir != '\\') {
1933 enddir++;
1934 *enddir = '\\';
1935 }
1936 enddir++;
1937 strcpy(enddir, "*");
1938 DosError(FERR_DISABLEHARDERR);
1939 ulFindCnt = ulFindMax;
1940 rc = xDosFindFirst(filename, &hdir, FILE_NORMAL | FILE_ARCHIVED |
1941 FILE_READONLY | FILE_DIRECTORY | FILE_SYSTEM |
1942 FILE_HIDDEN,
1943 pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARDL);
1944 if (!rc) {
1945 do {
1946 priority_normal();
1947 pffbFile = pffbArray;
1948 for (x = 0; x < ulFindCnt; x++) {
1949 if (pffbFile->attrFile & FILE_DIRECTORY) {
1950 // Skip . and ..
1951 if (pffbFile->achName[0] != '.' ||
1952 (pffbFile->achName[1] &&
1953 (pffbFile->achName[1] != '.' || pffbFile->achName[2]))) {
1954 strcpy(enddir, pffbFile->achName);
1955 DoADir(hwnd, filename);
1956 }
1957 }
1958 else {
1959 *enddir = 0;
1960 strcpy(enddir, pffbFile->achName);
1961 if (strlen(filename) > CCHMAXPATH) {
1962 // Complain if pathnames exceeds max
1963 DosFindClose(hdir);
1964 xfree(pffbArray, pszSrcFile, __LINE__);
1965 xfree(filename, pszSrcFile, __LINE__);
1966 if (!fDone) {
1967 fDone = TRUE;
1968 saymsg(MB_OK | MB_ICONASTERISK,
1969 HWND_DESKTOP,
1970 GetPString(IDS_WARNINGTEXT),
1971 "One or more of your files has a full path name that exceeds the OS/2 maximum");
1972 }
1973 return;
1974 }
1975 if (!ad->afalloc || ad->afheadcnt > ad->afalloc - 1) {
1976
1977 ALLFILES *temp;
1978
1979 temp = xrealloc(ad->afhead, (ad->afalloc + 1000) *
1980 sizeof(ALLFILES), pszSrcFile, __LINE__);
1981 if (!temp) {
1982 ad->stopflag = 1;
1983 break;
1984 }
1985 else {
1986 ad->afhead = temp;
1987 if (ad->stopflag)
1988 break;
1989 ad->afalloc += 1000;
1990 }
1991 }
1992 ad->afhead[ad->afheadcnt].fullname =
1993 xstrdup(filename, pszSrcFile, __LINE__);
1994 if (!ad->afhead[ad->afheadcnt].fullname) {
1995 ad->stopflag = 1;
1996 break;
1997 }
1998 else {
1999 ad->afhead[ad->afheadcnt].filename =
2000 ad->afhead[ad->afheadcnt].fullname + (enddir - filename);
2001 ad->afhead[ad->afheadcnt].cbFile = pffbFile->cbFile;
2002 ad->afhead[ad->afheadcnt].date = pffbFile->fdateLastWrite;
2003 ad->afhead[ad->afheadcnt].time = pffbFile->ftimeLastWrite;
2004 ad->afhead[ad->afheadcnt].attrFile = (USHORT) pffbFile->attrFile;
2005 ad->afhead[ad->afheadcnt].flags = 0;
2006 ad->afheadcnt++;
2007 if (ad->longest < pffbFile->cchName)
2008 ad->longest = pffbFile->cchName;
2009 if (ad->longestw < pffbFile->cchName + (enddir - filename))
2010 ad->longestw = pffbFile->cchName + (enddir - filename);
2011 }
2012 }
2013 pffbFile = (PFILEFINDBUF3L)((PBYTE)pffbFile + pffbFile->oNextEntryOffset);
2014 } // for
2015 if (ad->stopflag)
2016 break;
2017 ulFindCnt = ulFindMax;
2018 rc = xDosFindNext(hdir,
2019 pffbArray,
2020 sizeof(FILEFINDBUF3L) * ulFindCnt,
2021 &ulFindCnt,
2022 FIL_STANDARDL);
2023 } while (!rc);
2024 DosFindClose(hdir);
2025 }
2026
2027 if (rc && rc != ERROR_NO_MORE_FILES) {
2028 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
2029 GetPString(IDS_CANTFINDDIRTEXT), filename);
2030 }
2031
2032 xfree(pffbArray, pszSrcFile, __LINE__);
2033 xfree(filename, pszSrcFile, __LINE__);
2034}
2035
2036static VOID FindAllThread(VOID * args)
2037{
2038 ULONG ulDriveNum, ulDriveMap, x;
2039 CHAR startname[] = " :\\";
2040 HWND hwnd = (HWND) args;
2041 HAB hab2 = (HAB) 0;
2042 HMQ hmq2 = (HMQ) 0;
2043 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
2044
2045 if (!DosRequestMutexSem(ad->hmtxScan, SEM_INDEFINITE_WAIT)) {
2046 priority_normal();
2047 hab2 = WinInitialize(0);
2048 if (hab2) {
2049 hmq2 = WinCreateMsgQueue(hab2, 0);
2050 if (hmq2) {
2051 WinCancelShutdown(hmq2, TRUE);
2052 IncrThreadUsage();
2053 if (!*ad->szFindPath) {
2054 DosError(FERR_DISABLEHARDERR);
2055 if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) {
2056 for (x = 2; x < 26 && !ad->stopflag; x++) {
2057 if ((ulDriveMap & (1 << x)) && ad->abDrvFlags[x]) {
2058 *startname = (CHAR) (x + 'A');
2059 DoADir(hwnd, startname);
2060 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2061 DosSleep(0); //26 Aug 07 GKY 1
2062 }
2063 }
2064 }
2065 }
2066 else
2067 DoADir(hwnd, ad->szFindPath);
2068 DosPostEventSem(CompactSem);
2069 }
2070 }
2071 if (ad->afalloc != ad->afheadcnt) {
2072
2073 ALLFILES *tempa, **templ;
2074
2075 tempa =
2076 xrealloc(ad->afhead, sizeof(ALLFILES) * ad->afheadcnt, pszSrcFile,
2077 __LINE__);
2078 if (tempa) {
2079 ad->afhead = tempa;
2080 ad->afalloc = ad->afheadcnt;
2081 }
2082 templ =
2083 xrealloc(ad->afindex, sizeof(ALLFILES *) * ad->afheadcnt, pszSrcFile,
2084 __LINE__);
2085 if (templ)
2086 ad->afindex = templ;
2087 DosPostEventSem(CompactSem);
2088 }
2089
2090 if (!ad->stopflag) {
2091 PostMsg(hwnd, UM_RESCAN, MPFROMLONG(1), MPVOID);
2092 ReSort(hwnd);
2093 }
2094 DosReleaseMutexSem(ad->hmtxScan);
2095 }
2096 if (hmq2) {
2097 PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
2098 WinDestroyMsgQueue(hmq2);
2099 }
2100 if (hab2) {
2101 DecrThreadUsage();
2102 WinTerminate(hab2);
2103 }
2104}
2105
2106MRESULT EXPENTRY AFDrvsWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2107{
2108 switch (msg) {
2109 case WM_INITDLG:
2110 if (mp2) {
2111
2112 ULONG ulDriveNum, ulDriveMap, x;
2113 CHAR startname[] = " :";
2114 SHORT sSelect;
2115 ALLDATA *ad;
2116
2117 ad = (ALLDATA *) mp2;
2118 WinSetWindowPtr(hwnd, QWL_USER, mp2);
2119 DosError(FERR_DISABLEHARDERR);
2120 if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) {
2121 for (x = 2; x < 26 && !ad->stopflag; x++) {
2122 if (!(driveflags[x] & (DRIVE_IGNORE | DRIVE_INVALID))) {
2123 if (ulDriveMap & (1 << x)) {
2124 *startname = (CHAR) (x + 'A');
2125 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, DRVS_LISTBOX,
2126 LM_INSERTITEM,
2127 MPFROM2SHORT(LIT_END, 0),
2128 MPFROMP(startname));
2129 if (sSelect >= 0 && ad->abDrvFlags[x])
2130 WinSendDlgItemMsg(hwnd, DRVS_LISTBOX, LM_SELECTITEM,
2131 MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
2132 }
2133 }
2134 }
2135 }
2136 }
2137 else
2138 WinDismissDlg(hwnd, 0);
2139 break;
2140
2141 case WM_CONTROL:
2142 switch (SHORT1FROMMP(mp1)) {
2143 case DRVS_LISTBOX:
2144 switch (SHORT2FROMMP(mp1)) {
2145 case LN_ENTER:
2146 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
2147 break;
2148 }
2149 break;
2150 }
2151 return 0;
2152
2153 case WM_COMMAND:
2154 switch (SHORT1FROMMP(mp1)) {
2155 case DID_OK:
2156 {
2157 INT x;
2158 SHORT sSelect;
2159 CHAR filename[3];
2160 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
2161
2162 memset(ad->abDrvFlags, 0, sizeof(ad->abDrvFlags));
2163 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, DRVS_LISTBOX,
2164 LM_QUERYSELECTION,
2165 MPFROM2SHORT(LIT_FIRST, 0),
2166 MPVOID);
2167 while (sSelect >= 0) {
2168 *filename = 0;
2169 if (WinSendDlgItemMsg(hwnd, DRVS_LISTBOX, LM_QUERYITEMTEXT,
2170 MPFROM2SHORT(sSelect, 2),
2171 MPFROMP(filename)) && *filename)
2172 ad->abDrvFlags[*filename - 'A'] = 1;
2173 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, DRVS_LISTBOX,
2174 LM_QUERYSELECTION,
2175 MPFROM2SHORT(sSelect, 0),
2176 MPVOID);
2177 }
2178 for (x = 2; x < 26; x++) {
2179 if (ad->abDrvFlags[x]) {
2180 WinDismissDlg(hwnd, 1);
2181 return 0;
2182 }
2183 }
2184 }
2185 WinDismissDlg(hwnd, 0);
2186 break;
2187
2188 case IDM_HELP:
2189 if (hwndHelp)
2190 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
2191 MPFROM2SHORT(HELP_DRVSWND, 0), MPFROMSHORT(HM_RESOURCEID));
2192 break;
2193
2194 case DID_CANCEL:
2195 WinDismissDlg(hwnd, 0);
2196 break;
2197 }
2198 return 0;
2199 }
2200 return WinDefDlgProc(hwnd, msg, mp1, mp2);
2201}
2202
2203static HPS InitWindow(HWND hwnd)
2204{
2205 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
2206 HPS hps = (HPS) 0;
2207 SIZEL sizel;
2208 FONTMETRICS FontMetrics;
2209
2210 if (ad) {
2211 sizel.cx = sizel.cy = 0;
2212 hps = GpiCreatePS(WinQueryAnchorBlock(hwnd), WinOpenWindowDC(hwnd),
2213 (PSIZEL) & sizel, PU_PELS | GPIF_DEFAULT | GPIT_MICRO |
2214 GPIA_ASSOC);
2215 if (hps) {
2216 GpiSetCp(hps, (ULONG) ad->fattrs.usCodePage);
2217 GpiCreateLogFont(hps, NULL, FIXED_FONT_LCID, &ad->fattrs);
2218 GpiSetCharSet(hps, FIXED_FONT_LCID);
2219 GpiQueryFontMetrics(hps, sizeof(FontMetrics), &FontMetrics);
2220 ad->fattrs.lAveCharWidth = FontMetrics.lAveCharWidth;
2221 ad->fattrs.lMaxBaselineExt = FontMetrics.lMaxBaselineExt;
2222 ad->lMaxAscender = max(FontMetrics.lMaxAscender, 0);
2223 ad->lMaxDescender = max(FontMetrics.lMaxDescender, 0);
2224 ad->lMaxHeight = ad->lMaxDescender + ad->lMaxAscender;
2225 if (ad->fattrs.usCodePage != FontMetrics.usCodePage) {
2226 ad->fattrs.usCodePage = FontMetrics.usCodePage;
2227 Codepage = ad->fattrs.usCodePage;
2228 PrfWriteProfileData(fmprof,
2229 appname,
2230 "Seeall.Codepage",
2231 &ad->fattrs.usCodePage, sizeof(USHORT));
2232 }
2233 else if (ad->fattrs.usCodePage) {
2234
2235 HMQ hmq;
2236 ULONG cps[50], len, x;
2237
2238 if (!DosQueryCp(sizeof(cps), cps, &len)) {
2239 for (x = 0; x < len / sizeof(ULONG); x++) {
2240 if (cps[x] == (ULONG) ad->fattrs.usCodePage) {
2241 hmq = WinQueryWindowULong(hwnd, QWL_HMQ);
2242 WinSetCp(hmq, ad->fattrs.usCodePage);
2243 break;
2244 }
2245 }
2246 }
2247 DosSetProcessCp((ULONG) ad->fattrs.usCodePage);
2248 }
2249 GpiSetBackMix(hps, BM_OVERPAINT);
2250 }
2251 }
2252 return (hps);
2253}
2254
2255static VOID PaintLine(HWND hwnd, HPS hps, ULONG whichfile, ULONG topfile,
2256 RECTL * Rectl)
2257{
2258 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
2259 POINTL ptl;
2260 CHAR szBuff[CCHMAXPATH + 80], szCmmaFmtFileSize[81];
2261 ULONG len, y;
2262
2263 y = (ad->invertsort) ? (ad->afindexcnt - 1) - whichfile : whichfile;
2264 ptl.y = (Rectl->yTop -
2265 (ad->lMaxHeight * (((whichfile + 1) - topfile) + 1)));
2266 ptl.x = ad->horzscroll;
2267 if (ptl.y < Rectl->yBottom || ptl.y > Rectl->yTop || y > ad->afindexcnt)
2268 return;
2269 GpiSetBackMix(hps, BM_OVERPAINT);
2270 if (ad->afindex[y]->flags & AF_SELECTED) {
2271 GpiSetColor(hps, standardcolors[Colors[COLORS_SELECTEDNORMALFORE]]);
2272 GpiSetBackColor(hps, (whichfile == ad->cursored - 1) ?
2273 standardcolors[Colors[COLORS_CURSOREDSELECTEDBACK]] :
2274 standardcolors[Colors[COLORS_SELECTEDBACK]]);
2275 }
2276 else {
2277 GpiSetColor(hps,
2278 ((ad->afindex[y]->attrFile & (FILE_SYSTEM | FILE_HIDDEN)) !=
2279 0) ? standardcolors[Colors[COLORS_SYSTEMFORE]] : ((ad->
2280 afindex
2281 [y]->
2282 attrFile &
2283 FILE_READONLY)
2284 !=
2285 0) ?
2286 standardcolors[Colors[COLORS_READONLYFORE]] :
2287 standardcolors[Colors[COLORS_NORMALFORE]]);
2288 GpiSetBackColor(hps,
2289 (whichfile ==
2290 ad->cursored -
2291 1) ? standardcolors[Colors[COLORS_CURSOREDNORMALBACK]] :
2292 standardcolors[Colors[COLORS_NORMALBACK]]);
2293 }
2294 CommaFmtULL(szCmmaFmtFileSize,
2295 sizeof(szCmmaFmtFileSize), ad->afindex[y]->cbFile, ' ');
2296 len = sprintf(szBuff,
2297 "%c%-*.*s %-12s %c%c%c%c%c %04u/%02u/%02u %02u:%02u:%02u ",
2298 whichfile == ad->cursored - 1 ? '>' : ' ',
2299 ad->fullnames ? ad->longestw : ad->longest,
2300 ad->fullnames ? ad->longestw : ad->longest,
2301 ad->fullnames ? ad->afindex[y]->fullname :
2302 ad->afindex[y]->filename,
2303 szCmmaFmtFileSize,
2304 "-A"[((ad->afindex[y]->attrFile & FILE_ARCHIVED) != 0)],
2305 "-R"[((ad->afindex[y]->attrFile & FILE_READONLY) != 0)],
2306 "-H"[((ad->afindex[y]->attrFile & FILE_HIDDEN) != 0)],
2307 "-S"[((ad->afindex[y]->attrFile & FILE_SYSTEM) != 0)],
2308 "-D"[((ad->afindex[y]->attrFile & FILE_DIRECTORY) != 0)],
2309 ad->afindex[y]->date.year + 1980,
2310 ad->afindex[y]->date.month,
2311 ad->afindex[y]->date.day,
2312 ad->afindex[y]->time.hours,
2313 ad->afindex[y]->time.minutes,
2314 ad->afindex[y]->time.twosecs * 2);
2315 GpiCharStringAt(hps, &ptl, len, szBuff);
2316 GpiQueryCurrentPosition(hps, &ptl);
2317 if (ptl.x + abs(ad->horzscroll) > ad->maxx) {
2318 ad->maxx = ptl.x + abs(ad->horzscroll);
2319 WinSendMsg(ad->hhscroll, SBM_SETTHUMBSIZE,
2320 MPFROM2SHORT((SHORT) Rectl->xRight, (SHORT) ad->maxx), MPVOID);
2321 }
2322}
2323
2324MRESULT EXPENTRY SeeStatusProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2325{
2326 switch (msg) {
2327 case WM_CREATE:
2328 return CommonTextProc(hwnd, msg, mp1, mp2);
2329
2330 case WM_SETFOCUS:
2331 if (mp2)
2332 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
2333 break;
2334
2335 case WM_PAINT:
2336 {
2337 SWP swp;
2338 POINTL ptl;
2339 HPS hps;
2340
2341 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
2342 hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
2343 if (hps) {
2344 WinQueryWindowPos(hwnd, &swp);
2345 ptl.x = swp.x - 1;
2346 ptl.y = swp.y + swp.cy + 2;
2347 GpiMove(hps, &ptl);
2348 GpiSetColor(hps, CLR_WHITE);
2349 ptl.x = swp.x + swp.cx;
2350 GpiLine(hps, &ptl);
2351 WinReleasePS(hps);
2352 }
2353 }
2354 break;
2355
2356 case UM_FOCUSME:
2357 WinSetFocus(HWND_DESKTOP, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2358 FID_CLIENT));
2359 return 0;
2360 }
2361 return PFNWPStatic(hwnd, msg, mp1, mp2);
2362}
2363
2364MRESULT EXPENTRY SeeFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2365{
2366 PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
2367
2368 switch (msg) {
2369 case WM_BUTTON1UP:
2370 case WM_BUTTON2UP:
2371 case WM_BUTTON3UP:
2372 case WM_MOUSEMOVE:
2373 case WM_CHORD:
2374 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
2375 break;
2376
2377 case WM_CHAR:
2378 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
2379 break;
2380
2381 case WM_CALCFRAMERECT:
2382 {
2383 MRESULT mr;
2384 PRECTL prectl;
2385
2386 mr = oldproc(hwnd, msg, mp1, mp2);
2387
2388 /*
2389 * Calculate the position of the client rectangle.
2390 * Otherwise, we'll see a lot of redraw when we move the
2391 * client during WM_FORMATFRAME.
2392 */
2393
2394 if (mr && mp2) {
2395 prectl = (PRECTL) mp1;
2396 prectl->yBottom += 22;
2397 prectl->yTop -= 24;
2398 }
2399 return mr;
2400 }
2401
2402 case WM_FORMATFRAME:
2403 {
2404 SHORT sCount;
2405 PSWP pswp, pswpClient, pswpNew;
2406
2407 sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2);
2408
2409 /*
2410 * Reformat the frame to "squeeze" the client
2411 * and make room for status window sibling beneath
2412 */
2413
2414 pswp = (PSWP) mp1;
2415 {
2416 SHORT x;
2417
2418 for (x = 0; x < sCount; x++) {
2419 if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
2420 pswpClient = pswp;
2421 break;
2422 }
2423 pswp++;
2424 }
2425 }
2426 pswpNew = (PSWP) mp1 + sCount;
2427 *pswpNew = *pswpClient;
2428 pswpNew->hwnd = WinWindowFromID(hwnd, SEEALL_STATUS);
2429 pswpNew->x = pswpClient->x + 2;
2430 pswpNew->y = pswpClient->y + 2;
2431 pswpNew->cx = pswpClient->cx - 3;
2432 pswpNew->cy = 20;
2433 pswpClient->y = pswpNew->y + pswpNew->cy + 3;
2434 pswpClient->cy = (pswpClient->cy - pswpNew->cy) - 5;
2435 sCount++;
2436 return MRFROMSHORT(sCount);
2437 }
2438
2439 case WM_QUERYFRAMECTLCOUNT:
2440 {
2441 SHORT sCount;
2442
2443 sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2);
2444 sCount++;
2445 return MRFROMSHORT(sCount);
2446 }
2447 }
2448 return oldproc(hwnd, msg, mp1, mp2);
2449}
2450
2451MRESULT EXPENTRY SeeAllWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2452{
2453 ALLDATA *pAD = WinQueryWindowPtr(hwnd, QWL_USER);
2454
2455 switch (msg) {
2456 case WM_CREATE:
2457 // fprintf(stderr,"Seeall: WM_CREATE\n");
2458 WinSetWindowPtr(hwnd, QWL_USER, NULL);
2459# ifdef FORTIFY
2460 Fortify_EnterScope();
2461# endif
2462 pAD = xmallocz(sizeof(ALLDATA), pszSrcFile, __LINE__);
2463 if (pAD) {
2464 HWND hwndFrame;
2465
2466 pAD->size = sizeof(ALLDATA);
2467 hwndFrame = WinQueryWindow(hwnd, QW_PARENT);
2468 pAD->hwndFrame = hwndFrame;
2469 pAD->mask.attrFile = FILE_READONLY | FILE_HIDDEN |
2470 FILE_SYSTEM | FILE_ARCHIVED;
2471 pAD->mask.fNoDirs = TRUE;
2472 *(pAD->mask.prompt) = 0;
2473 WinSetWindowPtr(hwnd, QWL_USER, (PVOID) pAD);
2474 pAD->pfnCompare = comparenames;
2475 if (Firsttime) {
2476
2477 ULONG size;
2478
2479 size = sizeof(USHORT);
2480 PrfQueryProfileData(fmprof,
2481 appname,
2482 "Seeall.Codepage", (PVOID) & Codepage, &size);
2483 size = sizeof(BOOL);
2484 PrfQueryProfileData(fmprof,
2485 appname,
2486 "Seeall.Fullnames", (PVOID) & Fullnames, &size);
2487 size = sizeof(USHORT);
2488 PrfQueryProfileData(fmprof,
2489 appname,
2490 "Seeall.Sort", (PVOID) & SortType, &size);
2491 size = sizeof(BOOL);
2492 PrfQueryProfileData(fmprof,
2493 appname,
2494 "Seeall.SortReverse",
2495 (PVOID) & SortReverse, &size);
2496 memset(&Fattrs, 0, sizeof(Fattrs));
2497 size = sizeof(Fattrs);
2498 Fattrs.usRecordLength = sizeof(Fattrs);
2499 Fattrs.lMaxBaselineExt = 16;
2500 Fattrs.lAveCharWidth = 8;
2501 Fattrs.usCodePage = Codepage;
2502 strcpy(Fattrs.szFacename, GetPString(IDS_SYSMONOTEXT));
2503 PrfQueryProfileData(fmprof,
2504 appname,
2505 "Seeall.Fattrs", (PVOID) & Fattrs, &size);
2506 size = sizeof(LONG) * COLORS_MAX;
2507 PrfQueryProfileData(fmprof,
2508 appname, "Seeall.Colors", (PVOID) Colors, &size);
2509 Firsttime = FALSE;
2510 }
2511 switch (SortType) {
2512 case IDM_SORTEASIZE:
2513 pAD->pfnCompare = (PFNSORT) NULL;
2514 break;
2515 case IDM_SORTNAME:
2516 pAD->pfnCompare = comparefullnames;
2517 break;
2518 case IDM_SORTFILENAME:
2519 pAD->pfnCompare = comparenames;
2520 break;
2521 case IDM_SORTSIZE:
2522 pAD->pfnCompare = comparesizes;
2523 break;
2524 case IDM_SORTLWDATE:
2525 pAD->pfnCompare = comparedates;
2526 break;
2527 case IDM_SORTFIRST:
2528 pAD->pfnCompare = compareexts;
2529 break;
2530 }
2531 pAD->invertsort = SortReverse;
2532 pAD->fattrs = Fattrs;
2533 pAD->fullnames = Fullnames;
2534 pAD->stopflag = 0;
2535 pAD->cursored = pAD->topfile = 1;
2536 pAD->fattrs.usCodePage = Codepage;
2537 memcpy(pAD->aulColors, Colors, sizeof(LONG) * COLORS_MAX);
2538 pAD->hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
2539 SetConditionalCascade(pAD->hwndMenu, IDM_DELETESUBMENU,
2540 (fDefaultDeletePerm) ?
2541 IDM_PERMDELETE : IDM_DELETE);
2542 SetConditionalCascade(pAD->hwndMenu, IDM_MOVEMENU, IDM_MOVE);
2543 SetConditionalCascade(pAD->hwndMenu, IDM_COPYMENU, IDM_COPY);
2544 SetConditionalCascade(pAD->hwndMenu, IDM_OPENSUBMENU, IDM_OPENDEFAULT);
2545 SetConditionalCascade(pAD->hwndMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
2546 if (fWorkPlace) {
2547 WinSendMsg(pAD->hwndMenu, MM_DELETEITEM,
2548 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
2549 WinSendMsg(pAD->hwndMenu, MM_DELETEITEM,
2550 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
2551 }
2552 pAD->hwndClient = hwnd;
2553 pAD->hps = InitWindow(hwnd);
2554 pAD->hvscroll = WinWindowFromID(hwndFrame, FID_VERTSCROLL);
2555 pAD->hhscroll = WinWindowFromID(hwndFrame, FID_HORZSCROLL);
2556 pAD->multiplier = 1;
2557 if (_beginthread(MakeSeeObjWinThread, NULL, 122880, (PVOID) pAD) == -1)
2558 Runtime_Error(pszSrcFile, __LINE__,
2559 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2560 else {
2561 if (!DosCreateMutexSem(NULL, &pAD->hmtxScan, 0, FALSE)) {
2562 pAD->hwndStatus = WinCreateWindow(hwndFrame,
2563 WC_SEESTATUS,
2564 NullStr,
2565 WS_VISIBLE | SS_TEXT |
2566 DT_LEFT | DT_VCENTER,
2567 0,
2568 0,
2569 0,
2570 0,
2571 hwndFrame,
2572 HWND_TOP,
2573 SEEALL_STATUS, NULL, NULL);
2574 if (!pAD->hwndStatus)
2575 Win_Error2(hwndFrame, hwnd, pszSrcFile, __LINE__,
2576 IDS_WINCREATEWINDOW);
2577 else {
2578 PFNWP oldproc;
2579
2580 oldproc = WinSubclassWindow(hwndFrame, SeeFrameWndProc);
2581 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
2582 }
2583 break;
2584 }
2585 }
2586 }
2587 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2588 break;
2589
2590 case UM_SETUP5:
2591 // fprintf(stderr,"Seeall: UM_SETUP5\n");
2592 if (pAD) {
2593 if (mp1 && *((CHAR *)mp1))
2594 strcpy(pAD->szFindPath, (CHAR *)mp1);
2595 else {
2596 if (!WinDlgBox(HWND_DESKTOP, hwnd, AFDrvsWndProc,
2597 FM3ModHandle, DRVS_FRAME, (PVOID) pAD)) {
2598 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2599 return 0;
2600 }
2601 }
2602 if (_beginthread(FindAllThread, NULL, 524288, (PVOID) hwnd) == -1) {
2603 Runtime_Error(pszSrcFile, __LINE__,
2604 GetPString(IDS_COULDNTSTARTTHREADTEXT));
2605 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2606 }
2607 else {
2608 DosSleep(50);//05 Aug 07 GKY 100
2609 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
2610 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
2611 }
2612 }
2613 else
2614 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2615 return 0;
2616
2617 case UM_UPDATERECORDLIST:
2618 if (mp1) {
2619
2620 APIRET rc;
2621
2622 rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN);
2623 if (!rc) {
2624 WinSetPointer(HWND_DESKTOP, hptrBusy);
2625 if (UpdateList(hwnd, mp1)) {
2626 FreeList(mp1);
2627 RemoveDeleted(hwnd);
2628 ReSort(hwnd);
2629 WinInvalidateRect(hwnd, NULL, FALSE);
2630 }
2631 DosReleaseMutexSem(pAD->hmtxScan);
2632 WinSetPointer(HWND_DESKTOP, hptrArrow);
2633 }
2634 }
2635 return 0;
2636
2637 case UM_SETUP2:
2638// fprintf(stderr,"Seeall: UM_SETUP2\n");
2639 if (pAD) {
2640
2641 CHAR s[256];
2642 BOOL once = FALSE;
2643 ULONG x, ulDriveNum, ulDriveMap;
2644
2645 strcpy(s, GetPString(IDS_SEEALLTITLETEXT));
2646 if (!*pAD->szFindPath) {
2647 DosError(FERR_DISABLEHARDERR);
2648 if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) {
2649 for (x = 2; x < 26 && !pAD->stopflag; x++) {
2650 if ((ulDriveMap & (1 << x)) && pAD->abDrvFlags[x]) {
2651 sprintf(&s[strlen(s)], "%s%c:", (once) ? ", " : " (", x + 'A');
2652 once = TRUE;
2653 }
2654 }
2655 if (once)
2656 strcat(s, ")");
2657 }
2658 }
2659 else {
2660 strcat(s, " (");
2661 strcat(s, pAD->szFindPath);
2662 strcat(s, ")");
2663 }
2664 WinSetWindowText(WinQueryWindow(hwnd, QW_PARENT), s);
2665 }
2666 return 0;
2667
2668 case UM_SETUP3:
2669// fprintf(stderr,"Seeall: UM_SETUP3\n");
2670 if (pAD) {
2671 pAD->multiplier = pAD->afindexcnt / 32767;
2672 if (pAD->multiplier * 32767 != pAD->afindexcnt)
2673 pAD->multiplier++;
2674 if (!pAD->multiplier)
2675 pAD->multiplier++;
2676 {
2677 RECTL Rectl;
2678 ULONG numlines;
2679
2680 WinQueryWindowRect(hwnd, &Rectl);
2681 numlines = NumLines(&Rectl, pAD);
2682 if (numlines) {
2683 WinSendMsg(pAD->hhscroll, SBM_SETTHUMBSIZE,
2684 MPFROM2SHORT((SHORT) Rectl.xRight, (SHORT) pAD->maxx),
2685 MPVOID);
2686 WinSendMsg(pAD->hvscroll, SBM_SETTHUMBSIZE,
2687 MPFROM2SHORT((SHORT) numlines,
2688 (SHORT) min(pAD->afindexcnt, 32767)),
2689 MPFROM2SHORT(1, pAD->afindexcnt + 1));
2690 WinSendMsg(pAD->hhscroll, SBM_SETSCROLLBAR,
2691 MPFROMSHORT((SHORT) abs(pAD->horzscroll)),
2692 MPFROM2SHORT(0, (SHORT) (pAD->maxx - Rectl.xRight)));
2693 WinSendMsg(pAD->hvscroll, SBM_SETSCROLLBAR,
2694 MPFROMSHORT((SHORT) (pAD->topfile / pAD->multiplier)),
2695 MPFROM2SHORT(1,
2696 (SHORT) (pAD->afindexcnt / pAD->multiplier) -
2697 (numlines - 1)));
2698 if (pAD->afindexcnt - pAD->topfile < numlines) {
2699 pAD->topfile = ((pAD->afindexcnt - pAD->topfile) - numlines);
2700 WinInvalidateRect(hwnd, NULL, FALSE);
2701 }
2702 }
2703 }
2704 }
2705 return 0;
2706
2707 case UM_SETUP4:
2708 // fprintf(stderr,"Seeall: UM_SETUP4\n");
2709 if (pAD)
2710 pAD->killme = TRUE;
2711 else
2712 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
2713 return 0;
2714
2715 case UM_RESCAN:
2716 // fprintf(stderr,"Seeall: UM_RESCAN\n");
2717 if (pAD && !pAD->stopflag) {
2718 if (DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) {
2719 CHAR s[CCHMAXPATH + 80], tm[34];
2720
2721 if (mp1) {
2722 strcpy(s, GetPString(IDS_SORTINGTEXT));
2723 if (pAD->afindexcnt) {
2724 commafmt(tm, sizeof(tm), pAD->afindexcnt);
2725 strcat(s, tm);
2726 }
2727 }
2728 else {
2729 strcpy(s, GetPString(IDS_WORKINGTEXT));
2730 if (pAD->afheadcnt) {
2731 commafmt(tm, sizeof(tm), pAD->afheadcnt);
2732 strcat(s, tm);
2733 }
2734 }
2735 if (mp2) {
2736 strcat(s, " ");
2737 strcat(s, (CHAR *)mp2);
2738 }
2739 WinSetWindowText(pAD->hwndStatus, s);
2740 }
2741 else {
2742 CHAR s[(CCHMAXPATH * 2) + 80], tm[34], ts[34], tb[34];
2743 ULONG y;
2744
2745 if (mp1) {
2746 strcpy(s, GetPString(IDS_SORTINGTEXT));
2747 if (pAD->afindexcnt) {
2748 commafmt(tm, sizeof(tm), pAD->afindexcnt);
2749 strcat(s, tm);
2750 }
2751 if (mp2) {
2752 strcat(s, " ");
2753 strcat(s, (CHAR *)mp2);
2754 }
2755 }
2756 else if (pAD->afindexcnt) {
2757 y = (pAD->invertsort) ? (pAD->afindexcnt - 1) - (pAD->cursored - 1) :
2758 pAD->cursored - 1;
2759 commafmt(tm, sizeof(tm), pAD->afindexcnt);
2760 commafmt(ts, sizeof(ts), pAD->selected);
2761 CommaFmtULL(tb, sizeof(tb), pAD->ullSelectedBytes, ' ');
2762 sprintf(s,
2763 " %s %s%s%s %s %s (%s) %s %s",
2764 tm,
2765 GetPString(IDS_FILETEXT),
2766 &"s"[pAD->afindexcnt == 1],
2767 (*pAD->mask.szMask ||
2768 (pAD->mask.attrFile & (~FILE_DIRECTORY)) !=
2769 (ALLATTRS & (~FILE_DIRECTORY)) ||
2770 pAD->mask.antiattr) ?
2771 GetPString(IDS_FILTEREDTEXT) :
2772 NullStr,
2773 ts,
2774 GetPString(IDS_SELECTEDTEXT),
2775 tb, GetPString(IDS_CURRTEXT), pAD->afindex[y]->fullname);
2776 }
2777 else
2778 sprintf(s,
2779 GetPString(IDS_NOFILESPSTEXT),
2780 (*pAD->mask.szMask ||
2781 (pAD->mask.attrFile & (~FILE_DIRECTORY)) !=
2782 (ALLATTRS & (~FILE_DIRECTORY)) ||
2783 pAD->mask.antiattr) ?
2784 GetPString(IDS_FILTEREDTEXT) : NullStr);
2785 WinSetWindowText(pAD->hwndStatus, s);
2786 DosReleaseMutexSem(pAD->hmtxScan);
2787 }
2788 }
2789 return 0;
2790
2791 case UM_SETUP:
2792 // fprintf(stderr,"Seeall: UM_SETUP\n");
2793 if (pAD) {
2794 WinSendMsg(pAD->hvscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1), MPVOID);
2795 WinSendMsg(pAD->hhscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1), MPVOID);
2796 WinSetActiveWindow(HWND_DESKTOP, WinQueryWindow(hwnd, QW_PARENT));
2797 }
2798 return 0;
2799
2800 case WM_CHAR:
2801 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
2802 if (pAD && !(SHORT1FROMMP(mp1) & KC_KEYUP)) {
2803
2804 register ULONG x;
2805 ULONG numlines, y, wascursored = pAD->cursored, thistime, len;
2806 BOOL found = FALSE;
2807 RECTL rcl;
2808
2809 WinQueryWindowRect(hwnd, &rcl);
2810 numlines = NumLines(&rcl, pAD);
2811 if (numlines) {
2812 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
2813 pAD->lasttime = 0;
2814 *pAD->szCommonName = 0;
2815 switch (SHORT2FROMMP(mp2)) {
2816 case VK_DELETE:
2817 if ((shiftstate & KC_CTRL) == KC_CTRL)
2818 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0),
2819 MPVOID);
2820 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
2821 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0),
2822 MPVOID);
2823 else
2824 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
2825 break;
2826 case VK_LEFT:
2827 WinSendMsg(hwnd, WM_HSCROLL, MPFROM2SHORT(FID_HORZSCROLL, 0),
2828 MPFROM2SHORT(0, SB_LINELEFT));
2829 break;
2830 case VK_RIGHT:
2831 WinSendMsg(hwnd, WM_HSCROLL, MPFROM2SHORT(FID_HORZSCROLL, 0),
2832 MPFROM2SHORT(0, SB_LINERIGHT));
2833 break;
2834 case VK_PAGEUP:
2835 WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
2836 MPFROM2SHORT(0, SB_PAGEUP));
2837 break;
2838 case VK_PAGEDOWN:
2839 WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
2840 MPFROM2SHORT(0, SB_PAGEDOWN));
2841 break;
2842 case VK_UP:
2843 if (pAD->cursored > 1) {
2844 if (shiftstate & KC_SHIFT)
2845 WinSendMsg(hwnd, WM_BUTTON1CLICK,
2846 MPFROM2SHORT(pAD->fattrs.lAveCharWidth + 2,
2847 ((rcl.yTop - (pAD->lMaxHeight *
2848 ((pAD->cursored) -
2849 pAD->topfile))) -
2850 pAD->lMaxDescender) - 1),
2851 MPFROM2SHORT(TRUE, 0));
2852 pAD->cursored--;
2853 if (pAD->cursored < pAD->topfile) {
2854 PaintLine(hwnd, pAD->hps, pAD->cursored, pAD->topfile, &rcl);
2855 WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
2856 MPFROM2SHORT(0, SB_LINEUP));
2857 }
2858 else {
2859 PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile,
2860 &rcl);
2861 PaintLine(hwnd, pAD->hps, pAD->cursored, pAD->topfile, &rcl);
2862 }
2863 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2864 }
2865 break;
2866 case VK_DOWN:
2867 if (pAD->cursored < pAD->afindexcnt
2868 && pAD->cursored < pAD->topfile + numlines) {
2869 if (shiftstate & KC_SHIFT)
2870 WinSendMsg(hwnd, WM_BUTTON1CLICK,
2871 MPFROM2SHORT(pAD->fattrs.lAveCharWidth + 2,
2872 ((rcl.yTop - (pAD->lMaxHeight *
2873 ((pAD->cursored) -
2874 pAD->topfile))) -
2875 pAD->lMaxDescender) - 1),
2876 MPFROM2SHORT(TRUE, 0));
2877 pAD->cursored++;
2878 if (pAD->cursored >= pAD->topfile + numlines) {
2879 PaintLine(hwnd, pAD->hps, pAD->cursored - 2, pAD->topfile,
2880 &rcl);
2881 WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
2882 MPFROM2SHORT(0, SB_LINEDOWN));
2883 }
2884 else {
2885 PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile,
2886 &rcl);
2887 PaintLine(hwnd, pAD->hps, pAD->cursored - 2, pAD->topfile,
2888 &rcl);
2889 }
2890 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2891 }
2892 break;
2893 case VK_END:
2894 if ((shiftstate & KC_CTRL) ||
2895 pAD->cursored == (pAD->topfile - 1) + numlines) {
2896 pAD->cursored = pAD->afindexcnt;
2897 pAD->topfile = (pAD->afindexcnt + 1) - numlines;
2898 if (pAD->topfile > pAD->afindexcnt)
2899 pAD->topfile = 1;
2900 WinInvalidateRect(hwnd, NULL, FALSE);
2901 }
2902 else {
2903 pAD->cursored = (pAD->topfile - 1) + numlines;
2904 if (pAD->cursored > pAD->afindexcnt)
2905 pAD->cursored = pAD->afindexcnt;
2906 PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile,
2907 &rcl);
2908 PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile, &rcl);
2909 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2910 }
2911 break;
2912 case VK_HOME:
2913 if ((shiftstate & KC_CTRL) || pAD->cursored == pAD->topfile) {
2914 pAD->topfile = 1;
2915 pAD->cursored = 1;
2916 WinInvalidateRect(hwnd, NULL, FALSE);
2917 }
2918 else {
2919 pAD->cursored = pAD->topfile;
2920 PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile,
2921 &rcl);
2922 PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile, &rcl);
2923 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2924 }
2925 break;
2926 case VK_SPACE:
2927 WinSendMsg(hwnd, WM_BUTTON1CLICK,
2928 MPFROM2SHORT(pAD->fattrs.lAveCharWidth + 2,
2929 ((rcl.yTop - (pAD->lMaxHeight *
2930 ((pAD->cursored) -
2931 pAD->topfile))) -
2932 pAD->lMaxDescender) - 1),
2933 MPFROM2SHORT(TRUE, 0));
2934 break;
2935 case VK_NEWLINE:
2936 case VK_ENTER:
2937 WinSendMsg(hwnd, WM_BUTTON1DBLCLK,
2938 MPFROM2SHORT(pAD->fattrs.lAveCharWidth + 2,
2939 ((rcl.yTop - (pAD->lMaxHeight *
2940 ((pAD->cursored) -
2941 pAD->topfile))) -
2942 pAD->lMaxDescender) - 1), MPFROM2SHORT(0,
2943 0));
2944 break;
2945 }
2946 }
2947 else if (SHORT1FROMMP(mp1) & KC_CHAR) {
2948 switch (SHORT1FROMMP(mp2)) {
2949 case '\x1b':
2950 case '\r':
2951 case '\n':
2952 WinSendMsg(hwnd, WM_BUTTON1DBLCLK,
2953 MPFROM2SHORT(pAD->fattrs.lAveCharWidth + 2,
2954 (rcl.yTop - (pAD->lMaxHeight *
2955 ((pAD->cursored) -
2956 pAD->topfile))) - 1),
2957 MPFROM2SHORT(0, 0));
2958 pAD->lasttime = 0;
2959 *pAD->szCommonName = 0;
2960 break;
2961 default:
2962 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
2963 if (thistime > pAD->lasttime + 1000)
2964 *pAD->szCommonName = 0;
2965 pAD->lasttime = thistime;
2966 KbdRetry:
2967 len = strlen(pAD->szCommonName);
2968 if (len >= CCHMAXPATH - 1) {
2969 *pAD->szCommonName = 0;
2970 len = 0;
2971 }
2972 pAD->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
2973 pAD->szCommonName[len + 1] = 0;
2974 for (x = pAD->cursored - (len > 0); x < pAD->afindexcnt; x++) {
2975 y = (pAD->invertsort) ? (pAD->afindexcnt - 1) - x : x;
2976 if (pAD->fullnames) {
2977 if (!strnicmp(pAD->afindex[y]->fullname, pAD->szCommonName,
2978 len + 1)) {
2979 found = TRUE;
2980 break;
2981 }
2982 }
2983 else {
2984 if (!strnicmp(pAD->afindex[y]->filename, pAD->szCommonName,
2985 len + 1)) {
2986 found = TRUE;
2987 break;
2988 }
2989 }
2990 }
2991 if (!found) {
2992 for (x = 0; x < pAD->cursored - (len > 0); 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 }
3010 if (found) {
3011 if (x + 1 != pAD->cursored) {
3012 pAD->cursored = x + 1;
3013 if (pAD->cursored >= pAD->topfile &&
3014 pAD->cursored < pAD->topfile + numlines &&
3015 wascursored != pAD->cursored) {
3016 PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile,
3017 &rcl);
3018 PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile,
3019 &rcl);
3020 }
3021 else {
3022 if (pAD->cursored < numlines)
3023 pAD->topfile = 1;
3024 else if (pAD->cursored >
3025 (pAD->afindexcnt + 1) - (numlines / 2))
3026 pAD->topfile = (pAD->afindexcnt + 1) - numlines;
3027 else
3028 pAD->topfile = pAD->cursored - (numlines / 2);
3029 WinInvalidateRect(hwnd, NULL, FALSE);
3030 }
3031 }
3032 }
3033 else {
3034 *pAD->szCommonName = 0;
3035 pAD->lasttime = 0;
3036 if (len) // retry as first letter if no match
3037 goto KbdRetry;
3038 }
3039 break;
3040 }
3041 }
3042 }
3043 }
3044 break;
3045
3046 case DM_PRINTOBJECT:
3047 return MRFROMLONG(DRR_TARGET);
3048
3049 case DM_DISCARDOBJECT:
3050 return MRFROMLONG(DRR_TARGET);
3051
3052 case WM_BEGINDRAG:
3053 {
3054 CHAR **list;
3055
3056 list = BuildAList(hwnd);
3057 if (!list)
3058 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
3059 else {
3060 WinSetWindowText(pAD->hwndStatus, GetPString(IDS_DRAGGINGFILESTEXT));
3061 DragList(hwnd, (HWND) 0, list, TRUE);
3062 FreeList(list);
3063 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3064 }
3065 }
3066 break;
3067
3068 case WM_BUTTON1MOTIONSTART:
3069 if (pAD && !pAD->stopflag &&
3070 !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) {
3071 pAD->mousecaptured = TRUE;
3072 pAD->lastselected = (ULONG) - 1;
3073 pAD->lastdirection = 0;
3074 WinSetCapture(HWND_DESKTOP, hwnd);
3075 DosReleaseMutexSem(pAD->hmtxScan);
3076 WinSendMsg(hwnd, WM_BUTTON1CLICK, mp1, MPFROM2SHORT(TRUE, 0));
3077 }
3078 break;
3079
3080 case WM_MOUSEMOVE:
3081 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
3082 if (pAD && pAD->mousecaptured) {
3083
3084 ULONG numlines, whichfile, y, x;
3085 LONG inc;
3086 RECTL Rectl;
3087 POINTS pts;
3088 BOOL outofwindow = FALSE;
3089
3090 WinQueryWindowRect(hwnd, &Rectl);
3091 numlines = NumLines(&Rectl, pAD);
3092 if (numlines) {
3093 pts.x = SHORT1FROMMP(mp1);
3094 pts.y = SHORT2FROMMP(mp1);
3095 if (pts.y < 0) {
3096 WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
3097 MPFROM2SHORT(0, SB_LINEDOWN));
3098 pts.y = 1;
3099 outofwindow = TRUE;
3100 }
3101 else if (pts.y > Rectl.yTop - Rectl.yBottom) {
3102 WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
3103 MPFROM2SHORT(0, SB_LINEUP));
3104 pts.y = (Rectl.yTop - Rectl.yBottom) - 1;
3105 outofwindow = TRUE;
3106 }
3107 whichfile = ((Rectl.yTop - Rectl.yBottom) -
3108 ((LONG) pts.y + pAD->lMaxDescender)) / pAD->lMaxHeight;
3109 if (whichfile > numlines - 1)
3110 whichfile = numlines - 1;
3111 whichfile += (pAD->topfile - 1);
3112 y = (pAD->invertsort) ? (pAD->afindexcnt - 1) - whichfile : whichfile;
3113 if (y < pAD->afindexcnt && pAD->lastselected != whichfile) {
3114 if (pAD->lastselected != (ULONG) - 1) {
3115 inc = (pAD->lastselected < whichfile) ? 1 : -1;
3116 for (x = pAD->lastselected + inc;
3117 x != whichfile && x < pAD->afindexcnt;
3118 (pAD->lastselected < whichfile) ? x++ : x--) {
3119 y = (pAD->invertsort) ? (pAD->afindexcnt - 1) - x : x;
3120 if (pAD->afindex[y]->flags & AF_SELECTED) {
3121 pAD->afindex[y]->flags &= ~AF_SELECTED;
3122 pAD->selected--;
3123 pAD->ullSelectedBytes -= pAD->afindex[y]->cbFile;
3124 }
3125 else {
3126 pAD->afindex[y]->flags |= AF_SELECTED;
3127 pAD->selected++;
3128 pAD->ullSelectedBytes += pAD->afindex[y]->cbFile;
3129 }
3130 PaintLine(hwnd, pAD->hps, x, pAD->topfile, &Rectl);
3131 }
3132 }
3133 WinSendMsg(hwnd, WM_BUTTON1CLICK, MPFROM2SHORT(pts.x, pts.y),
3134 MPFROM2SHORT(TRUE, 0));
3135 }
3136 }
3137 if (outofwindow) {
3138
3139 POINTL ptl;
3140
3141 WinQueryPointerPos(HWND_DESKTOP, &ptl);
3142 WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
3143 if ((SHORT) ptl.y == (SHORT) SHORT2FROMMP(mp1) &&
3144 (SHORT) ptl.x == (SHORT) SHORT1FROMMP(mp1) &&
3145 ((SHORT) ptl.y < 0 || ptl.y > (Rectl.yTop - Rectl.yBottom))) {
3146 PostMsg(hwnd, UM_MOUSEMOVE, mp1, MPVOID);
3147 DosSleep(1);
3148 }
3149 }
3150 }
3151 break;
3152
3153 case UM_MOUSEMOVE:
3154 if (pAD && pAD->mousecaptured) {
3155
3156 POINTL ptl;
3157 RECTL Rectl;
3158
3159 WinQueryWindowRect(hwnd, &Rectl);
3160 WinQueryPointerPos(HWND_DESKTOP, &ptl);
3161 WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
3162 if ((SHORT) ptl.y == (SHORT) SHORT2FROMMP(mp1) &&
3163 (SHORT) ptl.x == (SHORT) SHORT1FROMMP(mp1) &&
3164 ((SHORT) ptl.y < 0 || ptl.y > (Rectl.yTop - Rectl.yBottom))) {
3165 DosSleep(1);
3166 PostMsg(hwnd, WM_MOUSEMOVE, mp1, MPFROM2SHORT(TRUE, 0));
3167 }
3168 }
3169 return 0;
3170
3171 case WM_BUTTON1UP:
3172 case WM_BUTTON1MOTIONEND:
3173 if (pAD) {
3174 pAD->mousecaptured = FALSE;
3175 pAD->lastselected = (ULONG) - 1;
3176 pAD->lastdirection = 0;
3177 WinSetCapture(HWND_DESKTOP, NULLHANDLE);
3178 }
3179 break;
3180
3181 case WM_BUTTON1CLICK:
3182 case WM_BUTTON1DBLCLK:
3183 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
3184 if (pAD && !pAD->stopflag &&
3185 !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) {
3186
3187 ULONG numlines, whichfile, y, wascursored;
3188 RECTL Rectl;
3189 POINTS pts;
3190
3191 if (pAD->afindexcnt) {
3192 WinQueryWindowRect(hwnd, &Rectl);
3193 numlines = NumLines(&Rectl, pAD);
3194 if (numlines) {
3195 pts.x = SHORT1FROMMP(mp1);
3196 pts.y = SHORT2FROMMP(mp1);
3197 whichfile = ((Rectl.yTop - Rectl.yBottom) -
3198 ((LONG) pts.y + pAD->lMaxDescender)) / pAD->lMaxHeight;
3199 if (whichfile > numlines - 1)
3200 whichfile = numlines - 1;
3201 whichfile += (pAD->topfile - 1);
3202 if (whichfile + 1 > pAD->afindexcnt)
3203 break;
3204 y = (pAD->invertsort) ? (pAD->afindexcnt - 1) - whichfile : whichfile;
3205 wascursored = pAD->cursored;
3206 pAD->cursored = whichfile + 1;
3207 if (pAD->cursored != wascursored)
3208 PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile, &Rectl);
3209 if (y < pAD->afindexcnt) {
3210 if (msg == WM_BUTTON1CLICK || fUnHilite) {
3211 if (pAD->afindex[y]->flags & AF_SELECTED) {
3212 pAD->afindex[y]->flags &= ~AF_SELECTED;
3213 pAD->selected--;
3214 pAD->ullSelectedBytes -= pAD->afindex[y]->cbFile;
3215 }
3216 else {
3217 pAD->afindex[y]->flags |= AF_SELECTED;
3218 pAD->selected++;
3219 pAD->ullSelectedBytes += pAD->afindex[y]->cbFile;
3220 }
3221 PaintLine(hwnd, pAD->hps, whichfile, pAD->topfile, &Rectl);
3222 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3223 }
3224 }
3225 if (msg == WM_BUTTON1CLICK) {
3226 if (pAD->lastselected != (ULONG) - 1) {
3227 if (whichfile > pAD->lastselected)
3228 pAD->lastdirection = 1;
3229 else
3230 pAD->lastdirection = 2;
3231 }
3232 else
3233 pAD->lastdirection = 0;
3234 pAD->lastselected = whichfile;
3235 }
3236 else
3237 DefaultViewKeys(hwnd, pAD->hwndFrame, HWND_DESKTOP, NULL,
3238 pAD->afindex[y]->fullname);
3239 }
3240 }
3241 DosReleaseMutexSem(pAD->hmtxScan);
3242 }
3243 break;
3244
3245 case WM_MENUEND:
3246 if (pAD && (HWND) mp2 == pAD->hwndPopup) {
3247 WinDestroyWindow(pAD->hwndPopup);
3248 pAD->hwndPopup = (HWND) 0;
3249 }
3250 break;
3251
3252 case WM_CONTEXTMENU:
3253 if (pAD) {
3254 if (!pAD->hwndPopup) {
3255 pAD->hwndPopup =
3256 WinLoadMenu(HWND_DESKTOP, FM3ModHandle, SEEALL_POPUP);
3257 if (pAD->hwndPopup) {
3258 WinSetPresParam(pAD->hwndPopup, PP_FONTNAMESIZE,
3259 (ULONG) strlen(GetPString(IDS_8HELVTEXT)) + 1,
3260 (PVOID) GetPString(IDS_8HELVTEXT));
3261 SetConditionalCascade(pAD->hwndPopup,
3262 IDM_DELETESUBMENU,
3263 (fDefaultDeletePerm) ?
3264 IDM_PERMDELETE : IDM_DELETE);
3265 SetConditionalCascade(pAD->hwndPopup, IDM_MOVEMENU, IDM_MOVE);
3266 SetConditionalCascade(pAD->hwndPopup, IDM_COPYMENU, IDM_COPY);
3267 SetConditionalCascade(pAD->hwndPopup, IDM_OPENSUBMENU,
3268 IDM_OPENDEFAULT);
3269 SetConditionalCascade(pAD->hwndMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
3270 if (fWorkPlace) {
3271 WinSendMsg(pAD->hwndPopup, MM_DELETEITEM,
3272 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
3273 WinSendMsg(pAD->hwndPopup, MM_DELETEITEM,
3274 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
3275 }
3276 }
3277 }
3278 if (pAD->hwndPopup) {
3279
3280 APIRET rc;
3281
3282 rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN);
3283 WinEnableMenuItem(pAD->hwndPopup, IDM_EAS, (rc == 0 &&
3284 pAD->selected != 0));
3285 WinEnableMenuItem(pAD->hwndPopup, IDM_UUDECODE, (rc == 0 &&
3286 pAD->selected != 0));
3287 WinEnableMenuItem(pAD->hwndPopup, IDM_EXTRACT, (rc == 0 &&
3288 pAD->selected != 0));
3289 WinEnableMenuItem(pAD->hwndPopup, IDM_ARCHIVE, (rc == 0 &&
3290 pAD->selected != 0));
3291 WinEnableMenuItem(pAD->hwndPopup, IDM_MOVEMENU, (rc == 0 &&
3292 pAD->selected != 0));
3293 WinEnableMenuItem(pAD->hwndPopup, IDM_COPYMENU, (rc == 0 &&
3294 pAD->selected != 0));
3295 WinEnableMenuItem(pAD->hwndPopup, IDM_RENAME, (rc == 0 &&
3296 pAD->selected != 0));
3297 WinEnableMenuItem(pAD->hwndPopup, IDM_PRINT, (rc == 0 &&
3298 pAD->selected != 0));
3299 WinEnableMenuItem(pAD->hwndPopup, IDM_SUBJECT, (rc == 0 &&
3300 pAD->selected != 0));
3301 WinEnableMenuItem(pAD->hwndPopup, IDM_OPENSUBMENU, (rc == 0 &&
3302 pAD->selected !=
3303 0));
3304 WinEnableMenuItem(pAD->hwndPopup, IDM_OBJECTSUBMENU,
3305 (rc == 0 && pAD->selected != 0));
3306 WinEnableMenuItem(pAD->hwndPopup, IDM_DELETESUBMENU,
3307 (rc == 0 && pAD->selected != 0));
3308 WinEnableMenuItem(pAD->hwndPopup, IDM_INFO,
3309 (rc == 0 && pAD->selected != 0));
3310 WinEnableMenuItem(pAD->hwndPopup, IDM_ATTRS,
3311 (rc == 0 && pAD->selected != 0));
3312 WinEnableMenuItem(pAD->hwndPopup, IDM_COLLECT,
3313 (rc == 0 && pAD->selected != 0));
3314 WinEnableMenuItem(pAD->hwndPopup, IDM_SAVETOCLIP,
3315 (rc == 0 && pAD->selected != 0));
3316 WinEnableMenuItem(pAD->hwndPopup, IDM_APPENDTOCLIP,
3317 (rc == 0 && pAD->selected != 0));
3318 WinEnableMenuItem(pAD->hwndPopup, IDM_SAVETOLIST,
3319 (rc == 0 && pAD->selected != 0));
3320 WinEnableMenuItem(pAD->hwndPopup, IDM_REMOVE,
3321 (rc == 0 && pAD->selected != 0));
3322 WinEnableMenuItem(pAD->hwndPopup, IDM_HIDEALL,
3323 (rc == 0 && pAD->selected != 0));
3324 WinEnableMenuItem(pAD->hwndPopup, IDM_SELECTALL,
3325 (rc == 0 && pAD->afindexcnt != 0));
3326 WinEnableMenuItem(pAD->hwndPopup, IDM_SELECTMASK,
3327 (rc == 0 && pAD->afindexcnt != 0));
3328 WinEnableMenuItem(pAD->hwndPopup, IDM_DESELECTALL,
3329 (rc == 0 && pAD->afindexcnt != 0));
3330 WinEnableMenuItem(pAD->hwndPopup, IDM_DESELECTMASK,
3331 (rc == 0 && pAD->afindexcnt != 0));
3332 WinEnableMenuItem(pAD->hwndPopup, IDM_INVERT,
3333 (rc == 0 && pAD->afindexcnt != 0));
3334 WinEnableMenuItem(pAD->hwndPopup, IDM_FILTER,
3335 (rc == 0 && pAD->afheadcnt != 0));
3336 if (!rc)
3337 DosReleaseMutexSem(pAD->hmtxScan);
3338 if (WinPopupMenu(hwnd, hwnd, pAD->hwndPopup, SHORT1FROMMP(mp1),
3339 SHORT2FROMMP(mp1), 0,
3340 PU_HCONSTRAIN | PU_VCONSTRAIN |
3341 PU_KEYBOARD | PU_MOUSEBUTTON1))
3342 CenterOverWindow(pAD->hwndPopup);
3343 }
3344 }
3345 break;
3346
3347 case UM_CONTAINER_FILLED:
3348 if (pAD) {
3349 pAD->stopflag = 0;
3350 pAD->topfile = 1;
3351 pAD->cursored = 1;
3352 pAD->multiplier = 1;
3353 if (!pAD->afindexcnt) {
3354 DosBeep(250, 50);
3355 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3356 }
3357 else {
3358 DosBeep(1000, 25);
3359 WinInvalidateRect(hwnd, NULL, FALSE);
3360 PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
3361 }
3362 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
3363 SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE | SWP_ZORDER);
3364 }
3365 return 0;
3366
3367 case WM_ERASEBACKGROUND:
3368 WinFillRect((HPS) mp1, (PRECTL) mp2,
3369 standardcolors[Colors[COLORS_NORMALBACK]]);
3370 return 0;
3371
3372 case WM_PAINT:
3373 // fprintf(stderr,"Seeall: WM_PAINT\n");
3374 if (pAD) {
3375
3376 HPS hpsp;
3377 RECTL Rectl;
3378 POINTL ptl;
3379 register ULONG x;
3380 ULONG y, len, numlines;
3381 CHAR szBuff[CCHMAXPATH + 80], szCmmaFmtFileSize[81];
3382 BOOL inverted, hidsys, reado, wascursored;
3383
3384 hpsp = WinBeginPaint(hwnd, pAD->hps, &Rectl);
3385 WinFillRect(hpsp, &Rectl, standardcolors[Colors[COLORS_NORMALBACK]]);
3386 if (!pAD->stopflag &&
3387 !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) {
3388 WinQueryWindowRect(hwnd, &Rectl);
3389 numlines = NumLines(&Rectl, pAD);
3390 if (pAD->afindexcnt && numlines) {
3391 if (pAD->topfile > (pAD->afindexcnt + 1) - numlines)
3392 pAD->topfile = (pAD->afindexcnt + 1) - numlines;
3393 if (pAD->topfile > pAD->afindexcnt)
3394 pAD->topfile = 1;
3395 if (!pAD->topfile)
3396 pAD->topfile = 1;
3397 if (pAD->cursored < pAD->topfile)
3398 pAD->cursored = pAD->topfile;
3399 else if (pAD->cursored > (pAD->topfile + numlines) - 1)
3400 pAD->cursored = (pAD->topfile + numlines) - 1;
3401 if (pAD->cursored > pAD->afindexcnt)
3402 pAD->cursored = pAD->afindexcnt;
3403 }
3404 else
3405 pAD->topfile = pAD->cursored = 1;
3406 if (numlines && pAD->afindexcnt) {
3407 GpiSetBackMix(hpsp, BM_OVERPAINT);
3408 wascursored = TRUE;
3409 for (x = pAD->topfile - 1; x < pAD->afindexcnt; x++) {
3410 ptl.x = pAD->horzscroll;
3411 if (wascursored) { /* reestablish normal colors */
3412 GpiSetColor(pAD->hps,
3413 standardcolors[Colors[COLORS_NORMALFORE]]);
3414 GpiSetBackColor(pAD->hps,
3415 standardcolors[Colors[COLORS_NORMALBACK]]);
3416 wascursored = inverted = hidsys = reado = FALSE;
3417 }
3418 if (x == pAD->cursored - 1)
3419 wascursored = TRUE;
3420 y = (pAD->invertsort) ? (pAD->afindexcnt - 1) - x : x;
3421 ptl.y = (Rectl.yTop -
3422 (pAD->lMaxHeight * (((x + 1) - pAD->topfile) + 1)));
3423 if (ptl.y - pAD->lMaxDescender <= 0)
3424 break;
3425 if (pAD->afindex[y]->flags & AF_SELECTED) {
3426 if (!inverted) {
3427 GpiSetColor(pAD->hps,
3428 standardcolors[Colors
3429 [COLORS_SELECTEDNORMALFORE]]);
3430 GpiSetBackColor(pAD->hps,
3431 (wascursored) ?
3432 standardcolors[Colors
3433 [COLORS_CURSOREDSELECTEDBACK]]
3434 :
3435 standardcolors[Colors[COLORS_SELECTEDBACK]]);
3436 inverted = TRUE;
3437 }
3438 }
3439 else if (inverted ||
3440 ((pAD->afindex[y]->attrFile &
3441 (FILE_SYSTEM | FILE_HIDDEN)) != 0) != hidsys ||
3442 ((pAD->afindex[y]->attrFile & FILE_READONLY) != 0) !=
3443 reado) {
3444 if (pAD->afindex[y]->attrFile & (FILE_SYSTEM | FILE_HIDDEN)) {
3445 GpiSetColor(pAD->hps,
3446 standardcolors[Colors[COLORS_SYSTEMFORE]]);
3447 hidsys = TRUE;
3448 }
3449 else if ((pAD->afindex[y]->attrFile & FILE_READONLY) != 0) {
3450 GpiSetColor(pAD->hps,
3451 standardcolors[Colors[COLORS_READONLYFORE]]);
3452 reado = TRUE;
3453 }
3454 else
3455 GpiSetColor(pAD->hps,
3456 standardcolors[Colors[COLORS_NORMALFORE]]);
3457 GpiSetBackColor(pAD->hps,
3458 (wascursored) ?
3459 standardcolors[Colors
3460 [COLORS_CURSOREDNORMALBACK]] :
3461 standardcolors[Colors[COLORS_NORMALBACK]]);
3462 inverted = FALSE;
3463 }
3464 else if (wascursored)
3465 GpiSetBackColor(pAD->hps,
3466 standardcolors[Colors
3467 [COLORS_CURSOREDNORMALBACK]]);
3468 CommaFmtULL(szCmmaFmtFileSize,
3469 sizeof(szCmmaFmtFileSize), pAD->afindex[y]->cbFile, ' ');
3470 len =
3471 sprintf(szBuff,
3472 "%c%-*.*s %-12s %c%c%c%c%c %04u/%02u/%02u %02u:%02u:%02u ",
3473 wascursored ? '>' : ' ',
3474 pAD->fullnames ? pAD->longestw : pAD->longest,
3475 pAD->fullnames ? pAD->longestw : pAD->longest,
3476 (pAD->fullnames) ? pAD->afindex[y]->fullname : pAD->
3477 afindex[y]->filename, szCmmaFmtFileSize,
3478 "-A"[((pAD->afindex[y]->attrFile & FILE_ARCHIVED) !=
3479 0)],
3480 "-R"[((pAD->afindex[y]->attrFile & FILE_READONLY) !=
3481 0)],
3482 "-H"[((pAD->afindex[y]->attrFile & FILE_HIDDEN) != 0)],
3483 "-S"[((pAD->afindex[y]->attrFile & FILE_SYSTEM) != 0)],
3484 "-D"[((pAD->afindex[y]->attrFile & FILE_DIRECTORY) !=
3485 0)], pAD->afindex[y]->date.year + 1980,
3486 pAD->afindex[y]->date.month, pAD->afindex[y]->date.day,
3487 pAD->afindex[y]->time.hours,
3488 pAD->afindex[y]->time.minutes,
3489 pAD->afindex[y]->time.twosecs * 2);
3490 GpiCharStringAt(hpsp, &ptl, len, szBuff);
3491 GpiQueryCurrentPosition(hpsp, &ptl);
3492 if (ptl.x + abs(pAD->horzscroll) > pAD->maxx) {
3493 pAD->maxx = ptl.x + abs(pAD->horzscroll);
3494 WinSendMsg(pAD->hhscroll, SBM_SETTHUMBSIZE,
3495 MPFROM2SHORT((SHORT) Rectl.xRight,
3496 (SHORT) pAD->maxx), MPVOID);
3497 }
3498 }
3499 }
3500 DosReleaseMutexSem(pAD->hmtxScan);
3501 }
3502 WinEndPaint(hpsp);
3503 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3504 if (!pAD->stopflag)
3505 WinSendMsg(pAD->hvscroll, SBM_SETSCROLLBAR,
3506 MPFROMSHORT((SHORT) (pAD->topfile / pAD->multiplier)),
3507 MPFROM2SHORT(1,
3508 (SHORT) (pAD->afindexcnt / pAD->multiplier) -
3509 (numlines - 1)));
3510 WinSendMsg(pAD->hhscroll, SBM_SETSCROLLBAR,
3511 MPFROMSHORT((SHORT) abs(pAD->horzscroll)),
3512 MPFROM2SHORT(0, (SHORT) (pAD->maxx - Rectl.xRight)));
3513 WinSendMsg(pAD->hhscroll, SBM_SETTHUMBSIZE,
3514 MPFROM2SHORT((SHORT) Rectl.xRight, (SHORT) pAD->maxx),
3515 MPVOID);
3516 }
3517 break;
3518
3519 case WM_HSCROLL:
3520 {
3521 RECTL rectl;
3522 BOOL invalidate = TRUE;
3523
3524 WinQueryWindowRect(hwnd, &rectl);
3525 switch (SHORT2FROMMP(mp2)) {
3526 case SB_PAGERIGHT:
3527 if (abs(pAD->horzscroll) < pAD->maxx - rectl.xRight) {
3528 pAD->horzscroll -= rectl.xRight;
3529 if (abs(pAD->horzscroll) > pAD->maxx - rectl.xRight)
3530 pAD->horzscroll = -(pAD->maxx - rectl.xRight);
3531 }
3532 break;
3533
3534 case SB_PAGELEFT:
3535 if (pAD->horzscroll < 0) {
3536 pAD->horzscroll += rectl.xRight;
3537 if (pAD->horzscroll > 0)
3538 pAD->horzscroll = 0;
3539 }
3540 break;
3541
3542 case SB_LINERIGHT:
3543 if (abs(pAD->horzscroll) < pAD->maxx - rectl.xRight)
3544 pAD->horzscroll -= pAD->fattrs.lAveCharWidth;
3545 break;
3546
3547 case SB_LINELEFT:
3548 if (pAD->horzscroll < 0)
3549 pAD->horzscroll += pAD->fattrs.lAveCharWidth;
3550 break;
3551
3552 case SB_SLIDERTRACK:
3553 pAD->horzscroll = SHORT1FROMMP(mp2);
3554 pAD->horzscroll = -(pAD->horzscroll);
3555 if (pAD->horzscroll > 0)
3556 pAD->horzscroll = 0;
3557 if (abs(pAD->horzscroll) > pAD->maxx - rectl.xRight)
3558 pAD->horzscroll = -(pAD->maxx - rectl.xRight);
3559 break;
3560
3561 default:
3562 invalidate = FALSE;
3563 break;
3564 }
3565 if (invalidate)
3566 WinInvalidateRect(hwnd, NULL, FALSE);
3567 }
3568 break;
3569
3570 case WM_VSCROLL:
3571// fprintf(stderr,"Seeall: WM_VSCROLL\n");
3572 if (pAD && !pAD->stopflag &&
3573 !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) {
3574
3575 ULONG numlines, wascursored;
3576 RECTL rcl;
3577
3578 if (pAD->afindexcnt) {
3579 WinQueryWindowRect(hwnd, &rcl);
3580 numlines = NumLines(&rcl, pAD);
3581 if (numlines) {
3582 wascursored = pAD->cursored;
3583 switch (SHORT2FROMMP(mp2)) {
3584 case SB_PAGEUP:
3585 if (pAD->topfile > 1) {
3586 pAD->topfile -= numlines;
3587 if (pAD->topfile > pAD->afindexcnt ||
3588 pAD->topfile > (pAD->afindexcnt + 1) - numlines)
3589 pAD->topfile = 1;
3590 if (pAD->cursored > pAD->topfile + numlines)
3591 pAD->cursored = pAD->topfile + numlines;
3592 if (pAD->cursored > pAD->afindexcnt)
3593 pAD->cursored = pAD->afindexcnt;
3594 WinInvalidateRect(hwnd, NULL, FALSE);
3595 }
3596 break;
3597 case SB_PAGEDOWN:
3598 if (pAD->topfile <= pAD->afindexcnt - numlines) {
3599 pAD->topfile += numlines;
3600 if (pAD->topfile > (pAD->afindexcnt + 1) - numlines)
3601 pAD->topfile = (pAD->afindexcnt + 1) - numlines;
3602 if (pAD->cursored < pAD->topfile)
3603 pAD->cursored = pAD->topfile;
3604 if (pAD->cursored > (pAD->topfile + numlines) - 1)
3605 pAD->cursored = (pAD->topfile + numlines) - 1;
3606 if (pAD->cursored > pAD->afindexcnt)
3607 pAD->cursored = pAD->afindexcnt;
3608 WinInvalidateRect(hwnd, NULL, FALSE);
3609 }
3610 break;
3611 case SB_LINEDOWN:
3612 if (pAD->topfile <= pAD->afindexcnt - numlines) {
3613
3614 RECTL Rectl, iRectl;
3615
3616 pAD->topfile++;
3617 if (pAD->cursored < pAD->topfile)
3618 pAD->cursored = pAD->topfile;
3619 else if (pAD->cursored > (pAD->topfile + numlines) - 1)
3620 pAD->cursored = (pAD->topfile + numlines) - 1;
3621 if (pAD->cursored > pAD->afindexcnt)
3622 pAD->cursored = pAD->afindexcnt;
3623 WinQueryWindowRect(hwnd, &Rectl);
3624 WinScrollWindow(hwnd, 0, pAD->lMaxHeight,
3625 NULL, NULL, NULLHANDLE, &iRectl, 0);
3626 WinFillRect(pAD->hps, &iRectl,
3627 standardcolors[Colors[COLORS_NORMALBACK]]);
3628 PaintLine(hwnd, pAD->hps, (pAD->topfile + numlines) - 2,
3629 pAD->topfile, &Rectl);
3630 if (pAD->cursored != pAD->topfile + numlines)
3631 PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile,
3632 &Rectl);
3633 if (wascursored != pAD->cursored
3634 && wascursored < pAD->topfile + numlines
3635 && wascursored >= pAD->topfile)
3636 PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile,
3637 &Rectl);
3638 if (wascursored != pAD->cursored)
3639 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3640 WinSendMsg(pAD->hhscroll, SBM_SETSCROLLBAR,
3641 MPFROMSHORT((SHORT) abs(pAD->horzscroll)),
3642 MPFROM2SHORT(0, (SHORT) (pAD->maxx - Rectl.xRight)));
3643 WinSendMsg(pAD->hvscroll, SBM_SETSCROLLBAR,
3644 MPFROMSHORT((SHORT) (pAD->topfile /
3645 pAD->multiplier)),
3646 MPFROM2SHORT(1, (SHORT) (pAD->afindexcnt /
3647 pAD->multiplier) -
3648 (numlines - 1)));
3649 }
3650 break;
3651 case SB_LINEUP:
3652 if (pAD->topfile > 1) {
3653
3654 RECTL Rectl, iRectl;
3655
3656 pAD->topfile--;
3657 if (pAD->cursored < pAD->topfile)
3658 pAD->cursored = pAD->topfile;
3659 else if (pAD->cursored > (pAD->topfile + numlines) - 1)
3660 pAD->cursored = (pAD->topfile + numlines) - 1;
3661 if (pAD->cursored > pAD->afindexcnt)
3662 pAD->cursored = pAD->afindexcnt;
3663 WinQueryWindowRect(hwnd, &Rectl);
3664 WinScrollWindow(hwnd, 0, -pAD->lMaxHeight,
3665 NULL, NULL, NULLHANDLE, &iRectl, 0);
3666 WinFillRect(pAD->hps, &iRectl,
3667 standardcolors[Colors[COLORS_NORMALBACK]]);
3668 iRectl = Rectl;
3669 iRectl.yTop -= ((numlines * pAD->lMaxHeight) +
3670 pAD->lMaxDescender);
3671 WinFillRect(pAD->hps, &iRectl,
3672 standardcolors[pAD->aulColors[COLORS_NORMALBACK]]);
3673 PaintLine(hwnd, pAD->hps, pAD->topfile - 1, pAD->topfile,
3674 &Rectl);
3675 if (pAD->cursored != pAD->topfile)
3676 PaintLine(hwnd, pAD->hps, pAD->cursored - 1, pAD->topfile,
3677 &Rectl);
3678 if (pAD->cursored != wascursored && wascursored >= pAD->topfile
3679 && wascursored < pAD->topfile + numlines)
3680 PaintLine(hwnd, pAD->hps, wascursored - 1, pAD->topfile,
3681 &Rectl);
3682 if (pAD->cursored != wascursored)
3683 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3684 WinSendMsg(pAD->hhscroll, SBM_SETSCROLLBAR,
3685 MPFROMSHORT((SHORT) abs(pAD->horzscroll)),
3686 MPFROM2SHORT(0, (SHORT) (pAD->maxx - Rectl.xRight)));
3687 WinSendMsg(pAD->hvscroll, SBM_SETSCROLLBAR,
3688 MPFROMSHORT((SHORT) (pAD->topfile /
3689 pAD->multiplier)),
3690 MPFROM2SHORT(1, (SHORT) (pAD->afindexcnt /
3691 pAD->multiplier) -
3692 (numlines - 1)));
3693 }
3694 break;
3695 case SB_SLIDERTRACK:
3696 if ((SHORT1FROMMP(mp2) >= 1) ||
3697 (SHORT1FROMMP(mp2)) <= pAD->afindexcnt) {
3698 pAD->topfile = (ULONG) SHORT1FROMMP(mp2) * pAD->multiplier;
3699 if (pAD->topfile > (pAD->afindexcnt + 1) - numlines)
3700 pAD->topfile = (pAD->afindexcnt + 1) - numlines;
3701 if (!pAD->topfile)
3702 pAD->topfile = 1;
3703 if (pAD->cursored < pAD->topfile)
3704 pAD->cursored = pAD->topfile;
3705 else if (pAD->cursored > pAD->topfile + numlines)
3706 pAD->cursored = pAD->topfile + numlines;
3707 if (pAD->cursored > pAD->afindexcnt)
3708 pAD->cursored = pAD->afindexcnt;
3709 WinInvalidateRect(hwnd, NULL, FALSE);
3710 }
3711 else
3712 WinAlarm(HWND_DESKTOP, WA_NOTE);
3713 break;
3714 }
3715 }
3716 }
3717 DosReleaseMutexSem(pAD->hmtxScan);
3718 }
3719 break;
3720
3721 case WM_INITMENU:
3722 if (pAD) {
3723 switch (SHORT1FROMMP(mp1)) {
3724 case IDM_FILESMENU:
3725 {
3726 APIRET rc;
3727
3728 rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN);
3729 WinEnableMenuItem((HWND) mp2, IDM_DUPES, (rc == 0));
3730 WinEnableMenuItem((HWND) mp2, IDM_COLLECT, (rc == 0 &&
3731 pAD->selected != 0));
3732 WinEnableMenuItem((HWND) mp2, IDM_SAVETOCLIP, (rc == 0 &&
3733 pAD->selected != 0));
3734 WinEnableMenuItem((HWND) mp2, IDM_APPENDTOCLIP, (rc == 0 &&
3735 pAD->selected !=
3736 0));
3737 WinEnableMenuItem((HWND) mp2, IDM_SAVETOLIST,
3738 (rc == 0 && pAD->selected != 0));
3739 WinEnableMenuItem((HWND) mp2, IDM_REMOVE,
3740 (rc == 0 && pAD->selected != 0));
3741 WinEnableMenuItem((HWND) mp2, IDM_HIDEALL,
3742 (rc == 0 && pAD->selected != 0));
3743 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU,
3744 (rc == 0 && pAD->selected != 0));
3745 WinEnableMenuItem((HWND) mp2, IDM_INFO,
3746 (rc == 0 && pAD->selected != 0));
3747 WinEnableMenuItem((HWND) mp2, IDM_ATTRS,
3748 (rc == 0 && pAD->selected != 0));
3749 WinEnableMenuItem((HWND) mp2, IDM_EAS,
3750 (rc == 0 && pAD->selected != 0));
3751 WinEnableMenuItem((HWND) mp2, IDM_UUDECODE,
3752 (rc == 0 && pAD->selected != 0));
3753 WinEnableMenuItem((HWND) mp2, IDM_EXTRACT,
3754 (rc == 0 && pAD->selected != 0));
3755 WinEnableMenuItem((HWND) mp2, IDM_ARCHIVE,
3756 (rc == 0 && pAD->selected != 0));
3757 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU,
3758 (rc == 0 && pAD->selected != 0));
3759 WinEnableMenuItem((HWND) mp2, IDM_COPYMENU,
3760 (rc == 0 && pAD->selected != 0));
3761 WinEnableMenuItem((HWND) mp2, IDM_RENAME,
3762 (rc == 0 && pAD->selected != 0));
3763 WinEnableMenuItem((HWND) mp2, IDM_PRINT,
3764 (rc == 0 && pAD->selected != 0));
3765 WinEnableMenuItem((HWND) mp2, IDM_SUBJECT,
3766 (rc == 0 && pAD->selected != 0));
3767 WinEnableMenuItem((HWND) mp2, IDM_OPENSUBMENU,
3768 (rc == 0 && pAD->selected != 0));
3769 WinEnableMenuItem((HWND) mp2, IDM_OBJECTSUBMENU,
3770 (rc == 0 && pAD->selected != 0));
3771 if (!rc)
3772 DosReleaseMutexSem(pAD->hmtxScan);
3773 }
3774 break;
3775
3776 case IDM_SELECTSUBMENU:
3777 {
3778 APIRET rc;
3779
3780 rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN);
3781 WinEnableMenuItem((HWND) mp2, IDM_SELECTALL, (rc == 0 &&
3782 pAD->afindexcnt != 0 &&
3783 (pAD->afindexcnt !=
3784 pAD->selected ||
3785 !pAD->selected)));
3786 WinEnableMenuItem((HWND) mp2, IDM_SELECTMASK, (rc == 0 &&
3787 pAD->afindexcnt != 0 &&
3788 (pAD->afindexcnt !=
3789 pAD->selected ||
3790 !pAD->selected)));
3791 WinEnableMenuItem((HWND) mp2, IDM_DESELECTALL, (rc == 0 &&
3792 pAD->afindexcnt != 0
3793 && pAD->selected));
3794 WinEnableMenuItem((HWND) mp2, IDM_DESELECTMASK,
3795 (rc == 0 && pAD->afindexcnt != 0) && pAD->selected);
3796 WinEnableMenuItem((HWND) mp2, IDM_INVERT,
3797 (rc == 0 && pAD->afindexcnt != 0));
3798 if (!rc)
3799 DosReleaseMutexSem(pAD->hmtxScan);
3800 }
3801 break;
3802
3803 case IDM_SORTSUBMENU:
3804 {
3805 APIRET rc;
3806
3807 rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN);
3808 WinEnableMenuItem((HWND) mp2, IDM_SORTNAME, (rc == 0));
3809 WinEnableMenuItem((HWND) mp2, IDM_SORTEASIZE, (rc == 0));
3810 WinEnableMenuItem((HWND) mp2, IDM_SORTSIZE, (rc == 0));
3811 WinEnableMenuItem((HWND) mp2, IDM_SORTLWDATE, (rc == 0));
3812 WinEnableMenuItem((HWND) mp2, IDM_SORTFILENAME, (rc == 0));
3813 WinEnableMenuItem((HWND) mp2, IDM_SORTFIRST, (rc == 0));
3814 if (!rc)
3815 DosReleaseMutexSem(pAD->hmtxScan);
3816 }
3817 WinCheckMenuItem((HWND) mp2, IDM_SORTNAME,
3818 (pAD->pfnCompare == comparefullnames));
3819 WinCheckMenuItem((HWND) mp2, IDM_SORTEASIZE,
3820 (pAD->pfnCompare == (PFNSORT) NULL));
3821 WinCheckMenuItem((HWND) mp2, IDM_SORTSIZE,
3822 (pAD->pfnCompare == comparesizes));
3823 WinCheckMenuItem((HWND) mp2, IDM_SORTLWDATE,
3824 (pAD->pfnCompare == comparedates));
3825 WinCheckMenuItem((HWND) mp2, IDM_SORTFILENAME,
3826 (pAD->pfnCompare == comparenames));
3827 WinCheckMenuItem((HWND) mp2, IDM_SORTREVERSE, pAD->invertsort);
3828 WinCheckMenuItem((HWND) mp2, IDM_SORTFIRST,
3829 (pAD->pfnCompare == compareexts));
3830 break;
3831
3832 case IDM_VIEWSMENU:
3833 {
3834 APIRET rc;
3835
3836 rc = DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN);
3837 WinEnableMenuItem((HWND) mp2, IDM_RESCAN, (rc == 0));
3838 WinEnableMenuItem((HWND) mp2, IDM_FILTER, (rc == 0 &&
3839 pAD->afheadcnt != 0));
3840 if (!rc)
3841 DosReleaseMutexSem(pAD->hmtxScan);
3842 }
3843 WinCheckMenuItem((HWND) mp2, IDM_SHOWLNAMES, pAD->fullnames);
3844 break;
3845 }
3846 }
3847 break;
3848
3849 case WM_COMMAND:
3850 if (!pAD) {
3851 Runtime_Error(pszSrcFile, __LINE__, "no data");
3852 return 0;
3853 }
3854 switch (SHORT1FROMMP(mp1)) {
3855 case IDM_SETTARGET:
3856 SetTargetDir(hwnd, FALSE);
3857 break;
3858
3859 case IDM_DUPES:
3860 if (!pAD->stopflag &&
3861 !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) {
3862 pAD->dupeflags = (USHORT) WinDlgBox(HWND_DESKTOP,
3863 hwnd,
3864 DupeDlgProc,
3865 FM3ModHandle,
3866 DUPE_FRAME,
3867 MPFROM2SHORT(pAD->dupeflags, 0));
3868 if (pAD->dupeflags) {
3869 if (_beginthread(FindDupesThread, NULL, 65536, (PVOID) hwnd) == -1)
3870 Runtime_Error(pszSrcFile, __LINE__,
3871 GetPString(IDS_COULDNTSTARTTHREADTEXT));
3872 }
3873 DosReleaseMutexSem(pAD->hmtxScan);
3874 }
3875 break;
3876
3877 case IDM_COLORPALETTE:
3878 {
3879 COLORS co;
3880 LONG temp[COLORS_MAX];
3881
3882 memset(&co, 0, sizeof(co));
3883 co.size = sizeof(co);
3884 co.numcolors = COLORS_MAX;
3885 co.colors = pAD->aulColors;
3886 co.descriptions = IDS_SACOLORS1TEXT;
3887 co.origs = temp;
3888 co.prompt = IDS_SACOLORSPROMPTTEXT;
3889 memcpy(temp, pAD->aulColors, sizeof(LONG) * COLORS_MAX);
3890 if (WinDlgBox(HWND_DESKTOP,
3891 hwnd,
3892 ColorDlgProc,
3893 FM3ModHandle, COLOR_FRAME, (PVOID) & co)) {
3894 memcpy(Colors, pAD->aulColors, sizeof(LONG) * COLORS_MAX);
3895 PrfWriteProfileData(fmprof,
3896 appname,
3897 "Seeall.Colors",
3898 &pAD->aulColors, sizeof(LONG) * COLORS_MAX);
3899 WinInvalidateRect(hwnd, NULL, FALSE);
3900 }
3901 }
3902 break;
3903
3904 case IDM_CODEPAGE:
3905 {
3906 INT cp;
3907
3908 cp = PickCodepage(hwnd);
3909 if (cp != -1) {
3910 pAD->fattrs.usCodePage = (USHORT) cp;
3911 Codepage = pAD->fattrs.usCodePage;
3912 PrfWriteProfileData(fmprof,
3913 appname,
3914 "Seeall.Codepage",
3915 &pAD->fattrs.usCodePage, sizeof(USHORT));
3916 GpiDeleteSetId(pAD->hps, FIXED_FONT_LCID);
3917 GpiAssociate(pAD->hps, 0);
3918 GpiDestroyPS(pAD->hps);
3919 pAD->hps = InitWindow(hwnd);
3920 pAD->maxx = pAD->horzscroll = 0;
3921 WinInvalidateRect(hwnd, NULL, FALSE);
3922 }
3923 }
3924 break;
3925
3926 case IDM_FONTPALETTE:
3927 SetMLEFont(hwnd, &pAD->fattrs, 11);
3928 PrfWriteProfileData(fmprof,
3929 appname,
3930 "Seeall.Fattrs", &pAD->fattrs, sizeof(pAD->fattrs));
3931 Fattrs = pAD->fattrs;
3932 GpiDeleteSetId(pAD->hps, FIXED_FONT_LCID);
3933 GpiAssociate(pAD->hps, 0);
3934 GpiDestroyPS(pAD->hps);
3935 pAD->hps = InitWindow(hwnd);
3936 pAD->maxx = pAD->horzscroll = 0;
3937 WinInvalidateRect(hwnd, NULL, FALSE);
3938 break;
3939
3940 case IDM_SHOWLNAMES:
3941 pAD->fullnames = (pAD->fullnames) ? FALSE : TRUE;
3942 PrfWriteProfileData(fmprof,
3943 appname,
3944 "Seeall.Fullnames", &pAD->fullnames, sizeof(BOOL));
3945 Fullnames = pAD->fullnames;
3946 pAD->maxx = pAD->horzscroll = 0;
3947 WinInvalidateRect(hwnd, NULL, FALSE);
3948 break;
3949
3950 case IDM_SORTREVERSE:
3951 pAD->invertsort = (pAD->invertsort) ? FALSE : TRUE;
3952 SortReverse = pAD->invertsort;
3953 PrfWriteProfileData(fmprof,
3954 appname,
3955 "Seeall.SortReverse",
3956 (PVOID) & pAD->invertsort, sizeof(BOOL));
3957 WinInvalidateRect(hwnd, NULL, FALSE);
3958 break;
3959
3960 case IDM_SORTEASIZE:
3961 case IDM_SORTNAME:
3962 case IDM_SORTFILENAME:
3963 case IDM_SORTSIZE:
3964 case IDM_SORTLWDATE:
3965 case IDM_SORTFIRST:
3966 if (!pAD->stopflag &&
3967 !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) {
3968 {
3969 USHORT dummy = SHORT1FROMMP(mp1);
3970
3971 PrfWriteProfileData(fmprof,
3972 appname,
3973 "Seeall.Sort", (PVOID) & dummy, sizeof(USHORT));
3974 SortType = SHORT1FROMMP(mp1);
3975 }
3976 WinSetPointer(HWND_DESKTOP, hptrBusy);
3977 WinSendMsg(hwnd, UM_RESCAN, MPFROMLONG(1), MPVOID);
3978 switch (SHORT1FROMMP(mp1)) {
3979 case IDM_SORTEASIZE:
3980 pAD->pfnCompare = (PFNSORT) NULL;
3981 ReSort(hwnd);
3982 break;
3983
3984 case IDM_SORTNAME:
3985 pAD->pfnCompare = comparefullnames;
3986 ReSort(hwnd);
3987 break;
3988
3989 case IDM_SORTFILENAME:
3990 pAD->pfnCompare = comparenames;
3991 ReSort(hwnd);
3992 break;
3993
3994 case IDM_SORTSIZE:
3995 pAD->pfnCompare = comparesizes;
3996 ReSort(hwnd);
3997 break;
3998
3999 case IDM_SORTLWDATE:
4000 pAD->pfnCompare = comparedates;
4001 ReSort(hwnd);
4002 break;
4003
4004 case IDM_SORTFIRST:
4005 pAD->pfnCompare = compareexts;
4006 ReSort(hwnd);
4007 break;
4008 }
4009 WinSetPointer(HWND_DESKTOP, hptrArrow);
4010 DosReleaseMutexSem(pAD->hmtxScan);
4011 WinInvalidateRect(hwnd, NULL, FALSE);
4012 }
4013 break;
4014
4015 case IDM_FILTER:
4016 if (!pAD->stopflag &&
4017 !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) {
4018 FilterList(hwnd);
4019 DosReleaseMutexSem(pAD->hmtxScan);
4020 }
4021 break;
4022
4023 case IDM_RESCAN:
4024 if (!pAD->stopflag &&
4025 !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) {
4026
4027 CHAR tempflags[26];
4028
4029 memcpy(tempflags, pAD->abDrvFlags, sizeof(tempflags));
4030 if (!WinDlgBox(HWND_DESKTOP, hwnd, AFDrvsWndProc, FM3ModHandle,
4031 DRVS_FRAME, (PVOID) pAD)) {
4032 memcpy(pAD->abDrvFlags, tempflags, sizeof(tempflags));
4033 *pAD->szFindPath = 0;
4034 DosReleaseMutexSem(pAD->hmtxScan);
4035 break;
4036 }
4037 WinSendMsg(pAD->hhscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1),
4038 MPVOID);
4039 WinSendMsg(pAD->hvscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1),
4040 MPVOID);
4041 pAD->topfile = 1;
4042 pAD->cursored = 1;
4043 pAD->selected = 0;
4044 pAD->ullSelectedBytes = 0;
4045 pAD->maxx = pAD->horzscroll = 0;
4046 FreeAllFilesList(hwnd);
4047 pAD->stopflag = 0;
4048 if (_beginthread(FindAllThread, NULL, 524288, (PVOID) hwnd) == -1) {
4049 Runtime_Error(pszSrcFile, __LINE__,
4050 GetPString(IDS_COULDNTSTARTTHREADTEXT));
4051 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
4052 DosReleaseMutexSem(pAD->hmtxScan);
4053 }
4054 else {
4055 DosReleaseMutexSem(pAD->hmtxScan);
4056 DosSleep(50);//05 Aug 07 GKY 100
4057 WinInvalidateRect(hwnd, NULL, FALSE);
4058 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
4059 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
4060 }
4061 }
4062 break;
4063 case IDM_UNHIDEALL:
4064 {
4065 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
4066 FilterAll(hwnd, ad);
4067 }
4068 break;
4069
4070 case IDM_DELETE:
4071 case IDM_PERMDELETE:
4072 case IDM_SELECTALL:
4073 case IDM_DESELECTALL:
4074 case IDM_INVERT:
4075 case IDM_SELECTMASK:
4076 case IDM_DESELECTMASK:
4077 case IDM_REMOVE:
4078 case IDM_HIDEALL:
4079 case IDM_COLLECT:
4080 case IDM_COLLECTOR:
4081 case IDM_SAVETOCLIP:
4082 case IDM_APPENDTOCLIP:
4083 case IDM_SAVETOLIST:
4084 case IDM_INFO:
4085 case IDM_ATTRS:
4086 case IDM_MOVE:
4087 case IDM_COPY:
4088 case IDM_RENAME:
4089 case IDM_MOVEPRESERVE:
4090 case IDM_COPYPRESERVE:
4091 case IDM_WILDMOVE:
4092 case IDM_WILDCOPY:
4093 case IDM_SUBJECT:
4094 case IDM_EAS:
4095 case IDM_PRINT:
4096 case IDM_ARCHIVE:
4097 case IDM_EXTRACT:
4098 case IDM_UUDECODE:
4099 case IDM_SHADOW:
4100 case IDM_OBJECT:
4101 case IDM_OPENSETTINGS:
4102 case IDM_OPENDEFAULT:
4103 if (!pAD->stopflag &&
4104 !DosRequestMutexSem(pAD->hmtxScan, SEM_IMMEDIATE_RETURN)) {
4105 switch (SHORT1FROMMP(mp1)) {
4106 case IDM_SELECTALL:
4107 case IDM_DESELECTALL:
4108 case IDM_INVERT:
4109 case IDM_HIDEALL:
4110 case IDM_REMOVE:
4111 Mark(hwnd, (SHORT1FROMMP(mp1) == IDM_DESELECTALL) ?
4112 AFM_UNMARK : (SHORT1FROMMP(mp1) == IDM_INVERT) ?
4113 AFM_INVERT : (SHORT1FROMMP(mp1) == IDM_HIDEALL) ?
4114 AFM_FILTER : (SHORT1FROMMP(mp1) == IDM_REMOVE) ?
4115 AFM_MARKDELETED : 0, NULL);
4116 if (SHORT1FROMMP(mp1) == IDM_REMOVE ||
4117 SHORT1FROMMP(mp1) == IDM_HIDEALL) {
4118 if (SHORT1FROMMP(mp1) == IDM_REMOVE)
4119 RemoveDeleted(hwnd);
4120 else
4121 ReSort(hwnd);
4122 }
4123 WinInvalidateRect(hwnd, NULL, FALSE);
4124 break;
4125
4126 case IDM_SELECTMASK:
4127 case IDM_DESELECTMASK:
4128 SelectMask(hwnd, (SHORT1FROMMP(mp1) == IDM_DESELECTMASK));
4129 WinInvalidateRect(hwnd, NULL, FALSE);
4130 break;
4131
4132 case IDM_DELETE:
4133 case IDM_PERMDELETE:
4134 case IDM_APPENDTOCLIP:
4135 case IDM_SAVETOCLIP:
4136 case IDM_SAVETOLIST:
4137 case IDM_COLLECT:
4138 case IDM_INFO:
4139 case IDM_ATTRS:
4140 case IDM_MOVE:
4141 case IDM_COPY:
4142 case IDM_RENAME:
4143 case IDM_MOVEPRESERVE:
4144 case IDM_COPYPRESERVE:
4145 case IDM_WILDMOVE:
4146 case IDM_WILDCOPY:
4147 case IDM_SUBJECT:
4148 case IDM_PRINT:
4149 case IDM_EAS:
4150 case IDM_ARCHIVE:
4151 case IDM_EXTRACT:
4152 case IDM_SHADOW:
4153 case IDM_OBJECT:
4154 case IDM_OPENSETTINGS:
4155 case IDM_OPENDEFAULT:
4156 case IDM_UUDECODE:
4157 {
4158 CHAR **list = BuildAList(hwnd);
4159
4160 if (!list)
4161 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
4162 else {
4163 switch (SHORT1FROMMP(mp1)) {
4164 case IDM_COLLECT:
4165 CollectList(hwnd, list);
4166 break;
4167 case IDM_DELETE:
4168 case IDM_PERMDELETE:
4169 case IDM_APPENDTOCLIP:
4170 case IDM_SAVETOCLIP:
4171 case IDM_SAVETOLIST:
4172 case IDM_INFO:
4173 case IDM_ATTRS:
4174 case IDM_MOVE:
4175 case IDM_COPY:
4176 case IDM_RENAME:
4177 case IDM_MOVEPRESERVE:
4178 case IDM_COPYPRESERVE:
4179 case IDM_WILDMOVE:
4180 case IDM_WILDCOPY:
4181 case IDM_SUBJECT:
4182 case IDM_PRINT:
4183 case IDM_EAS:
4184 case IDM_ARCHIVE:
4185 case IDM_EXTRACT:
4186 case IDM_UUDECODE:
4187 case IDM_OBJECT:
4188 case IDM_SHADOW:
4189 case IDM_OPENSETTINGS:
4190 case IDM_OPENDEFAULT:
4191 if (!PostMsg(pAD->hwndObj, UM_MASSACTION, mp1, MPFROMP(list)))
4192 FreeList(list);
4193 break;
4194 }
4195 if (fUnHilite) {
4196 Mark(hwnd, AFM_UNMARK, NULL);
4197 WinInvalidateRect(hwnd, NULL, FALSE);
4198 }
4199 }
4200 }
4201 break;
4202
4203 case IDM_COLLECTOR:
4204 if (mp2) {
4205
4206 CHAR **list = mp2;
4207
4208 if (Collector) {
4209 if (!PostMsg(Collector, WM_COMMAND,
4210 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
4211 FreeList(list);
4212 else if (fUnHilite) {
4213 Mark(hwnd, AFM_UNMARK, NULL);
4214 WinInvalidateRect(hwnd, NULL, FALSE);
4215 }
4216 }
4217 else
4218 FreeList(list);
4219 }
4220 break;
4221 }
4222 DosReleaseMutexSem(pAD->hmtxScan);
4223 }
4224 else if (SHORT1FROMMP(mp1) == IDM_COLLECTOR) {
4225 DosSleep(50);//05 Aug 07 GKY 100
4226 if (!PostMsg(hwnd, msg, mp1, mp2))
4227 WinSendMsg(hwnd, msg, mp1, mp2);
4228 }
4229 break;
4230
4231 case IDM_HELP:
4232 if (hwndHelp)
4233 WinSendMsg(hwndHelp,
4234 HM_DISPLAY_HELP,
4235 MPFROM2SHORT(HELP_SEEALL, 0), MPFROMSHORT(HM_RESOURCEID));
4236 break;
4237 }
4238 return 0;
4239
4240 case WM_SIZE:
4241// fprintf(stderr,"Seeall: WM_SIZE\n");
4242 PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
4243 break;
4244
4245 case WM_CLOSE:
4246// fprintf(stderr,"Seeall: WM_CLOSE\n");
4247 if (pAD)
4248 pAD->stopflag = 1;
4249 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
4250 return 0;
4251
4252 case WM_DESTROY:
4253// fprintf(stderr,"Seeall: WM_DESTROY\n");
4254 if (pAD) {
4255 pAD->stopflag = 1;
4256 if (pAD->hmtxScan) {
4257 DosRequestMutexSem(pAD->hmtxScan, 15000);
4258 DosCloseMutexSem(pAD->hmtxScan);
4259 }
4260 if (pAD->hwndPopup)
4261 WinDestroyWindow(pAD->hwndPopup);
4262 if (pAD->hwndObj) {
4263 if (!PostMsg(pAD->hwndObj, WM_CLOSE, MPVOID, MPVOID))
4264 WinSendMsg(pAD->hwndObj, WM_CLOSE, MPVOID, MPVOID);
4265 }
4266 if (pAD->hps) {
4267 GpiDeleteSetId(pAD->hps, FIXED_FONT_LCID);
4268 GpiAssociate(pAD->hps, 0);
4269 GpiDestroyPS(pAD->hps);
4270 }
4271 if (pAD->killme) {
4272 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
4273 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
4274 }
4275 FreeAllFilesList(hwnd);
4276 xfree(pAD, pszSrcFile, __LINE__);
4277# ifdef FORTIFY
4278 Fortify_LeaveScope();
4279# endif
4280 }
4281 break;
4282 }
4283
4284 return WinDefWindowProc(hwnd, msg, mp1, mp2);
4285}
4286
4287HWND StartSeeAll(HWND hwndParent, BOOL standalone, // called by applet
4288 CHAR * pszStartPath) // pathname or NULL
4289{
4290 HWND hwndFrame = (HWND) 0, hwndClient;
4291 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
4292 FCF_SIZEBORDER | FCF_MINMAX |
4293 FCF_NOBYTEALIGN | FCF_VERTSCROLL |
4294 FCF_MENU | FCF_ICON | FCF_ACCELTABLE | FCF_HORZSCROLL;
4295
4296 if (ParentIsDesktop(hwndParent, hwndParent))
4297 FrameFlags |= (FCF_TASKLIST | FCF_SHELLPOSITION);
4298 hwndFrame = WinCreateStdWindow(hwndParent,
4299 WS_VISIBLE,
4300 &FrameFlags,
4301 WC_SEEALL,
4302 GetPString(IDS_SEEALLTITLETEXT),
4303 WS_VISIBLE | fwsAnimate,
4304 FM3ModHandle, SEEALL_FRAME, &hwndClient);
4305 if (hwndFrame) {
4306 static CHAR *pszDir;
4307
4308 if (standalone) {
4309 if (!PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT),
4310 UM_SETUP4, MPVOID, MPVOID)) {
4311 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
4312 return (HWND) 0;
4313 }
4314 }
4315 if (pszStartPath) {
4316 // Needs to be static for other thread
4317 if (!pszDir)
4318 pszDir = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
4319 if (pszDir) {
4320 strcpy(pszDir, pszStartPath);
4321 pszStartPath = pszDir;
4322 }
4323 }
4324 PostMsg(WinWindowFromID(hwndFrame, FID_CLIENT),
4325 UM_SETUP5, MPFROMP(pszStartPath), MPVOID);
4326 }
4327 else if (standalone)
4328 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
4329 return hwndFrame;
4330}
4331
4332#pragma alloc_text(SEEALL,comparefullnames,comparenames,comparesizes)
4333#pragma alloc_text(SEEALL,comparedates,compareexts,SeeStatusProc)
4334#pragma alloc_text(SEEALL,InitWindow,PaintLine,SeeAllWndProc)
4335#pragma alloc_text(SEEALL,UpdateList,CollectList,ReSort,Mark)
4336#pragma alloc_text(SEEALL,BuildAList,RemoveDeleted,SeeFrameWndProc,FilterList,FilterAll)
4337#pragma alloc_text(SEEALL2,SeeObjWndProc,MakeSeeObjWinThread,FindDupesThread,DupeDlgProc)
4338#pragma alloc_text(SEEALL3,FreeAllFilesList,DoADir,FindAllThread,AFDrvsWndProc)
4339#pragma alloc_text(SEEALL3,StartSeeAll)
4340
Note: See TracBrowser for help on using the repository browser.