source: trunk/dll/collect.c@ 688

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

Update History and file headers for CheckPmDrgLimit etc changes

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