source: trunk/dll/collect.c@ 705

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

Minor code cleanup fix ramdisk on states list & WORPLACE_PROCESS logic

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