source: trunk/dll/collect.c@ 975

Last change on this file since 975 was 958, checked in by Gregg Young, 18 years ago

Add Unhide menu option every place that has hide (Ticket 218). Use additional xfrees where appropriate.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 75.7 KB
Line 
1
2/***********************************************************************
3
4 $Id: collect.c 958 2008-02-18 00:41:39Z gyoung $
5
6 Collector
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2003, 2008 Steven H. Levine
10
11 15 Oct 02 MK Baseline
12 10 Jan 04 SHL Avoid -1L byte counts
13 01 Aug 04 SHL Rework lstrip/rstrip usage
14 23 May 05 SHL Use QWL_USER
15 24 May 05 SHL Rework Win_Error usage
16 25 May 05 SHL Use ULONGLONG and CommaFmtULL
17 25 May 05 SHL Rework for FillInRecordFromFFB
18 05 Jun 05 SHL Use QWL_USER
19 06 Jun 05 SHL Indent -i2
20 06 Jun 05 SHL Make savedSortFlags static to avoid referencing garbage
21 24 Oct 05 SHL Sanitize handle references
22 24 Oct 05 SHL CollectorCnrWndProc: avoid excess writes to Status2 window
23 10 Nov 05 SHL CollectorCnrWndProc: correct missing button window updates
24 14 Jul 06 SHL Use Runtime_Error
25 27 Jul 06 SHL Avoid shutdown hang - pre3 typo
26 29 Jul 06 SHL Use xfgets_bstripcr
27 15 Aug 06 SHL Don't write garbage to CollectorFilter INI entry
28 15 Aug 06 SHL Rework SetMask args
29 18 Aug 06 SHL CollectorCnrWndProc: avoid freeing NULL pointer
30 31 Aug 06 SHL Disable Utilities->Seek and scan menu while busy
31 31 Aug 06 SHL Correct stop scan context menu enable/disable
32 30 Mar 07 GKY Remove GetPString for window class names
33 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
34 06 Apr 07 GKY Add some error checking in drag/drop
35 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checks.
36 12 May 07 SHL Use dcd->ulItemsToUnHilite
37 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
38 05 Jul 07 SHL CollectorCnrWndProc: just warn if busy
39 02 Aug 07 SHL Sync with CNRITEM mods
40 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
41 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
42 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
43 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
44 10 Jan 08 SHL Sync with CfgDlgProc mods
45 10 Feb 08 GKY Implement bubble help for bitmap menu items
46 15 Feb 08 SHL Sync with settings menu rework
47 15 Feb 08 GKY Fix attempt to free container items that were never inserted
48 15 Feb 08 GKY Fix "collect" so it updates recollected files and unhides them if needed
49
50***********************************************************************/
51
52#include <stdlib.h>
53#include <string.h>
54#include <ctype.h>
55#include <share.h>
56#include <limits.h>
57#include <process.h> // _beginthread
58
59#define INCL_DOS // QSV_MS_COUNT
60#define INCL_WIN
61#define INCL_DOSERRORS
62#define INCL_LONGLONG
63
64#include "fm3dlg.h"
65#include "fm3str.h"
66#include "mle.h"
67#include "grep.h"
68#include "comp.h"
69#include "arccnrs.h" // StartArcCnr
70#include "filldir.h" // EmptyCnr...
71#include "strutil.h" // GetPString
72#include "errutil.h" // Runtime_Error
73#include "tmrsvcs.h" // ITIMER_DESC
74#include "notebook.h" // CfgDlgProc
75#include "fm3dll.h"
76
77#pragma data_seg(DATA1)
78
79static PSZ pszSrcFile = __FILE__;
80
81MRESULT EXPENTRY CollectorFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
82 MPARAM mp2)
83{
84 return CommonFrameWndProc(COLLECTOR_CNR, hwnd, msg, mp1, mp2);
85}
86
87MRESULT EXPENTRY CollectorTextProc(HWND hwnd, ULONG msg, MPARAM mp1,
88 MPARAM mp2)
89{
90 DIRCNRDATA *dcd;
91
92 static BOOL emphasized = FALSE;
93 static HWND hwndButtonPopup = (HWND) 0;
94 static ULONG timestamp = ULONG_MAX;
95 static USHORT lastid = 0;
96
97 switch (msg) {
98 case WM_CREATE:
99 return CommonTextProc(hwnd, msg, mp1, mp2);
100
101 case UM_CONTEXTMENU:
102 case WM_CONTEXTMENU:
103 {
104 USHORT id;
105
106 id = WinQueryWindowUShort(hwnd, QWS_ID);
107 switch (id) {
108 case DIR_SELECTED:
109 case DIR_VIEW:
110 case DIR_SORT:
111 {
112 POINTL ptl = { 0, 0 };
113 SWP swp;
114
115 if (hwndButtonPopup)
116 WinDestroyWindow(hwndButtonPopup);
117 if (id == lastid) {
118 ULONG check;
119
120 DosQuerySysInfo(QSV_MS_COUNT,
121 QSV_MS_COUNT, &check, sizeof(check));
122 if (check < timestamp + 500) {
123 lastid = 0;
124 goto MenuAbort;
125 }
126 }
127 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
128 if (hwndButtonPopup) {
129 WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
130 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
131 QW_PARENT),
132 COLLECTOR_CNR), QWL_USER);
133 if (id == DIR_VIEW) {
134 if (dcd) {
135 SetViewMenu(hwndButtonPopup, dcd->flWindowAttr);
136 SetDetailsSwitches(hwndButtonPopup, dcd);
137 CopyPresParams(hwndButtonPopup, hwnd);
138 }
139
140 /* don't have tree view in collector */
141 WinSendMsg(hwndButtonPopup,
142 MM_DELETEITEM,
143 MPFROM2SHORT(IDM_TREEVIEW, FALSE), MPVOID);
144
145 }
146 else if (id == DIR_SORT) {
147 if (dcd)
148 SetSortChecks(hwndButtonPopup, dcd->sortFlags);
149 }
150 ptl.x = 0;
151 if (WinPopupMenu(HWND_OBJECT,
152 HWND_OBJECT,
153 hwndButtonPopup, -32767, -32767, 0, 0)) {
154 WinQueryWindowPos(hwndButtonPopup, &swp);
155 ptl.y = -(swp.cy + 2);
156 }
157 else {
158 WinQueryWindowPos(hwnd, &swp);
159 ptl.y = swp.cy + 2;
160 }
161 if (WinPopupMenu(hwnd,
162 hwnd,
163 hwndButtonPopup,
164 ptl.x,
165 ptl.y,
166 0,
167 PU_HCONSTRAIN | PU_VCONSTRAIN |
168 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
169 CenterOverWindow(hwndButtonPopup);
170 PaintRecessedWindow(hwnd, NULLHANDLE, FALSE, FALSE);
171 }
172 }
173 }
174 break;
175 default:
176 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
177 COLLECTOR_CNR),
178 WM_CONTROL,
179 MPFROM2SHORT(COLLECTOR_CNR, CN_CONTEXTMENU), MPVOID);
180 break;
181 }
182 }
183 MenuAbort:
184 if (msg == UM_CONTEXTMENU)
185 return 0;
186 break;
187
188 case WM_MENUEND:
189 if (hwndButtonPopup == (HWND) mp2) {
190 lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
191 WinDestroyWindow(hwndButtonPopup);
192 hwndButtonPopup = (HWND) 0;
193 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &timestamp,
194 sizeof(timestamp));
195 switch (lastid) {
196 case DIR_SELECTED:
197 case DIR_VIEW:
198 case DIR_SORT:
199 PaintRecessedWindow(hwnd, NULLHANDLE, TRUE, FALSE);
200 break;
201 }
202 }
203 break;
204
205 case WM_COMMAND:
206 {
207 DIRCNRDATA *dcd;
208 MRESULT mr;
209
210 mr = WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,
211 QW_PARENT),
212 COLLECTOR_CNR), msg, mp1, mp2);
213 if (hwndButtonPopup &&
214 SHORT1FROMMP(mp1) > IDM_DETAILSTITLES &&
215 SHORT1FROMMP(mp1) < IDM_DETAILSSETUP) {
216 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
217 QW_PARENT),
218 COLLECTOR_CNR), QWL_USER);
219 if (dcd)
220 SetDetailsSwitches(hwndButtonPopup, dcd);
221 }
222 return mr;
223 }
224
225 case WM_MOUSEMOVE:
226 {
227 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
228 char *s = NULL;
229
230 if (fOtherHelp) {
231 if ((!hwndBubble ||
232 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
233 !WinQueryCapture(HWND_DESKTOP)) {
234 switch (id) {
235 case DIR_SELECTED:
236 s = GetPString(IDS_COLSELECTEDHELP);
237 break;
238 case DIR_TOTALS:
239 s = GetPString(IDS_COLTOTALSHELP);
240 break;
241 case DIR_VIEW:
242 s = GetPString(IDS_DIRCNRVIEWHELP);
243 break;
244 case DIR_SORT:
245 s = GetPString(IDS_DIRCNRSORTHELP);
246 break;
247 case DIR_FILTER:
248 s = GetPString(IDS_DIRCNRFILTERHELP);
249 break;
250 default:
251 break;
252 }
253 if (s)
254 MakeBubble(hwnd, TRUE, s);
255 else if (hwndBubble)
256 WinDestroyWindow(hwndBubble);
257 }
258 }
259 switch (id) {
260 case DIR_FILTER:
261 case DIR_SORT:
262 case DIR_VIEW:
263 case DIR_SELECTED:
264 return CommonTextButton(hwnd, msg, mp1, mp2);
265 }
266 }
267 break;
268
269 case WM_BUTTON3UP:
270 case WM_BUTTON1UP:
271 case WM_BUTTON3DOWN:
272 case WM_BUTTON1DOWN:
273 {
274 USHORT id;
275
276 id = WinQueryWindowUShort(hwnd, QWS_ID);
277 switch (id) {
278 case DIR_FILTER:
279 case DIR_SORT:
280 case DIR_VIEW:
281 case DIR_SELECTED:
282 return CommonTextButton(hwnd, msg, mp1, mp2);
283 }
284 }
285 break;
286
287 case UM_CLICKED:
288 case UM_CLICKED3:
289 {
290 USHORT id, cmd = 0;
291
292 id = WinQueryWindowUShort(hwnd, QWS_ID);
293 switch (id) {
294 case DIR_VIEW:
295 case DIR_SORT:
296 case DIR_SELECTED:
297 PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
298 break;
299 case DIR_FILTER:
300 cmd = IDM_FILTER;
301 break;
302 default:
303 break;
304 }
305 if (cmd)
306 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
307 COLLECTOR_CNR),
308 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
309 }
310 return 0;
311
312 case DM_DROP:
313 case DM_DRAGOVER:
314 case DM_DRAGLEAVE:
315 case DM_DROPHELP:
316 if (msg == DM_DRAGOVER) {
317 if (!emphasized) {
318 emphasized = TRUE;
319 DrawTargetEmphasis(hwnd, emphasized);
320 }
321 }
322 else {
323 if (emphasized) {
324 emphasized = FALSE;
325 DrawTargetEmphasis(hwnd, emphasized);
326 }
327 }
328 {
329 CNRDRAGINFO cnd;
330 USHORT dcmd;
331
332 switch (msg) {
333 case DM_DROP:
334 dcmd = CN_DROP;
335 break;
336 case DM_DRAGOVER:
337 dcmd = CN_DRAGOVER;
338 break;
339 case DM_DRAGLEAVE:
340 dcmd = CN_DRAGLEAVE;
341 break;
342 case DM_DROPHELP:
343 dcmd = CN_DROPHELP;
344 break;
345 }
346 memset(&cnd, 0, sizeof(cnd));
347 cnd.pDragInfo = (PDRAGINFO) mp1;
348 cnd.pRecord = NULL;
349 return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_CONTROL,
350 MPFROM2SHORT(COLLECTOR_CNR, dcmd), MPFROMP(&cnd));
351 }
352 }
353 return PFNWPStatic(hwnd, msg, mp1, mp2);
354}
355
356MRESULT EXPENTRY CollectorClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
357 MPARAM mp2)
358{
359 switch (msg) {
360 case UM_CONTAINERHWND:
361 return MRFROMLONG(WinWindowFromID(hwnd, COLLECTOR_CNR));
362
363 case UM_VIEWSMENU:
364 return MRFROMLONG(CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP));
365
366 case MM_PORTHOLEINIT:
367 case WM_INITMENU:
368 case UM_INITMENU:
369 case UM_CONTAINER_FILLED:
370 case UM_FILESMENU:
371 case UM_UPDATERECORD:
372 case UM_UPDATERECORDLIST:
373 return WinSendMsg(WinWindowFromID(hwnd, COLLECTOR_CNR), msg, mp1, mp2);
374
375 case WM_PSETFOCUS:
376 case WM_SETFOCUS:
377 if (mp2)
378 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
379 break;
380
381 case UM_FOCUSME:
382 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, COLLECTOR_CNR));
383 break;
384
385 case WM_PAINT:
386 {
387 HPS hps;
388 RECTL rcl;
389
390 hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
391 if (hps) {
392 WinQueryWindowRect(hwnd, &rcl);
393 WinFillRect(hps, &rcl, CLR_PALEGRAY);
394 CommonTextPaint(hwnd, hps);
395 WinEndPaint(hps);
396 }
397 }
398 break;
399
400 case UM_SIZE:
401 case WM_SIZE:
402 if (msg == UM_SIZE) {
403 SWP swp;
404
405 WinQueryWindowPos(hwnd, &swp);
406 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
407 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
408 }
409 {
410 USHORT cx, cy, bx;
411
412 cx = SHORT1FROMMP(mp2);
413 cy = SHORT2FROMMP(mp2);
414 WinSetWindowPos(WinWindowFromID(hwnd, COLLECTOR_CNR), HWND_TOP,
415 0, 0, cx, cy - 24, SWP_SHOW | SWP_MOVE | SWP_SIZE);
416 WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
417 2,
418 cy - 22,
419 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
420 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
421 2 + (cx / 3) + 2,
422 cy - 22,
423 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
424 bx = (cx - (2 + (((cx / 3) + 2) * 2))) / 3;
425 WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
426 2 + (((cx / 3) + 2) * 2),
427 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
428 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
429 2 + (((cx / 3) + 2) * 2) + bx,
430 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
431 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
432 2 + (((cx / 3) + 2) * 2) + (bx * 2),
433 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
434 }
435 CommonTextPaint(hwnd, NULLHANDLE);
436 if (msg == UM_SIZE) {
437 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
438 SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
439 return 0;
440 }
441 break;
442
443 case UM_COMMAND:
444 case WM_COMMAND:
445 case WM_CONTROL:
446 case WM_CLOSE:
447 return WinSendMsg(WinWindowFromID(hwnd, COLLECTOR_CNR), msg, mp1, mp2);
448 }
449 return WinDefWindowProc(hwnd, msg, mp1, mp2);
450}
451
452MRESULT EXPENTRY CollectorObjWndProc(HWND hwnd, ULONG msg,
453 MPARAM mp1, MPARAM mp2)
454{
455 ULONG size;
456 DIRCNRDATA *dcd;
457
458 switch (msg) {
459 case WM_CREATE:
460 break;
461
462 case DM_PRINTOBJECT:
463 return MRFROMLONG(DRR_TARGET);
464
465 case DM_DISCARDOBJECT:
466 dcd = INSTDATA(hwnd);
467 if (fFM2Deletes && dcd) {
468 LISTINFO *li;
469 CNRDRAGINFO cni;
470
471 cni.pRecord = NULL;
472 cni.pDragInfo = (PDRAGINFO) mp1;
473 li = DoFileDrop(dcd->hwndCnr, NULL, FALSE, MPVOID, MPFROMP(&cni));
474 CheckPmDrgLimit(cni.pDragInfo);
475 if (li) {
476 li->type = fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE;
477 if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
478 FreeListInfo(li);
479 else
480 return MRFROMLONG(DRR_SOURCE);
481 }
482 }
483 return MRFROMLONG(DRR_TARGET);
484
485 case UM_UPDATERECORDLIST:
486 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
487 if (dcd && mp1) {
488 INT numentries = 0;
489 CHAR **list = (CHAR **) mp1;
490
491 while (list[numentries])
492 numentries++;
493 if (numentries)
494 UpdateCnrList(dcd->hwndCnr, list, numentries, FALSE, dcd);
495 }
496 return 0;
497
498 case UM_SETUP:
499 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
500 if (dcd) {
501 /* set unique id */
502 WinSetWindowUShort(hwnd,
503 QWS_ID,
504 COLLECTOROBJ_FRAME + (COLLECTOR_FRAME - dcd->id));
505 dcd->hwndObject = hwnd;
506 // 09 Feb 08 SHL fixme to be sure applet does not really need this
507 // if (ParentIsDesktop(hwnd, dcd->hwndParent))
508 // DosSleep(100); //05 Aug 07 GKY 250
509 }
510 else
511 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
512 return 0;
513
514 case UM_COMMAND:
515 if (mp1) {
516 LISTINFO *li = (LISTINFO *) mp1;
517
518 switch (li->type) {
519 case IDM_DOITYOURSELF:
520 case IDM_APPENDTOCLIP:
521 case IDM_SAVETOCLIP:
522 case IDM_ARCHIVE:
523 case IDM_ARCHIVEM:
524 case IDM_VIEW:
525 case IDM_VIEWTEXT:
526 case IDM_VIEWBINARY:
527 case IDM_VIEWARCHIVE:
528 case IDM_EDIT:
529 case IDM_EDITTEXT:
530 case IDM_EDITBINARY:
531 case IDM_OBJECT:
532 case IDM_SHADOW:
533 case IDM_SHADOW2:
534 case IDM_PRINT:
535 case IDM_ATTRS:
536 case IDM_DELETE:
537 case IDM_PERMDELETE:
538 case IDM_FAKEEXTRACT:
539 case IDM_FAKEEXTRACTM:
540 case IDM_MCIPLAY:
541 case IDM_UPDATE:
542 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
543 return (MRESULT) TRUE;
544 break;
545 default:
546 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
547 return (MRESULT) TRUE;
548 }
549 }
550 return 0;
551
552 case UM_COLLECT:
553 DosError(FERR_DISABLEHARDERR);
554 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
555 if (dcd) {
556 LISTINFO *li = (LISTINFO *) mp1;
557 INT x;
558 FILEFINDBUF4L fb4;
559 HDIR hdir;
560 ULONG nm;
561 PCNRITEM pci, pciFirst, pciT, pciP = NULL;
562 RECORDINSERT ri;
563 ULONG ulMaxFiles;
564 ULONGLONG ullTotalBytes;
565 CHAR fullname[CCHMAXPATH];
566
567 if (!hwndStatus) {
568 WinSetWindowText(WinWindowFromID(dcd->hwndClient, DIR_SELECTED),
569 GetPString(IDS_COLLECTINGTEXT));
570 }
571 else {
572 if (WinQueryFocus(HWND_DESKTOP) == dcd->hwndCnr)
573 WinSetWindowText(hwndStatus, GetPString(IDS_COLLECTINGTEXT));
574 }
575
576 for (ulMaxFiles = 0; li->list[ulMaxFiles]; ulMaxFiles++) ; // Count
577
578 if (ulMaxFiles) {
579 pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD,
580 MPFROMLONG(EXTRA_RECORD_BYTES),
581 MPFROMLONG(ulMaxFiles));
582 if (!pci) {
583 Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
584 ulMaxFiles);
585 break;
586 }
587 else {
588 ITIMER_DESC itdSleep = { 0 }; // 06 Feb 08 SHL
589 InitITimer(&itdSleep, 500); // Sleep every 500 mSec
590 pciFirst = pci;
591 // 04 Jan 08 SHL fixme like comp.c if CM_ALLOCRECORD returns unexpected record count
592 for (x = 0; li->list[x]; x++) {
593 nm = 1;
594 hdir = HDIR_CREATE;
595 DosError(FERR_DISABLEHARDERR);
596 if (FindCnrRecord(dcd->hwndCnr,
597 li->list[x],
598 NULL,
599 FALSE,
600 FALSE,
601 TRUE)) {
602 pci = UpdateCnrRecord(dcd->hwndCnr, li->list[x], FALSE, dcd);
603 if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
604 pci->rc.flRecordAttr &= ~CRA_FILTERED;
605 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
606 MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
607 }
608 pci = (PCNRITEM) pci->rc.preccNextRecord;
609 if (pciP)
610 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
611 else
612 pciFirst = pci;
613 }
614 else if (*li->list[x] &&
615 !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
616 fullname, sizeof(fullname)) &&
617 !IsRoot(fullname) &&
618 !xDosFindFirst(fullname,
619 &hdir,
620 FILE_NORMAL | FILE_DIRECTORY |
621 FILE_ARCHIVED | FILE_SYSTEM |
622 FILE_HIDDEN | FILE_READONLY,
623 &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL)) {
624 DosFindClose(hdir);
625 priority_normal();
626 *fb4.achName = 0;
627 ullTotalBytes = FillInRecordFromFFB(dcd->hwndCnr,
628 pci,
629 fullname, &fb4, FALSE, dcd);
630 dcd->ullTotalBytes += ullTotalBytes;
631 pciP = pci;
632 pci = (PCNRITEM) pci->rc.preccNextRecord;
633 }
634 else {
635 // Oops - fixme to complain?
636 pciT = pci;
637 pci = (PCNRITEM) pci->rc.preccNextRecord;
638 if (pciP)
639 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
640 else
641 pciFirst = pci;
642 if (pciT)
643 FreeCnrItemData(pciT); // FreeCnrItem(hwnd, pciT);
644 ulMaxFiles--; // Remember gone
645 }
646 SleepIfNeeded(&itdSleep, 1); // 09 Feb 08 SHL
647 // DosSleep(0); //26 Aug 07 GKY 1 // 09 Feb 08 SHL
648 } // for
649 if (ulMaxFiles) {
650 // Some files OK
651 memset(&ri, 0, sizeof(RECORDINSERT));
652 ri.cb = sizeof(RECORDINSERT);
653 ri.pRecordOrder = (PRECORDCORE) CMA_END;
654 ri.pRecordParent = (PRECORDCORE) 0;
655 ri.zOrder = (ULONG) CMA_TOP;
656 ri.cRecordsInsert = ulMaxFiles;
657 ri.fInvalidateRecord = TRUE;
658 WinSendMsg(dcd->hwndCnr,
659 CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
660 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
661 }
662 }
663 }
664 }
665 if (dcd->flWindowAttr & CV_DETAIL)
666 WinSendDlgItemMsg(hwnd,
667 COLLECTOR_CNR,
668 CM_INVALIDATERECORD,
669 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
670 return 0;
671
672 case UM_COLLECTFROMFILE:
673 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
674 if (dcd && mp1) {
675 FILESTATUS4L fs4;
676 PCNRITEM pci;
677 RECORDINSERT ri;
678 CHAR fullname[1024], *p;
679 FILE *fp;
680 ULONG errs = 0;
681 BOOL first = FALSE;
682 size_t c;
683
684 fp = _fsopen((CHAR *) mp1, "r", SH_DENYNO);
685 if (fp) {
686 while (!feof(fp)) {
687 // Avoid too much noise if collecting from binary file - oops
688 if (!fgets(fullname, sizeof(fullname), fp)) {
689 if (ferror(fp))
690 Runtime_Error(pszSrcFile, __LINE__, "fgets");
691 break;
692 }
693
694 c = strlen(fullname);
695 if (c + 1 >= sizeof(fullname))
696 errs++;
697 else if (!c || (fullname[c - 1] != '\n' && fullname[c - 1] != '\r'))
698 errs++;
699 else {
700 bstripcr(fullname);
701
702 if (*fullname == '\"') {
703 memmove(fullname, fullname + 1, strlen(fullname) + 1);
704 lstrip(fullname);
705 p = strchr(fullname, '\"');
706 if (p)
707 *p = 0;
708 rstrip(fullname);
709 }
710 else {
711 p = strchr(fullname, ' ');
712 if (p)
713 *p = 0;
714 }
715 /* fullname now contains name of file to collect */
716 DosError(FERR_DISABLEHARDERR);
717 if (FindCnrRecord(dcd->hwndCnr,
718 fullname,
719 NULL,
720 FALSE,
721 FALSE,
722 TRUE)) {
723 pci = UpdateCnrRecord(dcd->hwndCnr, fullname, FALSE, dcd);
724 if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
725 pci->rc.flRecordAttr &= ~CRA_FILTERED;
726 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
727 MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
728 }
729 /*pci = (PCNRITEM) pci->rc.preccNextRecord;
730 if (pciP)
731 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
732 else
733 pciFirst = pci;*/
734 }
735 else if (IsFullName(fullname) &&
736 !IsRoot(fullname) &&
737 !DosQueryPathInfo(fullname,
738 FIL_QUERYEASIZEL,
739 &fs4,
740 sizeof(fs4))) {
741 /* collect it */
742 pci = WinSendMsg(dcd->hwndCnr,
743 CM_ALLOCRECORD,
744 MPFROMLONG(EXTRA_RECORD_BYTES),
745 MPFROMLONG(1));
746 if (pci) {
747 dcd->ullTotalBytes += FillInRecordFromFSA(dcd->hwndCnr, pci,
748 fullname,
749 &fs4, FALSE, dcd);
750 memset(&ri, 0, sizeof(RECORDINSERT));
751 ri.cb = sizeof(RECORDINSERT);
752 ri.pRecordOrder = (PRECORDCORE) CMA_END;
753 ri.pRecordParent = (PRECORDCORE) 0;
754 ri.zOrder = (ULONG) CMA_TOP;
755 ri.cRecordsInsert = 1;
756 ri.fInvalidateRecord = TRUE;
757 WinSendMsg(dcd->hwndCnr, CM_INSERTRECORD,
758 MPFROMP(pci), MPFROMP(&ri));
759 }
760 }
761 else
762 errs++;
763 }
764 if (errs > (first ? 0 : 50)) {
765 /* prevent runaway on bad file */
766 APIRET ret = saymsg(MB_YESNO, dcd->hwndCnr,
767 GetPString(IDS_COLLECTNOLISTHDRTEXT),
768 GetPString(IDS_COLLECTNOLISTTEXT),
769 (CHAR *) mp1);
770
771 if (ret == MBID_NO)
772 break;
773 if (!first)
774 errs = 0;
775 else
776 first = FALSE;
777 }
778 } // while not eof
779 fclose(fp);
780 }
781 }
782 xfree(mp1);
783 return 0;
784
785 case UM_SELECT:
786 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
787 if (dcd) {
788 switch (SHORT1FROMMP(mp1)) {
789 case IDM_SELECTLIST:
790 {
791 CHAR filename[CCHMAXPATH], *p, *pp;
792
793 strcpy(filename, "*.LST");
794 size = CCHMAXPATH;
795 PrfQueryProfileData(fmprof, appname, "SaveToListName", filename,
796 &size);
797 pp = strrchr(filename, '\\');
798 if (!pp)
799 pp = filename;
800 p = strrchr(pp, '.');
801 if (p && *(p + 1) && p > pp + 1) {
802 if (pp > filename)
803 pp++;
804 *pp = '*';
805 pp++;
806 if (p > pp)
807 memmove(pp, p, strlen(p) + 1);
808 }
809 if (insert_filename(hwnd, filename, FALSE, FALSE))
810 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
811 NULL);
812 }
813 break;
814 case IDM_SELECTALL:
815 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
816 break;
817 case IDM_DESELECTALL:
818 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
819 break;
820 case IDM_SELECTALLFILES:
821 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
822 break;
823 case IDM_DESELECTALLFILES:
824 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
825 break;
826 case IDM_SELECTALLDIRS:
827 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
828 break;
829 case IDM_DESELECTALLDIRS:
830 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
831 break;
832 case IDM_DESELECTMASK:
833 case IDM_SELECTMASK:
834 {
835 MASK mask;
836 PCNRITEM pci = (PCNRITEM) mp2;
837
838 memset(&mask, 0, sizeof(MASK));
839 mask.fNoAttribs = TRUE;
840 mask.fNoDirs = TRUE;
841 mask.fText = TRUE;
842 strcpy(mask.prompt,
843 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
844 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
845 if (pci && (INT) pci != -1)
846 strcpy(mask.szMask, pci->pszFileName);
847 if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
848 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
849 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
850 SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
851 FALSE);
852 else
853 DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
854 FALSE);
855 }
856 }
857
858 case IDM_DESELECTCLIP:
859 case IDM_SELECTCLIP:
860 {
861 CHAR **list;
862
863 list = ListFromClipboard(hwnd);
864 if (list) {
865 SelectList(dcd->hwndCnr, TRUE, FALSE,
866 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
867 NULL, NULL, list);
868 FreeList(list);
869 }
870 }
871 break;
872
873 case IDM_INVERT:
874 InvertAll(dcd->hwndCnr);
875 break;
876 }
877 }
878 return 0;
879
880 case UM_MASSACTION:
881 if (mp1) {
882 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
883 if (dcd) {
884 WORKER *wk;
885
886 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
887 if (!wk)
888 FreeListInfo((LISTINFO *) mp1);
889 else {
890 wk->size = sizeof(WORKER);
891 wk->hwndCnr = dcd->hwndCnr;
892 wk->hwndParent = dcd->hwndParent;
893 wk->hwndFrame = dcd->hwndFrame;
894 wk->hwndClient = dcd->hwndClient;
895 wk->li = (LISTINFO *) mp1;
896 strcpy(wk->directory, dcd->directory);
897 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
898 Runtime_Error(pszSrcFile, __LINE__,
899 GetPString(IDS_COULDNTSTARTTHREADTEXT));
900 free(wk);
901 FreeListInfo((LISTINFO *) mp1);
902 }
903 }
904 }
905 }
906 return 0;
907
908 case UM_ACTION:
909 if (mp1) {
910 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
911 if (dcd) {
912 WORKER *wk;
913
914 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
915 if (!wk)
916 FreeListInfo((LISTINFO *) mp1);
917 else {
918 wk->size = sizeof(WORKER);
919 wk->hwndCnr = dcd->hwndCnr;
920 wk->hwndParent = dcd->hwndParent;
921 wk->hwndFrame = dcd->hwndFrame;
922 wk->hwndClient = dcd->hwndClient;
923 wk->li = (LISTINFO *) mp1;
924 strcpy(wk->directory, dcd->directory);
925 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
926 Runtime_Error(pszSrcFile, __LINE__,
927 GetPString(IDS_COULDNTSTARTTHREADTEXT));
928 free(wk);
929 FreeListInfo((LISTINFO *) mp1);
930 }
931 }
932 }
933 }
934 return 0;
935
936 case WM_CLOSE:
937 WinDestroyWindow(hwnd);
938 break;
939
940 case WM_DESTROY:
941 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
942 if (dcd) {
943 INT x;
944
945 dcd->stopflag = 1;
946 // Allow other threads to honor stop request
947 for (x = 0; x < 100 && dcd->amextracted; x++)
948 DosSleep(10);
949 if (dcd->amextracted)
950 Runtime_Error(pszSrcFile, __LINE__, "still busy");
951 WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
952 FreeList(dcd->lastselection);
953 free(dcd);
954 }
955 DosPostEventSem(CompactSem);
956 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
957 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
958 break;
959 }
960 return WinDefWindowProc(hwnd, msg, mp1, mp2);
961}
962
963MRESULT EXPENTRY CollectorCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
964 MPARAM mp2)
965{
966 DIRCNRDATA *dcd = INSTDATA(hwnd);
967 ULONG size;
968
969 static INT savedSortFlags;
970
971 switch (msg) {
972 case DM_PRINTOBJECT:
973 return MRFROMLONG(DRR_TARGET);
974
975 case DM_DISCARDOBJECT:
976 if (dcd)
977 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
978 else
979 return MRFROMLONG(DRR_TARGET);
980
981 case WM_CHAR:
982 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
983 if (SHORT1FROMMP(mp1) & KC_KEYUP)
984 return (MRESULT) TRUE;
985 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
986 switch (SHORT2FROMMP(mp2)) {
987 case VK_DELETE:
988 if ((shiftstate & KC_CTRL) == KC_CTRL)
989 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
990 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
991 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
992 else
993 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
994 break;
995 }
996 }
997 if (shiftstate || fNoSearch)
998 break;
999 if (SHORT1FROMMP(mp1) & KC_CHAR) {
1000 ULONG thistime, len;
1001 SEARCHSTRING srch;
1002 PCNRITEM pci;
1003
1004 if (!dcd)
1005 break;
1006 switch (SHORT1FROMMP(mp2)) {
1007 case '\x1b':
1008 case '\r':
1009 case '\n':
1010 dcd->lasttime = 0;
1011 *dcd->szCommonName = 0;
1012 break;
1013 default:
1014 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1015 if (thistime > dcd->lasttime + 1250)
1016 *dcd->szCommonName = 0;
1017 dcd->lasttime = thistime;
1018 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
1019 break;
1020 KbdRetry:
1021 len = strlen(dcd->szCommonName);
1022 if (len >= CCHMAXPATH - 1) {
1023 *dcd->szCommonName = 0;
1024 len = 0;
1025 }
1026 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1027 dcd->szCommonName[len + 1] = 0;
1028 memset(&srch, 0, sizeof(SEARCHSTRING));
1029 srch.cb = sizeof(SEARCHSTRING);
1030 srch.pszSearch = dcd->szCommonName;
1031 srch.fsPrefix = TRUE;
1032 srch.fsCaseSensitive = FALSE;
1033 srch.usView = CV_ICON;
1034 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
1035 MPFROMLONG(CMA_FIRST));
1036 if (pci && (INT) pci != -1) {
1037 USHORT attrib = CRA_CURSORED;
1038
1039 /* make found item current item */
1040 if (!stricmp(pci->pszFileName, dcd->szCommonName))
1041 attrib |= CRA_SELECTED;
1042 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1043 MPFROM2SHORT(TRUE, attrib));
1044 /* make sure that record shows in viewport */
1045 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1046 return (MRESULT) TRUE;
1047 }
1048 else {
1049 if (SHORT1FROMMP(mp2) == ' ') {
1050 dcd->szCommonName[len] = 0;
1051 break;
1052 }
1053 *dcd->szCommonName = 0;
1054 dcd->lasttime = 0;
1055 if (len) // retry as first letter if no match
1056
1057 goto KbdRetry;
1058 }
1059 break;
1060 }
1061 }
1062 break;
1063
1064 case WM_MOUSEMOVE:
1065 case WM_BUTTON1UP:
1066 case WM_BUTTON2UP:
1067 case WM_BUTTON3UP:
1068 case WM_CHORD:
1069 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1070 break;
1071
1072 case WM_BUTTON1MOTIONEND:
1073 {
1074 CNRINFO cnri;
1075
1076 memset(&cnri, 0, sizeof(CNRINFO));
1077 cnri.cb = sizeof(CNRINFO);
1078 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1079 MPFROMLONG(sizeof(CNRINFO)))) {
1080 if (cnri.flWindowAttr & CV_DETAIL)
1081 PrfWriteProfileData(fmprof, appname, "CollectorCnrSplitBar",
1082 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
1083 }
1084 }
1085 break;
1086
1087 case WM_PRESPARAMCHANGED:
1088 PresParamChanged(hwnd, "Collector", mp1, mp2);
1089 break;
1090
1091 case UM_COMPARE:
1092 if (dcd && mp1 && mp2) {
1093 COMPARE *cmp;
1094 CHAR *leftdir = (CHAR *) mp1, *rightdir = (CHAR *) mp2;
1095
1096 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1097 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1098 if (cmp) {
1099 cmp->size = sizeof(COMPARE);
1100 strcpy(cmp->leftdir, leftdir);
1101 strcpy(cmp->rightdir, rightdir);
1102 cmp->hwndParent = dcd->hwndParent;
1103 cmp->dcd.hwndParent = dcd->hwndParent;
1104 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, CompareDlgProc,
1105 FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1106 }
1107 }
1108 }
1109 return 0;
1110
1111 case UM_UPDATERECORDLIST:
1112 if (dcd && mp1)
1113 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1114 return 0;
1115
1116 case UM_UPDATERECORD:
1117 if (dcd && mp1) {
1118 CHAR *filename;
1119
1120 filename = mp1;
1121 if (filename)
1122 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1123 }
1124 return 0;
1125
1126 case WM_SETFOCUS:
1127 /*
1128 * put name of our window on status line
1129 */
1130 if (dcd && hwndStatus && mp2) {
1131 PCNRITEM pci = NULL;
1132
1133 if (fAutoView && hwndMain) {
1134 pci = WinSendMsg(hwnd,
1135 CM_QUERYRECORDEMPHASIS,
1136 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1137 if (pci && (INT) pci != -1 &&
1138 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1139 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1140 else
1141 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1142 }
1143 if (dcd->amextracted)
1144 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1145 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1146 }
1147 break;
1148
1149 case UM_RESCAN:
1150 if (dcd) {
1151 CNRINFO cnri;
1152 CHAR s[CCHMAXPATH + 69], tb[81], tf[81], *p;
1153 PCNRITEM pci = NULL;
1154
1155 memset(&cnri, 0, sizeof(CNRINFO));
1156 cnri.cb = sizeof(CNRINFO);
1157 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1158 MPFROMLONG(sizeof(CNRINFO)));
1159 dcd->totalfiles = cnri.cRecords;
1160 commafmt(tf, sizeof(tf), dcd->totalfiles);
1161 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
1162 sprintf(s, "%s / %s", tf, tb);
1163 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1164
1165 commafmt(tf, sizeof(tf), dcd->selectedfiles);
1166 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
1167 sprintf(s, "%s / %s", tf, tb);
1168 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1169
1170 if (hwndStatus &&
1171 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1172 if (hwndMain) {
1173 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1174 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1175 if (pci && (INT) pci != -1)
1176 PostMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1177 else
1178 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1179 }
1180 if (!dcd->amextracted) {
1181 if (!fMoreButtons) {
1182 sprintf(s, " %s%s%s%s",
1183 GetPString(IDS_COLLECTORTEXT),
1184 *dcd->mask.szMask || dcd->mask.antiattr ||
1185 dcd->mask.attrFile != ALLATTRS ? " (" : NullStr,
1186 *dcd->mask.szMask ?
1187 dcd->mask.szMask :
1188 dcd->mask.antiattr ||
1189 dcd->mask.attrFile != ALLATTRS ?
1190 GetPString(IDS_ATTRTEXT) : NullStr,
1191 *dcd->mask.szMask || dcd->mask.antiattr ||
1192 dcd->mask.attrFile != ALLATTRS ?
1193 ")" : NullStr);
1194 }
1195 else
1196 strcpy(s, GetPString(IDS_COLLECTORTEXT));
1197 WinSetWindowText(hwndStatus, s);
1198 }
1199 if (!pci)
1200 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1201 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1202 if (pci && (INT) pci != -1) {
1203 BOOL fStatus2Used = FALSE;
1204
1205 if (fSplitStatus && hwndStatus2) {
1206 if (pci->attrFile & FILE_DIRECTORY)
1207 p = pci->pszFileName;
1208 else {
1209 p = strrchr(pci->pszFileName, '\\');
1210 if (p) {
1211 if (*(p + 1))
1212 p++;
1213 else
1214 p = pci->pszFileName;
1215 }
1216 else
1217 p = pci->pszFileName;
1218 }
1219 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1220 if (!fMoreButtons) {
1221 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
1222 tb, pci->date.year, pci->date.month,
1223 pci->date.day, pci->time.hours, pci->time.minutes,
1224 pci->time.seconds, pci->pszDispAttr, p);
1225 }
1226 else {
1227 if (pci->cbFile + pci->easize > 1024)
1228 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1229 else
1230 *tf = 0;
1231 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
1232 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1233 }
1234 WinSetWindowText(hwndStatus2, s);
1235 fStatus2Used = TRUE;
1236 }
1237 if (fMoreButtons) {
1238 WinSetWindowText(hwndName, pci->pszFileName);
1239 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
1240 pci->date.year, pci->date.month,
1241 pci->date.day, pci->time.hours, pci->time.minutes,
1242 pci->time.seconds);
1243 WinSetWindowText(hwndDate, s);
1244 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1245 }
1246 if (dcd->amextracted && hwndStatus2 && !fStatus2Used)
1247 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1248 }
1249 else {
1250 if (hwndStatus2) {
1251 if (dcd->amextracted)
1252 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1253 else
1254 WinSetWindowText(hwndStatus2, NullStr);
1255 }
1256 if (fMoreButtons) {
1257 WinSetWindowText(hwndName, NullStr);
1258 WinSetWindowText(hwndDate, NullStr);
1259 WinSetWindowText(hwndAttr, NullStr);
1260 }
1261 }
1262 }
1263 }
1264 return 0;
1265
1266 case UM_CONTAINER_FILLED:
1267 DosBeep(1000, 50); // Wake up user?
1268 WinSendMsg(hwnd,
1269 CM_INVALIDATERECORD,
1270 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1271 disable_menuitem(WinWindowFromID(WinQueryWindow(hwndMain, QW_PARENT),
1272 FID_MENU), IDM_GREP, FALSE);
1273 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1274 if (dcd) {
1275 dcd->stopflag = 0;
1276 dcd->amextracted = FALSE; // Say not busy
1277 if (dcd->namecanchange) {
1278 if (!PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID))
1279 WinSendMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1280 }
1281 else
1282 WinSetWindowPos(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
1283 QW_PARENT),
1284 HWND_TOP,
1285 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ZORDER);
1286 }
1287 return 0;
1288
1289 case UM_SETUP:
1290 if (dcd) {
1291 if (!dcd->hwndObject) {
1292 /* first time through -- set things up */
1293
1294 CNRINFO cnri;
1295
1296 RestorePresParams(hwnd, "Collector");
1297 LoadDetailsSwitches("Collector", dcd);
1298
1299 dcd->amextracted = FALSE; // Say not busy
1300 dcd->stopflag = 0;
1301 memset(&cnri, 0, sizeof(CNRINFO));
1302 cnri.cb = sizeof(CNRINFO);
1303 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1304 MPFROMLONG(sizeof(CNRINFO)));
1305 cnri.cyLineSpacing = 0;
1306 cnri.cxTreeIndent = 12;
1307
1308 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_DETAIL));
1309 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES |
1310 CV_MINI | CV_FLOW);
1311 cnri.pSortRecord = (PVOID) SortCollectorCnr;
1312
1313 size = sizeof(ULONG);
1314 PrfQueryProfileData(fmprof, appname, "CollectorflWindowAttr",
1315 (PVOID) & cnri.flWindowAttr, &size);
1316 size = sizeof(MASK);
1317 if (PrfQueryProfileSize(fmprof, appname, "CollectorFilter", &size) &&
1318 size) {
1319 PrfQueryProfileData(fmprof, appname, "CollectorFilter", &dcd->mask,
1320 &size);
1321 SetMask(NULL, &dcd->mask);
1322 }
1323 else {
1324 dcd->mask.attrFile = (FILE_NORMAL | FILE_READONLY |
1325 FILE_DIRECTORY | FILE_HIDDEN |
1326 FILE_SYSTEM | FILE_ARCHIVED);
1327 dcd->mask.antiattr = 0;
1328 }
1329
1330 *(dcd->mask.prompt) = 0;
1331
1332 cnri.flWindowAttr |= CV_FLOW;
1333 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
1334 dcd->flWindowAttr = cnri.flWindowAttr;
1335 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1336 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1337 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1338 SetCnrCols(hwnd, FALSE);
1339 AdjustCnrColsForPref(hwnd, NULL, dcd, FALSE);
1340
1341 /* fix splitbar for collector container */
1342 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1343 size = sizeof(LONG);
1344 PrfQueryProfileData(fmprof, appname, "CollectorCnrSplitBar",
1345 &cnri.xVertSplitbar, &size);
1346 if (cnri.xVertSplitbar <= 0)
1347 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1348 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1349 MPFROMLONG(CMA_XVERTSPLITBAR));
1350
1351 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID)dcd) == -1) {
1352 Runtime_Error(pszSrcFile, __LINE__,
1353 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1354 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1355 return 0;
1356 }
1357 else
1358 DosSleep(32); // Let object window get started
1359 }
1360 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1361 DIR_FILTER), &dcd->mask, FALSE);
1362 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1363 DIR_SORT), CollectorsortFlags, FALSE);
1364 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1365 DIR_VIEW), dcd->flWindowAttr);
1366 }
1367 else {
1368 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1369 return 0;
1370 }
1371 return 0;
1372
1373 case WM_MENUEND:
1374 if (dcd) {
1375 HWND hwndMenu = (HWND) mp2;
1376
1377 if (hwndMenu == CollectorCnrMenu || hwndMenu == CollectorFileMenu ||
1378 hwndMenu == CollectorDirMenu) {
1379 MarkAll(hwnd, TRUE, FALSE, TRUE);
1380 if (dcd->cnremphasized) {
1381 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1382 MPFROM2SHORT(FALSE, CRA_SOURCE));
1383 dcd->cnremphasized = FALSE;
1384 }
1385 }
1386 }
1387 break;
1388
1389 case UM_OPENWINDOWFORME:
1390 if (dcd) {
1391 if (mp1 && !IsFile((CHAR *) mp1))
1392 OpenDirCnr(HWND_DESKTOP, hwndMain, dcd->hwndFrame, FALSE, (PSZ) mp1);
1393 else if (mp1 && IsFile(mp1) == 1)
1394 StartArcCnr(HWND_DESKTOP,
1395 dcd->hwndFrame, (CHAR *) mp1, 4, (ARC_TYPE *) mp2);
1396 }
1397 return 0;
1398
1399 case MM_PORTHOLEINIT:
1400 if (dcd) {
1401 switch (SHORT1FROMMP(mp1)) {
1402 case 0:
1403 case 1:
1404 {
1405 ULONG wmsg;
1406
1407 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1408 PortholeInit((HWND) WinSendMsg(dcd->hwndClient, wmsg, MPVOID,
1409 MPVOID), mp1, mp2);
1410 }
1411 break;
1412 }
1413 }
1414 break;
1415
1416 case UM_INITMENU:
1417 case WM_INITMENU:
1418 if (dcd) {
1419 switch (SHORT1FROMMP(mp1)) {
1420 case IDM_VIEWSMENU:
1421 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1422 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1423 (dcd->lastselection != NULL));
1424 CopyPresParams((HWND) mp2, hwnd);
1425 break;
1426
1427 case IDM_DETAILSSETUP:
1428 SetDetailsSwitches((HWND) mp2, dcd);
1429 break;
1430
1431 case IDM_COMMANDSMENU:
1432 SetupCommandMenu((HWND) mp2, hwnd);
1433 break;
1434
1435 case IDM_SORTSUBMENU:
1436 SetSortChecks((HWND) mp2, CollectorsortFlags);
1437 break;
1438 }
1439 dcd->hwndLastMenu = (HWND) mp2;
1440 }
1441 if (msg == WM_INITMENU)
1442 break;
1443 return 0;
1444
1445 case UM_COLLECTFROMFILE:
1446 if (mp1) {
1447 if (!dcd) {
1448 free(mp1);
1449 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1450 }
1451 else {
1452 if (!PostMsg(dcd->hwndObject, UM_COLLECTFROMFILE, mp1, mp2)) {
1453 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1454 free(mp1);
1455 }
1456 }
1457 }
1458 return 0;
1459
1460 case UM_COMMAND:
1461 if (mp1) {
1462 if (dcd) {
1463 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1464 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1465 FreeListInfo((LISTINFO *) mp1);
1466 }
1467 else
1468 return (MRESULT) TRUE;
1469 }
1470 else
1471 FreeListInfo((LISTINFO *) mp1);
1472 }
1473 return 0;
1474
1475 case UM_NOTIFY:
1476 if (mp2)
1477 AddNote((CHAR *) mp2);
1478 return 0;
1479
1480 case WM_COMMAND:
1481 DosError(FERR_DISABLEHARDERR);
1482 if (dcd) {
1483 switch (SHORT1FROMMP(mp1)) {
1484 case IDM_SETTARGET:
1485 SetTargetDir(hwnd, FALSE);
1486 break;
1487
1488 case IDM_CONTEXTMENU:
1489 {
1490 PCNRITEM pci;
1491
1492 pci = (PCNRITEM) CurrentRecord(hwnd);
1493 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(COLLECTOR_CNR,
1494 CN_CONTEXTMENU),
1495 MPFROMP(pci));
1496 }
1497 break;
1498
1499 case IDM_SHOWALLFILES:
1500 {
1501 PCNRITEM pci;
1502
1503 pci = WinSendMsg(hwnd,
1504 CM_QUERYRECORDEMPHASIS,
1505 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1506 if (pci && (INT) pci != -1) {
1507 static CHAR dirname[CCHMAXPATH];
1508
1509 strcpy(dirname, pci->pszFileName);
1510 MakeValidDir(dirname);
1511 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1512 }
1513 }
1514 break;
1515
1516 case IDM_BEGINEDIT:
1517 OpenEdit(hwnd);
1518 break;
1519
1520 case IDM_ENDEDIT:
1521 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1522 break;
1523
1524 case IDM_SHOWSELECT:
1525 QuickPopup(hwnd, dcd,
1526 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
1527 IDM_SELECTSUBMENU);
1528 break;
1529
1530 case IDM_SHOWSORT:
1531 QuickPopup(hwnd, dcd,
1532 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
1533 IDM_SORTSUBMENU);
1534 break;
1535
1536 case IDM_VIEWORARC:
1537 {
1538 SWP swp;
1539 PCNRITEM pci;
1540
1541 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1542 MPFROMLONG(CMA_FIRST),
1543 MPFROMSHORT(CRA_CURSORED));
1544 if (pci && (INT) pci != -1) {
1545 WinQueryWindowPos(dcd->hwndFrame, &swp);
1546 DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp,
1547 pci->pszFileName);
1548 }
1549 }
1550 break;
1551
1552 case IDM_SEEALL:
1553 StartSeeAll(HWND_DESKTOP, FALSE, NULL);
1554 break;
1555
1556 case IDM_COLLECTSELECT:
1557 {
1558 CHAR filename[CCHMAXPATH], *p, *pp;
1559
1560 strcpy(filename, "*.LST");
1561 size = CCHMAXPATH;
1562 PrfQueryProfileData(fmprof, appname, "SaveToListName",
1563 filename, &size);
1564 pp = strrchr(filename, '\\');
1565 if (!pp)
1566 pp = filename;
1567 p = strrchr(pp, '.');
1568 if (p && *(p + 1) && p > pp + 1) {
1569 if (pp > filename)
1570 pp++;
1571 *pp = '*';
1572 pp++;
1573 if (p > pp)
1574 memmove(pp, p, strlen(p) + 1);
1575 }
1576 if (insert_filename(hwnd, filename, FALSE, FALSE)) {
1577 p = xstrdup(filename, pszSrcFile, __LINE__);
1578 if (p) {
1579 if (!PostMsg(hwnd, UM_COLLECTFROMFILE, MPFROMP(p), MPVOID))
1580 free(p);
1581 }
1582 }
1583 }
1584 break;
1585
1586 case IDM_COLLECTORVIEWSETTINGS:
1587 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1588 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_COLLECTORVIEWSETTINGS), mp2);
1589 else {
1590 WinDlgBox(HWND_DESKTOP,
1591 hwnd,
1592 CfgDlgProc,
1593 FM3ModHandle,
1594 CFG_FRAME,
1595 MPFROMLONG(IDM_COLLECTORVIEWSETTINGS));
1596 }
1597 break;
1598
1599 case IDM_RESELECT:
1600 SelectList(hwnd, FALSE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1601 break;
1602
1603 case IDM_HELP:
1604 if (hwndHelp)
1605 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
1606 MPFROM2SHORT(HELP_COLLECT, 0),
1607 MPFROMSHORT(HM_RESOURCEID));
1608 break;
1609
1610 case IDM_SORTNONE:
1611 case IDM_SORTSMARTNAME:
1612 case IDM_SORTNAME:
1613 case IDM_SORTFILENAME:
1614 case IDM_SORTSIZE:
1615 case IDM_SORTEASIZE:
1616 case IDM_SORTFIRST:
1617 case IDM_SORTLAST:
1618 case IDM_SORTLWDATE:
1619 case IDM_SORTLADATE:
1620 case IDM_SORTCRDATE:
1621 case IDM_SORTSUBJECT:
1622 savedSortFlags = CollectorsortFlags;
1623 CollectorsortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1624 case IDM_SORTDIRSFIRST:
1625 case IDM_SORTDIRSLAST:
1626 case IDM_SORTREVERSE:
1627 switch (SHORT1FROMMP(mp1)) {
1628 case IDM_SORTSUBJECT:
1629 CollectorsortFlags |= SORT_SUBJECT;
1630 break;
1631 case IDM_SORTNONE:
1632 CollectorsortFlags |= SORT_NOSORT;
1633 break;
1634 case IDM_SORTSMARTNAME:
1635 if (~savedSortFlags & SORT_FILENAME)
1636 CollectorsortFlags |= SORT_FILENAME;
1637 break;
1638 case IDM_SORTFILENAME:
1639 CollectorsortFlags |= SORT_FILENAME;
1640 break;
1641 case IDM_SORTSIZE:
1642 CollectorsortFlags |= SORT_SIZE;
1643 break;
1644 case IDM_SORTEASIZE:
1645 CollectorsortFlags |= SORT_EASIZE;
1646 break;
1647 case IDM_SORTFIRST:
1648 CollectorsortFlags |= SORT_FIRSTEXTENSION;
1649 break;
1650 case IDM_SORTLAST:
1651 CollectorsortFlags |= SORT_LASTEXTENSION;
1652 break;
1653 case IDM_SORTLWDATE:
1654 CollectorsortFlags |= SORT_LWDATE;
1655 break;
1656 case IDM_SORTLADATE:
1657 CollectorsortFlags |= SORT_LADATE;
1658 break;
1659 case IDM_SORTCRDATE:
1660 CollectorsortFlags |= SORT_CRDATE;
1661 break;
1662 case IDM_SORTDIRSFIRST:
1663 if (CollectorsortFlags & SORT_DIRSFIRST)
1664 CollectorsortFlags &= (~SORT_DIRSFIRST);
1665 else {
1666 CollectorsortFlags |= SORT_DIRSFIRST;
1667 CollectorsortFlags &= (~SORT_DIRSLAST);
1668 }
1669 break;
1670 case IDM_SORTDIRSLAST:
1671 if (CollectorsortFlags & SORT_DIRSLAST)
1672 CollectorsortFlags &= (~SORT_DIRSLAST);
1673 else {
1674 CollectorsortFlags |= SORT_DIRSLAST;
1675 CollectorsortFlags &= (~SORT_DIRSFIRST);
1676 }
1677 break;
1678 case IDM_SORTREVERSE:
1679 if (CollectorsortFlags & SORT_REVERSE)
1680 CollectorsortFlags &= (~SORT_REVERSE);
1681 else
1682 CollectorsortFlags |= SORT_REVERSE;
1683 break;
1684 }
1685 PrfWriteProfileData(fmprof, appname, "CollectorSort",
1686 &CollectorsortFlags, sizeof(INT));
1687 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1688 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1689 DIR_SORT), CollectorsortFlags, FALSE);
1690 break;
1691
1692 case IDM_COLLECTFROMCLIP:
1693 {
1694 LISTINFO *li;
1695
1696 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1697 if (li) {
1698 li->list = ListFromClipboard(hwnd);
1699 if (!li->list || !li->list[0])
1700 FreeListInfo(li);
1701 else {
1702 li->type = IDM_COLLECT;
1703 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1704 FreeListInfo(li);
1705 }
1706 }
1707 }
1708 break;
1709
1710 case IDM_REMOVE:
1711 if (fAutoView && hwndMain)
1712 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1713 dcd->suspendview = 1;
1714 RemoveAll(hwnd, &dcd->ullTotalBytes, &dcd->totalfiles);
1715 dcd->suspendview = 0;
1716 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1717 break;
1718
1719 case IDM_CLEARCNR:
1720 {
1721 PCNRITEM pci;
1722
1723 pci = (PCNRITEM) WinSendMsg(hwnd,
1724 CM_QUERYRECORD,
1725 MPVOID,
1726 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
1727 if (pci && (INT) pci != -1) {
1728 RemoveCnrItems(hwnd, NULL, 0, CMA_FREE | CMA_INVALIDATE);
1729 dcd->ullTotalBytes = dcd->selectedbytes = dcd->selectedfiles =
1730 dcd->totalfiles = 0;
1731 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1732 }
1733 }
1734 break;
1735
1736 case DID_CANCEL:
1737 if (dcd->amextracted)
1738 dcd->stopflag = 1; // Request cancel
1739 break;
1740
1741 case IDM_COLLECTOR:
1742 if (mp2) {
1743 LISTINFO *li;
1744
1745 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1746 if (li) {
1747 li->list = mp2;
1748 if (!li->list || !li->list[0])
1749 FreeListInfo(li);
1750 else {
1751 li->type = IDM_COLLECT;
1752 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1753 FreeListInfo(li);
1754 }
1755 }
1756 else
1757 FreeList(mp2);
1758 }
1759 break;
1760
1761 case IDM_UNDELETE:
1762 {
1763 PCNRITEM pci;
1764 CHAR path[CCHMAXPATH];
1765
1766 pci = (PCNRITEM) CurrentRecord(hwnd);
1767 if (pci) {
1768 strcpy(path, pci->pszFileName);
1769 MakeValidDir(path);
1770 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
1771 UNDEL_FRAME, MPFROMP(path));
1772 }
1773 }
1774 break;
1775
1776 case IDM_GREP:
1777 if (dcd->amextracted) {
1778 saymsg(MB_OK | MB_ICONASTERISK,
1779 hwnd,
1780 GetPString(IDS_WARNINGTEXT),
1781 "Collector busy - please try again later");
1782 }
1783 else {
1784 if (WinDlgBox(HWND_DESKTOP, hwnd, GrepDlgProc,
1785 FM3ModHandle, GREP_FRAME, (PVOID) & hwnd)) {
1786 dcd->amextracted = TRUE; // Say busy scanning
1787 disable_menuitem(WinWindowFromID
1788 (WinQueryWindow(hwndMain, QW_PARENT), FID_MENU),
1789 IDM_GREP, TRUE);
1790 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1791 }
1792 }
1793 break;
1794
1795 case IDM_RESORT:
1796 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1797 break;
1798
1799 case IDM_FILTER:
1800 {
1801 BOOL empty = FALSE;
1802 PCNRITEM pci;
1803 CHAR *p;
1804
1805 if (!*dcd->mask.szMask) {
1806 empty = TRUE;
1807 pci = (PCNRITEM) CurrentRecord(hwnd);
1808 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
1809 p = strrchr(pci->pszFileName, '\\');
1810 if (p) {
1811 p++;
1812 strcpy(dcd->mask.szMask, p);
1813 }
1814 }
1815 }
1816 *(dcd->mask.prompt) = 0;
1817
1818 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
1819 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
1820 size = sizeof(MASK);
1821 PrfWriteProfileData(fmprof, appname, "CollectorFilter",
1822 &dcd->mask, size);
1823 dcd->suspendview = 1;
1824 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1825 dcd->suspendview = 0;
1826 if (fAutoView && hwndMain) {
1827 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1828 MPFROMLONG(CMA_FIRST),
1829 MPFROMSHORT(CRA_CURSORED));
1830 if (pci && (INT) pci != -1 &&
1831 (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
1832 DRIVE_SLOW)))
1833 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName),
1834 MPVOID);
1835 else
1836 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1837 }
1838 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1839 }
1840 else if (empty)
1841 *dcd->mask.szMask = 0;
1842 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1843 DIR_FILTER), &dcd->mask, FALSE);
1844 }
1845 break;
1846
1847 case IDM_UNHIDEALL:
1848 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1849 break;
1850
1851 case IDM_HIDEALL:
1852 if (fAutoView && hwndMain)
1853 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1854 dcd->suspendview = 1;
1855 HideAll(hwnd);
1856 dcd->suspendview = 0;
1857 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1858 break;
1859
1860 case IDM_SELECTLIST:
1861 case IDM_SELECTALL:
1862 case IDM_DESELECTALL:
1863 case IDM_SELECTALLFILES:
1864 case IDM_DESELECTALLFILES:
1865 case IDM_SELECTALLDIRS:
1866 case IDM_DESELECTALLDIRS:
1867 case IDM_SELECTMASK:
1868 case IDM_DESELECTMASK:
1869 case IDM_INVERT:
1870 case IDM_SELECTCLIP:
1871 case IDM_DESELECTCLIP:
1872 {
1873 PCNRITEM pci;
1874
1875 pci = (PCNRITEM) CurrentRecord(hwnd);
1876 if ((INT) pci == -1)
1877 pci = NULL;
1878 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
1879 if (pci) {
1880 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
1881 pci->rc.flRecordAttr |= CRA_FILTERED;
1882 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
1883 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
1884 break;
1885 }
1886 }
1887 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
1888 }
1889 break;
1890
1891 case IDM_RESCAN:
1892 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
1893 break;
1894
1895 case IDM_SHOWLNAMES:
1896 case IDM_SHOWSUBJECT:
1897 case IDM_SHOWEAS:
1898 case IDM_SHOWSIZE:
1899 case IDM_SHOWICON:
1900 case IDM_SHOWLWDATE:
1901 case IDM_SHOWLWTIME:
1902 case IDM_SHOWLADATE:
1903 case IDM_SHOWLATIME:
1904 case IDM_SHOWCRDATE:
1905 case IDM_SHOWCRTIME:
1906 case IDM_SHOWATTR:
1907 AdjustDetailsSwitches(hwnd, dcd->hwndLastMenu,
1908 SHORT1FROMMP(mp1), NULL,
1909 "Collector", dcd, FALSE);
1910 break;
1911
1912 case IDM_ICON:
1913 case IDM_TEXT:
1914 case IDM_DETAILS:
1915 case IDM_NAME:
1916 case IDM_MINIICONS:
1917 case IDM_DETAILSTITLES:
1918 {
1919 CNRINFO cnri;
1920
1921 memset(&cnri, 0, sizeof(CNRINFO));
1922 cnri.cb = sizeof(CNRINFO);
1923 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1924 MPFROMLONG(sizeof(CNRINFO)));
1925 switch (SHORT1FROMMP(mp1)) {
1926 case IDM_ICON:
1927 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1928 CV_DETAIL | CV_NAME));
1929 cnri.flWindowAttr |= CV_ICON;
1930 break;
1931 case IDM_NAME:
1932 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1933 CV_DETAIL | CV_NAME));
1934 cnri.flWindowAttr |= CV_NAME;
1935 break;
1936 case IDM_TEXT:
1937 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1938 CV_DETAIL | CV_NAME));
1939 cnri.flWindowAttr |= CV_TEXT;
1940 break;
1941 case IDM_DETAILS:
1942 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1943 CV_DETAIL | CV_NAME));
1944 cnri.flWindowAttr |= CV_DETAIL;
1945 break;
1946 case IDM_MINIICONS:
1947 if (cnri.flWindowAttr & CV_MINI)
1948 cnri.flWindowAttr &= (~CV_MINI);
1949 else
1950 cnri.flWindowAttr |= CV_MINI;
1951 break;
1952 case IDM_DETAILSTITLES:
1953 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
1954 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
1955 else
1956 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
1957 break;
1958 }
1959 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
1960 cnri.flWindowAttr |= CV_FLOW;
1961 dcd->flWindowAttr = cnri.flWindowAttr;
1962 PrfWriteProfileData(fmprof, appname, "CollectorflWindowAttr",
1963 &cnri.flWindowAttr, sizeof(ULONG));
1964 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1965 MPFROMLONG(CMA_FLWINDOWATTR));
1966 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
1967 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1968 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1969 DIR_VIEW), dcd->flWindowAttr);
1970 }
1971 break;
1972
1973 case IDM_SAVETOLIST:
1974 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
1975 SAV_FRAME, MPFROMP(&hwnd));
1976 break;
1977
1978 case IDM_SIZES:
1979 {
1980 PCNRITEM pci;
1981
1982 pci = (PCNRITEM) CurrentRecord(hwnd);
1983 if (pci && (INT) pci != -1)
1984 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DirSizeProc, FM3ModHandle,
1985 DSZ_FRAME, pci->pszFileName);
1986 }
1987 break;
1988
1989 case IDM_MKDIR:
1990 {
1991 PCNRITEM pci;
1992
1993 pci = (PCNRITEM) CurrentRecord(hwnd);
1994 PMMkDir(dcd->hwndParent, (pci && (INT) pci != -1) ?
1995 pci->pszFileName : NULL, FALSE);
1996 }
1997 break;
1998
1999 case IDM_DOITYOURSELF:
2000 case IDM_UPDATE:
2001 case IDM_COLLECTFROMFILE:
2002 case IDM_OPENWINDOW:
2003 case IDM_OPENSETTINGS:
2004 case IDM_OPENDEFAULT:
2005 case IDM_OPENICON:
2006 case IDM_OPENDETAILS:
2007 case IDM_OPENTREE:
2008 case IDM_OBJECT:
2009 case IDM_SHADOW:
2010 case IDM_SHADOW2:
2011 case IDM_DELETE:
2012 case IDM_PERMDELETE:
2013 case IDM_PRINT:
2014 case IDM_ATTRS:
2015 case IDM_INFO:
2016 case IDM_COPY:
2017 case IDM_MOVE:
2018 case IDM_WPSCOPY:
2019 case IDM_WPSMOVE:
2020 case IDM_COPYPRESERVE:
2021 case IDM_MOVEPRESERVE:
2022 case IDM_WILDCOPY:
2023 case IDM_WILDMOVE:
2024 case IDM_RENAME:
2025 case IDM_COMPARE:
2026 case IDM_EAS:
2027 case IDM_SUBJECT:
2028 case IDM_VIEW:
2029 case IDM_VIEWTEXT:
2030 case IDM_VIEWBINARY:
2031 case IDM_VIEWARCHIVE:
2032 case IDM_EDIT:
2033 case IDM_EDITTEXT:
2034 case IDM_EDITBINARY:
2035 case IDM_SAVETOCLIP:
2036 case IDM_APPENDTOCLIP:
2037 case IDM_ARCHIVE:
2038 case IDM_ARCHIVEM:
2039 case IDM_EXTRACT:
2040 case IDM_MCIPLAY:
2041 case IDM_UUDECODE:
2042 case IDM_MERGE:
2043 {
2044 LISTINFO *li;
2045 ULONG action = UM_ACTION;
2046
2047 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2048 if (li) {
2049 li->type = SHORT1FROMMP(mp1);
2050 li->hwnd = hwnd;
2051 li->list = BuildList(hwnd);
2052 if (li->list) {
2053 switch (SHORT1FROMMP(mp1)) {
2054 case IDM_DOITYOURSELF:
2055 case IDM_APPENDTOCLIP:
2056 case IDM_SAVETOCLIP:
2057 case IDM_ARCHIVE:
2058 case IDM_ARCHIVEM:
2059 case IDM_DELETE:
2060 case IDM_PERMDELETE:
2061 case IDM_ATTRS:
2062 case IDM_PRINT:
2063 case IDM_SHADOW:
2064 case IDM_SHADOW2:
2065 case IDM_OBJECT:
2066 case IDM_VIEW:
2067 case IDM_VIEWTEXT:
2068 case IDM_VIEWBINARY:
2069 case IDM_EDIT:
2070 case IDM_EDITTEXT:
2071 case IDM_EDITBINARY:
2072 case IDM_MCIPLAY:
2073 case IDM_UPDATE:
2074 case IDM_INFO:
2075 case IDM_EAS:
2076 action = UM_MASSACTION;
2077 break;
2078 }
2079 if (li->type == IDM_SHADOW || li->type == IDM_OBJECT ||
2080 li->type == IDM_SHADOW2)
2081 *li->targetpath = 0;
2082 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2083 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2084 FreeListInfo(li);
2085 }
2086 else if (fUnHilite)
2087 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2088 }
2089 else
2090 free(li);
2091 }
2092 }
2093 break;
2094
2095 default:
2096 if (!cmdloaded)
2097 load_commands();
2098 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2099 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2100 INT x;
2101
2102 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2103 if (x >= 0) {
2104 x++;
2105 RunCommand(hwnd, x);
2106 if (fUnHilite)
2107 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2108 }
2109 }
2110 break;
2111 }
2112 }
2113 return 0;
2114
2115 case UM_FIXCNRMLE:
2116 case UM_FIXEDITNAME:
2117 return CommonCnrProc(hwnd, msg, mp1, mp2);
2118
2119 case UM_FILESMENU:
2120 {
2121 PCNRITEM pci;
2122 HWND menuHwnd = (HWND) 0;
2123
2124 pci = (PCNRITEM) CurrentRecord(hwnd);
2125 if (pci && (INT) pci != -1) {
2126 if (pci->attrFile & FILE_DIRECTORY)
2127 menuHwnd = CheckMenu(hwnd, &CollectorDirMenu, COLLECTORDIR_POPUP);
2128 else
2129 menuHwnd = CheckMenu(hwnd, &CollectorFileMenu, COLLECTORFILE_POPUP);
2130 }
2131 return MRFROMLONG(menuHwnd);
2132 }
2133
2134 case WM_CONTROL:
2135 DosError(FERR_DISABLEHARDERR);
2136 if (dcd) {
2137 switch (SHORT2FROMMP(mp1)) {
2138 case CN_CONTEXTMENU:
2139 {
2140 PCNRITEM pci = (PCNRITEM) mp2;
2141
2142 if (pci) {
2143 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
2144 MPFROM2SHORT(TRUE, CRA_CURSORED));
2145 MarkAll(hwnd, FALSE, FALSE, TRUE);
2146 if (pci->attrFile & FILE_DIRECTORY)
2147 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorDirMenu,
2148 COLLECTORDIR_POPUP);
2149 else
2150 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorFileMenu,
2151 COLLECTORFILE_POPUP);
2152 }
2153 else {
2154 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorCnrMenu,
2155 COLLECTORCNR_POPUP);
2156 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2157 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2158 MPFROM2SHORT(TRUE, CRA_SOURCE));
2159 dcd->cnremphasized = TRUE;
2160 }
2161 }
2162 if (dcd->hwndLastMenu) {
2163 if (dcd->hwndLastMenu == CollectorCnrMenu) {
2164 SetViewMenu(dcd->hwndLastMenu, dcd->flWindowAttr);
2165 SetDetailsSwitches(dcd->hwndLastMenu, dcd);
2166 CopyPresParams(dcd->hwndLastMenu, hwnd);
2167 if (dcd->flWindowAttr & CV_MINI)
2168 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2169 disable_menuitem(dcd->hwndLastMenu, DID_CANCEL,
2170 !dcd->amextracted);
2171 disable_menuitem(dcd->hwndLastMenu, IDM_GREP, dcd->amextracted);
2172 }
2173 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2174 if (dcd->cnremphasized) {
2175 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2176 MPFROM2SHORT(FALSE, CRA_SOURCE));
2177 dcd->cnremphasized = TRUE;
2178 }
2179 MarkAll(hwnd, TRUE, FALSE, TRUE);
2180 }
2181 }
2182 }
2183 break;
2184
2185 case CN_DROPHELP:
2186 if (mp2) {
2187 PDRAGINFO pDInfo;
2188 PCNRITEM pci;
2189 ULONG numitems;
2190 USHORT usOperation;
2191
2192 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2193 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2194 if (!DrgAccessDraginfo(pDInfo)) {
2195 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2196 "DrgAccessDraginfo");
2197 return 0;
2198 }
2199 numitems = DrgQueryDragitemCount(pDInfo);
2200 usOperation = pDInfo->usOperation;
2201 FreeDragInfoData(hwnd, pDInfo);
2202 saymsg(MB_ENTER | MB_ICONASTERISK,
2203 hwnd,
2204 GetPString(IDS_DROPHELPHDRTEXT),
2205 GetPString(IDS_DROPHELPTEXT),
2206 numitems,
2207 &"s"[numitems == 1],
2208 (pci) ? NullStr : GetPString(IDS_NOTEXT),
2209 (pci) ? NullStr : " ",
2210 (pci) ? pci->pszFileName : NullStr,
2211 (pci) ? " " : NullStr,
2212 GetPString((usOperation == DO_COPY) ?
2213 IDS_COPYTEXT :
2214 (usOperation == DO_LINK) ?
2215 IDS_LINKTEXT : IDS_MOVETEXT));
2216 }
2217 return 0;
2218
2219 case CN_DRAGLEAVE:
2220 if (mp2) {
2221 PDRAGINFO pDInfo;
2222
2223 // fixme to know why needed
2224 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2225 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
2226 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2227 }
2228 return 0;
2229
2230 case CN_DRAGAFTER:
2231 case CN_DRAGOVER:
2232 if (mp2) {
2233 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2234 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2235 PCNRITEM pci;
2236 USHORT uso;
2237
2238 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2239 // if(SHORT1FROMMP(mp1) == CN_DRAGAFTER)
2240 // pci = NULL;
2241 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2242 if (!DrgAccessDraginfo(pDInfo)) {
2243 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2244 "DrgAccessDraginfo");
2245 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2246 }
2247 if (pci) {
2248 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2249 DrgFreeDraginfo(pDInfo);
2250 return (MRFROM2SHORT(DOR_NODROP, 0));
2251 }
2252 uso = pDInfo->usOperation;
2253 if (uso == DO_DEFAULT)
2254 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
2255 if (!(pci->attrFile & FILE_DIRECTORY)) {
2256 if (uso != DO_LINK && uso != DO_MOVE && uso != DO_COPY) {
2257 DrgFreeDraginfo(pDInfo);
2258 return MRFROM2SHORT(DOR_NODROP, 0);
2259 }
2260 if (uso != DO_LINK &&
2261 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2262 DRIVE_NOTWRITEABLE)) {
2263 ARC_TYPE *info = NULL;
2264
2265 if (!fQuickArcFind &&
2266 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2267 DRIVE_SLOW))
2268 info = find_type(pci->pszFileName, NULL);
2269 else
2270 info = quick_find_type(pci->pszFileName, NULL);
2271 if (!info || ((uso == DO_MOVE && !info->move) ||
2272 (uso == DO_COPY && !info->create))) {
2273 DrgFreeDraginfo(pDInfo);
2274 return MRFROM2SHORT(DOR_NODROP, 0);
2275 }
2276 }
2277 }
2278 }
2279 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
2280 0); /* Index to DRAGITEM */
2281 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
2282 DRM_OS2FILE, /* mechanisms and data */
2283 NULL)) {
2284 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2285 if (pci) {
2286 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
2287 DRIVE_NOTWRITEABLE)
2288 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2289 if (toupper(*pci->pszFileName) < 'C')
2290 return MRFROM2SHORT(DOR_DROP, DO_COPY);
2291 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2292 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2293 }
2294 else
2295 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2296 DO_COPY);
2297 }
2298 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2299 }
2300 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2301
2302 case CN_INITDRAG:
2303 if (mp2) {
2304 BOOL wasemphasized = FALSE;
2305 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2306 PCNRITEM pci;
2307
2308 if (pcd) {
2309 pci = (PCNRITEM) pcd->pRecord;
2310 if (pci) {
2311 if (pci->rc.flRecordAttr & CRA_SELECTED)
2312 wasemphasized = TRUE;
2313 if (IsRoot(pci->pszFileName))
2314 break;
2315 if (hwndStatus2)
2316 WinSetWindowText(hwndStatus2,
2317 GetPString(IDS_DRAGFILEOBJTEXT));
2318 if (DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE)) {
2319 if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
2320 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2321 }
2322 if (hwndStatus2)
2323 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2324 }
2325 }
2326 }
2327 return 0;
2328
2329 case CN_DROP:
2330 if (mp2) {
2331 LISTINFO *li;
2332 ULONG action = UM_ACTION;
2333
2334 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
2335 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
2336 if (li) {
2337 if (!*li->targetpath) {
2338 li->type = IDM_COLLECT;
2339 action = UM_COLLECT;
2340 }
2341 else {
2342 if (li->list && li->list[0] && IsRoot(li->list[0]))
2343 li->type = DO_LINK;
2344 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2345 CHECKLIST cl;
2346
2347 memset(&cl, 0, sizeof(cl));
2348 cl.size = sizeof(cl);
2349 cl.flags = li->type;
2350 cl.list = li->list;
2351 cl.cmd = li->type;
2352 cl.prompt = li->targetpath;
2353 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2354 DropListProc, FM3ModHandle,
2355 DND_FRAME, MPFROMP(&cl));
2356 if (li->type == DID_ERROR)
2357 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2358 "Drag & Drop Dialog");
2359 if (!li->type) {
2360 FreeListInfo(li);
2361 return 0;
2362 }
2363 li->list = cl.list;
2364 if (!li->list || !li->list[0]) {
2365 FreeListInfo(li);
2366 return 0;
2367 }
2368 }
2369 switch (li->type) {
2370 case DND_LAUNCH:
2371 strcat(li->targetpath, " %a");
2372 ExecOnList(dcd->hwndParent, li->targetpath,
2373 PROMPT | WINDOWED, NULL, li->list, NULL,
2374 pszSrcFile, __LINE__);
2375 FreeList(li->list);
2376 li->list = NULL;
2377 break;
2378 case DO_LINK:
2379 if (fLinkSetsIcon) {
2380 li->type = IDM_SETICON;
2381 action = UM_MASSACTION;
2382 }
2383 else
2384 li->type = IDM_COMPARE;
2385 break;
2386 case DND_EXTRACT:
2387 if (*li->targetpath && !IsFile(li->targetpath))
2388 li->type = IDM_EXTRACT;
2389 break;
2390 case DND_MOVE:
2391 li->type = IDM_MOVE;
2392 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2393 action = UM_MASSACTION;
2394 li->type = IDM_ARCHIVEM;
2395 }
2396 break;
2397 case DND_WILDMOVE:
2398 li->type = IDM_WILDMOVE;
2399 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2400 action = UM_MASSACTION;
2401 li->type = IDM_ARCHIVEM;
2402 }
2403 break;
2404 case DND_OBJECT:
2405 li->type = IDM_OBJECT;
2406 action = UM_MASSACTION;
2407 break;
2408 case DND_SHADOW:
2409 li->type = IDM_SHADOW;
2410 action = UM_MASSACTION;
2411 break;
2412 case DND_COMPARE:
2413 li->type = IDM_COMPARE;
2414 break;
2415 case DND_SETICON:
2416 action = UM_MASSACTION;
2417 li->type = IDM_SETICON;
2418 break;
2419 case DND_WILDCOPY:
2420 li->type = IDM_WILDCOPY;
2421 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2422 action = UM_MASSACTION;
2423 li->type = IDM_ARCHIVE;
2424 }
2425 break;
2426 case DND_COPY:
2427 li->type = IDM_COPY;
2428 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2429 action = UM_MASSACTION;
2430 li->type = IDM_ARCHIVE;
2431 }
2432 break;
2433 default:
2434 if (*li->arcname && li->info) {
2435 action = UM_MASSACTION;
2436 li->type =
2437 (li->type ==
2438 DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
2439 }
2440 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2441 action = UM_MASSACTION;
2442 li->type =
2443 (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2444 }
2445 else
2446 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2447 break;
2448 }
2449 }
2450 if (!li->list || !li->list[0])
2451 FreeListInfo(li);
2452 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
2453 FreeListInfo(li);
2454 else {
2455 USHORT usop = 0;
2456
2457 switch (li->type) {
2458 case IDM_COPY:
2459 case IDM_WILDCOPY:
2460 usop = DO_COPY;
2461 break;
2462 case IDM_MOVE:
2463 case IDM_WILDMOVE:
2464 case IDM_ARCHIVEM:
2465 usop = DO_MOVE;
2466 break;
2467 }
2468 if (usop)
2469 return MRFROM2SHORT(DOR_DROP, usop);
2470 }
2471 }
2472 }
2473 return 0;
2474
2475 case CN_BEGINEDIT:
2476 case CN_REALLOCPSZ:
2477 case CN_ENDEDIT:
2478 {
2479 MRESULT mre;
2480
2481 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
2482 if (mre != (MRESULT) - 1)
2483 return mre;
2484 }
2485 break;
2486
2487 case CN_EMPHASIS:
2488 if (mp2) {
2489 PNOTIFYRECORDEMPHASIS pre = mp2;
2490 PCNRITEM pci;
2491 CHAR s[CCHMAXPATH + 91], tb[81], tf[81], *p;
2492
2493 pci = (PCNRITEM) ((pre) ? pre->pRecord : NULL);
2494 if (!pci) {
2495 if (hwndStatus2)
2496 WinSetWindowText(hwndStatus2, NullStr);
2497 if (fMoreButtons) {
2498 WinSetWindowText(hwndName, NullStr);
2499 WinSetWindowText(hwndDate, NullStr);
2500 WinSetWindowText(hwndAttr, NullStr);
2501 }
2502 if (hwndMain)
2503 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2504 break;
2505 }
2506 if (pre->fEmphasisMask & CRA_SELECTED) {
2507 if (pci->rc.flRecordAttr & CRA_SELECTED) {
2508 dcd->selectedbytes += (pci->cbFile + pci->easize);
2509 dcd->selectedfiles++;
2510 }
2511 else if (dcd->selectedfiles) {
2512 dcd->selectedbytes -= (pci->cbFile + pci->easize);
2513 dcd->selectedfiles--;
2514 }
2515 if (!dcd->suspendview) {
2516 commafmt(tf, sizeof(tf), dcd->selectedfiles);
2517 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
2518 sprintf(s, "%s / %s", tf, tb);
2519 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
2520 }
2521 }
2522 if (!dcd->suspendview &&
2523 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
2524 if (pre->fEmphasisMask & CRA_CURSORED) {
2525 if (pci->rc.flRecordAttr & CRA_CURSORED) {
2526 if (fSplitStatus && hwndStatus2) {
2527 if (pci->attrFile & FILE_DIRECTORY)
2528 p = pci->pszFileName;
2529 else {
2530 p = strrchr(pci->pszFileName, '\\');
2531 if (p) {
2532 if (*(p + 1))
2533 p++;
2534 else
2535 p = pci->pszFileName;
2536 }
2537 else
2538 p = pci->pszFileName;
2539 }
2540 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
2541 if (!fMoreButtons)
2542 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
2543 tb, pci->date.year,
2544 pci->date.month, pci->date.day, pci->time.hours,
2545 pci->time.minutes, pci->time.seconds,
2546 pci->pszDispAttr, p);
2547 else {
2548 if (pci->cbFile + pci->easize > 1024)
2549 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize,
2550 ' ');
2551 else
2552 *tf = 0;
2553 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
2554 tb,
2555 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
2556 }
2557 WinSetWindowText(hwndStatus2, s);
2558 }
2559 if (fMoreButtons) {
2560 WinSetWindowText(hwndName, pci->pszFileName);
2561 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
2562 pci->date.year, pci->date.month,
2563 pci->date.day, pci->time.hours, pci->time.minutes,
2564 pci->time.seconds);
2565 WinSetWindowText(hwndDate, s);
2566 WinSetWindowText(hwndAttr, pci->pszDispAttr);
2567 }
2568 }
2569 }
2570 }
2571 if (!dcd->suspendview && hwndMain &&
2572 (pre->fEmphasisMask & CRA_CURSORED) &&
2573 (pci->rc.flRecordAttr & CRA_CURSORED) &&
2574 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame)
2575 WinSendMsg(hwndMain, UM_LOADFILE,
2576 MPFROMP(((fComments
2577 || (pci->attrFile & FILE_DIRECTORY) ==
2578 0) ? pci->pszFileName : NULL)), MPVOID);
2579 }
2580 break;
2581
2582 case CN_ENTER:
2583 if (mp2) {
2584 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
2585 FILEFINDBUF3 ffb;
2586 HDIR hDir = HDIR_CREATE;
2587 ULONG nm = 1;
2588 APIRET status = 0;
2589
2590 SetShiftState();
2591 if (pci) {
2592 if (pci->rc.flRecordAttr & CRA_INUSE)
2593 break;
2594 DosError(FERR_DISABLEHARDERR);
2595 status = DosFindFirst(pci->pszFileName, &hDir,
2596 FILE_NORMAL | FILE_DIRECTORY |
2597 FILE_ARCHIVED | FILE_READONLY |
2598 FILE_HIDDEN | FILE_SYSTEM,
2599 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
2600 priority_bumped();
2601 if (!status) {
2602 DosFindClose(hDir);
2603 if (ffb.attrFile & FILE_DIRECTORY) {
2604 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
2605 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0),
2606 MPVOID);
2607 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
2608 (KC_CTRL | KC_SHIFT))
2609 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
2610 else if (shiftstate & KC_CTRL)
2611 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
2612 else
2613 OpenDirCnr(HWND_DESKTOP,
2614 hwndMain,
2615 dcd->hwndFrame, FALSE, pci->pszFileName);
2616 }
2617 else {
2618 SWP swp;
2619
2620 WinSendMsg(hwnd,
2621 CM_SETRECORDEMPHASIS,
2622 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
2623 WinQueryWindowPos(dcd->hwndFrame, &swp);
2624 DefaultViewKeys(hwnd,
2625 dcd->hwndFrame,
2626 dcd->hwndParent, &swp, pci->pszFileName);
2627 WinSendMsg(hwnd,
2628 CM_SETRECORDEMPHASIS,
2629 MPFROMP(pci),
2630 MPFROM2SHORT(FALSE, CRA_INUSE |
2631 ((fUnHilite) ? CRA_SELECTED : 0)));
2632 }
2633 }
2634 else
2635 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
2636 }
2637 }
2638 break;
2639 }
2640 }
2641 return 0;
2642
2643 case UM_LOADFILE:
2644 if (dcd && mp2) {
2645 HWND ret;
2646
2647 ret = StartMLEEditor(dcd->hwndParent,
2648 (INT) mp1, (CHAR *) mp2, dcd->hwndFrame);
2649 xfree((CHAR *) mp2);
2650 return MRFROMLONG(ret);
2651 }
2652 return 0;
2653
2654 case UM_CLOSE:
2655 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
2656 QW_PARENT));
2657 return 0;
2658
2659 case UM_FOLDUP:
2660 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
2661 DosExit(EXIT_PROCESS, 1);
2662 return 0;
2663
2664 case WM_CLOSE:
2665 if (dcd) {
2666 dcd->namecanchange = TRUE;
2667 dcd->stopflag = 1;
2668 if (dcd->amextracted)
2669 return 0; // Can not close yet
2670 }
2671 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
2672 if (dcd) {
2673 if (!dcd->dontclose && ParentIsDesktop(hwnd, dcd->hwndParent))
2674 PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
2675 if (dcd->hwndObject) {
2676 DosSleep(32); // Allow UM_FOLDUP to process
2677 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
2678 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
2679 }
2680 }
2681 else
2682 WinSendMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
2683 return 0;
2684
2685 case WM_DESTROY:
2686 if (CollectorDirMenu)
2687 WinDestroyWindow(CollectorDirMenu);
2688 if (CollectorFileMenu)
2689 WinDestroyWindow(CollectorFileMenu);
2690 if (CollectorCnrMenu)
2691 WinDestroyWindow(CollectorCnrMenu);
2692 CollectorCnrMenu = CollectorFileMenu = CollectorDirMenu = (HWND) 0;
2693 Collector = (HWND) 0;
2694 EmptyCnr(hwnd);
2695 break;
2696 }
2697 if (dcd && dcd->oldproc){
2698 return dcd->oldproc(hwnd, msg, mp1, mp2);
2699 }
2700 else
2701 return PFNWPCnr(hwnd, msg, mp1, mp2);
2702}
2703
2704MRESULT EXPENTRY CollectorMenuProc(HWND hwnd, ULONG msg, MPARAM mp1,
2705 MPARAM mp2)
2706{
2707 PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
2708 static short sLastMenuitem;
2709
2710 switch (msg) {
2711 case WM_MOUSEMOVE: {
2712 if (fOtherHelp) {
2713 RECTL rectl;
2714 SHORT i, sCurrentMenuitem;
2715 SHORT MenuItems = 5;
2716 SHORT asMenuIDs[5] = {IDM_GREP,
2717 IDM_SEEALL,
2718 IDM_CLEARCNR,
2719 IDM_REMOVE,
2720 0};
2721 char *szHelpString = NULL;
2722
2723
2724 for (i=0; i<MenuItems; i++) {
2725 sCurrentMenuitem = asMenuIDs[i];
2726 oldMenuProc(hwnd,MM_QUERYITEMRECT,
2727 MPFROM2SHORT(asMenuIDs[i], FALSE),
2728 &rectl);
2729
2730 if (MOUSEMSG(&msg)->x > rectl.xLeft &&
2731 MOUSEMSG(&msg)->x < rectl.xRight &&
2732 MOUSEMSG(&msg)->y > rectl.yBottom &&
2733 MOUSEMSG(&msg)->y < rectl.yTop)
2734 break;
2735 } // for
2736
2737
2738 switch (sCurrentMenuitem) {
2739 case 0:
2740 break;
2741 case IDM_GREP:
2742 szHelpString = GetPString(IDS_COLMENUSEEKSCANHELP);
2743 break;
2744 case IDM_SEEALL:
2745 szHelpString = GetPString(IDS_COLMENUSEEALLHELP);
2746 break;
2747 case IDM_CLEARCNR:
2748 szHelpString = GetPString(IDS_COLMENUCLEARCNRHELP);
2749 break;
2750 case IDM_REMOVE:
2751 szHelpString = GetPString(IDS_COLMENUREMOVECNRHELP);
2752 break;
2753 default:
2754 break;
2755 }
2756
2757 if (sLastMenuitem != sCurrentMenuitem && szHelpString) {
2758 sLastMenuitem = sCurrentMenuitem;
2759 MakeBubble(hwnd, TRUE, szHelpString);
2760 }
2761 else if (hwndBubble && !sCurrentMenuitem){
2762 sLastMenuitem = sCurrentMenuitem;
2763 WinDestroyWindow(hwndBubble);
2764 }
2765 }
2766 }
2767 }
2768 return oldMenuProc(hwnd, msg, mp1, mp2);
2769}
2770
2771HWND StartCollector(HWND hwndParent, INT flags)
2772{
2773 HWND hwndFrame = (HWND) 0;
2774 HWND hwndClient;
2775 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
2776 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
2777 USHORT id;
2778 DIRCNRDATA *dcd;
2779
2780 static USHORT idinc = 0;
2781
2782 if (ParentIsDesktop(hwndParent, hwndParent))
2783 FrameFlags |= (FCF_TASKLIST | FCF_SHELLPOSITION | FCF_MENU);
2784 if (Collector) {
2785 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
2786 QW_PARENT),
2787 QW_PARENT),
2788 HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE);
2789 return WinQueryWindow(WinQueryWindow(Collector, QW_PARENT), QW_PARENT);
2790 }
2791 hwndFrame = WinCreateStdWindow(hwndParent,
2792 WS_VISIBLE,
2793 &FrameFlags,
2794 WC_COLLECTOR,
2795 NULL,
2796 WS_VISIBLE | fwsAnimate,
2797 FM3ModHandle, COLLECTOR_FRAME, &hwndClient);
2798 if (hwndFrame && hwndClient) {
2799 id = COLLECTOR_FRAME + idinc++;
2800 WinSetWindowUShort(hwndFrame, QWS_ID, id);
2801 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
2802 if (!dcd) {
2803 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2804 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
2805 hwndFrame = (HWND) 0;
2806 }
2807 else {
2808 dcd->size = sizeof(DIRCNRDATA);
2809 dcd->id = id;
2810 dcd->type = COLLECTOR_FRAME;
2811 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
2812 dcd->hwndFrame = hwndFrame;
2813 dcd->hwndClient = hwndClient;
2814 if (flags & 4)
2815 dcd->dontclose = TRUE;
2816 {
2817 PFNWP oldproc;
2818
2819 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) CollectorFrameWndProc);
2820 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
2821 }
2822 dcd->hwndCnr = WinCreateWindow(hwndClient,
2823 WC_CONTAINER,
2824 NULL,
2825 CCS_AUTOPOSITION | CCS_MINIICONS |
2826 CCS_MINIRECORDCORE | ulCnrType |
2827 WS_VISIBLE,
2828 0,
2829 0,
2830 0,
2831 0,
2832 hwndClient,
2833 HWND_TOP,
2834 (ULONG) COLLECTOR_CNR, NULL, NULL);
2835 if (!dcd->hwndCnr) {
2836 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
2837 IDS_WINCREATEWINDOW);
2838 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
2839 free(dcd);
2840 hwndFrame = (HWND) 0;
2841 }
2842 else {
2843 Collector = dcd->hwndCnr;
2844 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
2845 WinSetWindowText(hwndFrame, GetPString(IDS_COLLECTORTITLETEXT));
2846 if (FrameFlags & FCF_MENU) {
2847 PFNWP oldmenuproc;
2848 HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
2849
2850 oldmenuproc = WinSubclassWindow(hwndMenu, (PFNWP) CollectorMenuProc);
2851 WinSetWindowPtr(hwndMenu, QWL_USER, (PVOID) oldmenuproc);
2852 if (!fToolbar) {
2853 if (hwndMenu) {
2854
2855 WinSendMsg(hwndMenu,
2856 MM_DELETEITEM,
2857 MPFROM2SHORT(IDM_SEEALL, FALSE), MPVOID);
2858 WinSendMsg(hwndMenu,
2859 MM_DELETEITEM,
2860 MPFROM2SHORT(IDM_GREP, FALSE), MPVOID);
2861 WinSendMsg(hwndMenu,
2862 MM_DELETEITEM,
2863 MPFROM2SHORT(IDM_CLEARCNR, FALSE), MPVOID);
2864 WinSendMsg(hwndMenu,
2865 MM_DELETEITEM,
2866 MPFROM2SHORT(IDM_REMOVE, FALSE), MPVOID);
2867 }
2868 }
2869 }
2870 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
2871 (PFNWP) CollectorCnrWndProc);
2872 {
2873 USHORT ids[] = { DIR_TOTALS,
2874 DIR_SELECTED,
2875 DIR_VIEW,
2876 DIR_SORT,
2877 DIR_FILTER,
2878 0
2879 };
2880
2881 CommonCreateTextChildren(dcd->hwndClient,
2882 WC_COLSTATUS, ids);
2883 }
2884 if (FrameFlags & FCF_SHELLPOSITION)
2885 PostMsg(hwndClient, UM_SIZE, MPVOID, MPVOID);
2886 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
2887 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
2888 }
2889 }
2890 }
2891 return hwndFrame;
2892}
2893
2894#pragma alloc_text(COLLECTOR,CollectorCnrWndProc,CollectorObjWndProc)
2895#pragma alloc_text(COLLECTOR,CollectorClientWndProc,CollectorTextProc)
2896#pragma alloc_text(COLLECTOR,CollectorFrameWndProc)
2897#pragma alloc_text(STARTUP,StartCollector)
Note: See TracBrowser for help on using the repository browser.