source: trunk/dll/collect.c@ 689

Last change on this file since 689 was 689, checked in by Steven Levine, 18 years ago

Commit OpenWatcom compatibility updates

  • 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 689 2007-06-15 06:33:24Z stevenhl $
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 DIRCNRDATA *dcdsrc;
449
450 switch (msg) {
451 case WM_CREATE:
452 break;
453
454 case DM_PRINTOBJECT:
455 return MRFROMLONG(DRR_TARGET);
456
457 case DM_DISCARDOBJECT:
458 dcd = INSTDATA(hwnd);
459 if (fFM2Deletes && dcd) {
460 LISTINFO *li;
461 CNRDRAGINFO cni;
462
463 cni.pRecord = NULL;
464 cni.pDragInfo = (PDRAGINFO) mp1;
465 li = DoFileDrop(dcd->hwndCnr, NULL, FALSE, MPVOID, MPFROMP(&cni));
466 CheckPmDrgLimit(cni.pDragInfo);
467 if (li) {
468 li->type = fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE;
469 if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
470 FreeListInfo(li);
471 else
472 return MRFROMLONG(DRR_SOURCE);
473 }
474 }
475 return MRFROMLONG(DRR_TARGET);
476
477 case UM_UPDATERECORDLIST:
478 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
479 if (dcd && mp1) {
480 INT numentries = 0;
481 CHAR **list = (CHAR **) mp1;
482
483 while (list[numentries])
484 numentries++;
485 if (numentries)
486 UpdateCnrList(dcd->hwndCnr, list, numentries, FALSE, dcd);
487 }
488 return 0;
489
490 case UM_SETUP:
491 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
492 if (dcd) {
493 /* set unique id */
494 WinSetWindowUShort(hwnd,
495 QWS_ID,
496 COLLECTOROBJ_FRAME + (COLLECTOR_FRAME - dcd->id));
497 dcd->hwndObject = hwnd;
498 if (ParentIsDesktop(hwnd, dcd->hwndParent))
499 DosSleep(250L);
500 }
501 else
502 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
503 return 0;
504
505 case UM_COMMAND:
506 if (mp1) {
507 LISTINFO *li = (LISTINFO *) mp1;
508
509 switch (li->type) {
510 case IDM_DOITYOURSELF:
511 case IDM_APPENDTOCLIP:
512 case IDM_SAVETOCLIP:
513 case IDM_ARCHIVE:
514 case IDM_ARCHIVEM:
515 case IDM_VIEW:
516 case IDM_VIEWTEXT:
517 case IDM_VIEWBINARY:
518 case IDM_VIEWARCHIVE:
519 case IDM_EDIT:
520 case IDM_EDITTEXT:
521 case IDM_EDITBINARY:
522 case IDM_OBJECT:
523 case IDM_SHADOW:
524 case IDM_SHADOW2:
525 case IDM_PRINT:
526 case IDM_ATTRS:
527 case IDM_DELETE:
528 case IDM_PERMDELETE:
529 case IDM_FAKEEXTRACT:
530 case IDM_FAKEEXTRACTM:
531 case IDM_MCIPLAY:
532 case IDM_UPDATE:
533 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
534 return (MRESULT) TRUE;
535 break;
536 default:
537 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
538 return (MRESULT) TRUE;
539 }
540 }
541 return 0;
542
543 case UM_COLLECT:
544 DosError(FERR_DISABLEHARDERR);
545 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
546 if (dcd) {
547 LISTINFO *li = (LISTINFO *) mp1;
548 INT x;
549 FILEFINDBUF4 fb4;
550 HDIR hdir;
551 ULONG nm;
552 PCNRITEM pci, pciFirst, pciT, pciP = NULL;
553 RECORDINSERT ri;
554 ULONG ulMaxFiles;
555 ULONGLONG ullTotalBytes;
556 CHAR fullname[CCHMAXPATH];
557
558 WinSetWindowText(WinWindowFromID(dcd->hwndClient, DIR_SELECTED),
559 GetPString(IDS_COLLECTINGTEXT));
560 for (ulMaxFiles = 0; li->list[ulMaxFiles]; ulMaxFiles++) ; // Count
561
562 if (ulMaxFiles) {
563 pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD,
564 MPFROMLONG(EXTRA_RECORD_BYTES),
565 MPFROMLONG(ulMaxFiles));
566 if (!pci) {
567 Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
568 ulMaxFiles);
569 break;
570 }
571 else {
572 pciFirst = pci;
573 for (x = 0; li->list[x]; x++) {
574 nm = 1L;
575 hdir = HDIR_CREATE;
576 DosError(FERR_DISABLEHARDERR);
577 if (*li->list[x] &&
578 !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
579 fullname, sizeof(fullname)) &&
580 !IsRoot(fullname) &&
581 !FindCnrRecord(dcd->hwndCnr,
582 fullname,
583 NULL,
584 FALSE,
585 FALSE,
586 TRUE) &&
587 !DosFindFirst(fullname,
588 &hdir,
589 FILE_NORMAL | FILE_DIRECTORY |
590 FILE_ARCHIVED | FILE_SYSTEM |
591 FILE_HIDDEN | FILE_READONLY,
592 &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZE)) {
593 DosFindClose(hdir);
594 priority_normal();
595 *fb4.achName = 0;
596 ullTotalBytes = FillInRecordFromFFB(dcd->hwndCnr,
597 pci,
598 fullname, &fb4, FALSE, dcd);
599 dcd->ullTotalBytes += ullTotalBytes;
600 pciP = pci;
601 pci = (PCNRITEM) pci->rc.preccNextRecord;
602 }
603 else {
604 pciT = pci;
605 pci = (PCNRITEM) pci->rc.preccNextRecord;
606 if (pciP)
607 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
608 else
609 pciFirst = pci;
610 WinSendMsg(hwnd, CM_FREERECORD, MPFROMP(&pciT),
611 MPFROM2SHORT(1, 0));
612 ulMaxFiles--;
613 }
614 DosSleep(1L);
615 }
616 if (ulMaxFiles) {
617 memset(&ri, 0, sizeof(RECORDINSERT));
618 ri.cb = sizeof(RECORDINSERT);
619 ri.pRecordOrder = (PRECORDCORE) CMA_END;
620 ri.pRecordParent = (PRECORDCORE) 0;
621 ri.zOrder = (ULONG) CMA_TOP;
622 ri.cRecordsInsert = ulMaxFiles;
623 ri.fInvalidateRecord = TRUE;
624 WinSendMsg(dcd->hwndCnr,
625 CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
626 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
627 }
628 }
629 }
630 }
631 if (dcd->flWindowAttr & CV_DETAIL)
632 WinSendDlgItemMsg(hwnd,
633 COLLECTOR_CNR,
634 CM_INVALIDATERECORD,
635 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
636 return 0;
637
638 case UM_COLLECTFROMFILE:
639 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
640 if (dcd && mp1) {
641 FILESTATUS4 fs4;
642 PCNRITEM pci;
643 RECORDINSERT ri;
644 CHAR fullname[1024], *p;
645 FILE *fp;
646 ULONG errs = 0L;
647 BOOL first = FALSE;
648 size_t c;
649
650 fp = _fsopen((CHAR *) mp1, "r", SH_DENYNO);
651 if (fp) {
652 while (!feof(fp)) {
653 // Avoid too much noise if collecting from binary file - oops
654 if (!fgets(fullname, sizeof(fullname), fp)) {
655 if (ferror(fp))
656 Runtime_Error(pszSrcFile, __LINE__, "fgets");
657 break;
658 }
659
660 c = strlen(fullname);
661 if (c + 1 >= sizeof(fullname))
662 errs++;
663 else if (!c || (fullname[c - 1] != '\n' && fullname[c - 1] != '\r'))
664 errs++;
665 else {
666 bstripcr(fullname);
667
668 if (*fullname == '\"') {
669 memmove(fullname, fullname + 1, strlen(fullname) + 1);
670 lstrip(fullname);
671 p = strchr(fullname, '\"');
672 if (p)
673 *p = 0;
674 rstrip(fullname);
675 }
676 else {
677 p = strchr(fullname, ' ');
678 if (p)
679 *p = 0;
680 }
681 /* fullname now contains name of file to collect */
682 DosError(FERR_DISABLEHARDERR);
683 if (IsFullName(fullname) &&
684 !IsRoot(fullname) &&
685 !DosQueryPathInfo(fullname,
686 FIL_QUERYEASIZE,
687 &fs4,
688 sizeof(fs4)) &&
689 !FindCnrRecord(dcd->hwndCnr,
690 fullname, NULL, FALSE, FALSE, TRUE)) {
691 /* collect it */
692 pci = WinSendMsg(dcd->hwndCnr,
693 CM_ALLOCRECORD,
694 MPFROMLONG(EXTRA_RECORD_BYTES),
695 MPFROMLONG(1L));
696 if (pci) {
697 dcd->ullTotalBytes += FillInRecordFromFSA(dcd->hwndCnr, pci,
698 fullname,
699 &fs4, FALSE, dcd);
700 memset(&ri, 0, sizeof(RECORDINSERT));
701 ri.cb = sizeof(RECORDINSERT);
702 ri.pRecordOrder = (PRECORDCORE) CMA_END;
703 ri.pRecordParent = (PRECORDCORE) 0;
704 ri.zOrder = (ULONG) CMA_TOP;
705 ri.cRecordsInsert = 1L;
706 ri.fInvalidateRecord = TRUE;
707 WinSendMsg(dcd->hwndCnr, CM_INSERTRECORD,
708 MPFROMP(pci), MPFROMP(&ri));
709 }
710 }
711 else
712 errs++;
713 }
714 if (errs > (first ? 0 : 50)) {
715 /* prevent runaway on bad file */
716 APIRET ret = saymsg(MB_YESNO, dcd->hwndCnr,
717 GetPString(IDS_COLLECTNOLISTHDRTEXT),
718 GetPString(IDS_COLLECTNOLISTTEXT),
719 (CHAR *) mp1);
720
721 if (ret == MBID_NO)
722 break;
723 if (!first)
724 errs = 0;
725 else
726 first = FALSE;
727 }
728 } // while not eof
729 fclose(fp);
730 }
731 }
732 xfree(mp1);
733 return 0;
734
735 case UM_SELECT:
736 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
737 if (dcd) {
738 switch (SHORT1FROMMP(mp1)) {
739 case IDM_SELECTLIST:
740 {
741 CHAR filename[CCHMAXPATH], *p, *pp;
742
743 strcpy(filename, "*.LST");
744 size = CCHMAXPATH;
745 PrfQueryProfileData(fmprof, appname, "SaveToListName", filename,
746 &size);
747 pp = strrchr(filename, '\\');
748 if (!pp)
749 pp = filename;
750 p = strrchr(pp, '.');
751 if (p && *(p + 1) && p > pp + 1) {
752 if (pp > filename)
753 pp++;
754 *pp = '*';
755 pp++;
756 if (p > pp)
757 memmove(pp, p, strlen(p) + 1);
758 }
759 if (insert_filename(hwnd, filename, FALSE, FALSE))
760 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
761 NULL);
762 }
763 break;
764 case IDM_SELECTALL:
765 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
766 break;
767 case IDM_DESELECTALL:
768 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
769 break;
770 case IDM_SELECTALLFILES:
771 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
772 break;
773 case IDM_DESELECTALLFILES:
774 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
775 break;
776 case IDM_SELECTALLDIRS:
777 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
778 break;
779 case IDM_DESELECTALLDIRS:
780 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
781 break;
782 case IDM_DESELECTMASK:
783 case IDM_SELECTMASK:
784 {
785 MASK mask;
786 PCNRITEM pci = (PCNRITEM) mp2;
787
788 memset(&mask, 0, sizeof(MASK));
789 mask.fNoAttribs = TRUE;
790 mask.fNoDirs = TRUE;
791 mask.fText = TRUE;
792 strcpy(mask.prompt,
793 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
794 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
795 if (pci && (INT) pci != -1)
796 strcpy(mask.szMask, pci->szFileName);
797 if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
798 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
799 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
800 SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
801 FALSE);
802 else
803 DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
804 FALSE);
805 }
806 }
807
808 case IDM_DESELECTCLIP:
809 case IDM_SELECTCLIP:
810 {
811 CHAR **list;
812
813 list = ListFromClipboard(hwnd);
814 if (list) {
815 SelectList(dcd->hwndCnr, TRUE, FALSE,
816 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
817 NULL, NULL, list);
818 FreeList(list);
819 }
820 }
821 break;
822
823 case IDM_INVERT:
824 InvertAll(dcd->hwndCnr);
825 break;
826 }
827 }
828 return 0;
829
830 case UM_MASSACTION:
831 if (mp1) {
832 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
833 if (dcd) {
834 WORKER *wk;
835
836 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
837 if (!wk)
838 FreeListInfo((LISTINFO *) mp1);
839 else {
840 wk->size = sizeof(WORKER);
841 wk->hwndCnr = dcd->hwndCnr;
842 wk->hwndParent = dcd->hwndParent;
843 wk->hwndFrame = dcd->hwndFrame;
844 wk->hwndClient = dcd->hwndClient;
845 wk->li = (LISTINFO *) mp1;
846 strcpy(wk->directory, dcd->directory);
847 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
848 Runtime_Error(pszSrcFile, __LINE__,
849 GetPString(IDS_COULDNTSTARTTHREADTEXT));
850 free(wk);
851 FreeListInfo((LISTINFO *) mp1);
852 }
853 }
854 }
855 }
856 return 0;
857
858 case UM_ACTION:
859 if (mp1) {
860 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
861 if (dcd) {
862 WORKER *wk;
863
864 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
865 if (!wk)
866 FreeListInfo((LISTINFO *) mp1);
867 else {
868 wk->size = sizeof(WORKER);
869 wk->hwndCnr = dcd->hwndCnr;
870 wk->hwndParent = dcd->hwndParent;
871 wk->hwndFrame = dcd->hwndFrame;
872 wk->hwndClient = dcd->hwndClient;
873 wk->li = (LISTINFO *) mp1;
874 strcpy(wk->directory, dcd->directory);
875 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
876 Runtime_Error(pszSrcFile, __LINE__,
877 GetPString(IDS_COULDNTSTARTTHREADTEXT));
878 free(wk);
879 FreeListInfo((LISTINFO *) mp1);
880 }
881 }
882 }
883 }
884 return 0;
885
886 case WM_CLOSE:
887 WinDestroyWindow(hwnd);
888 break;
889
890 case WM_DESTROY:
891 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
892 if (dcd) {
893 INT x;
894
895 dcd->stopflag = 1;
896 // Allow rescan logic to quiesce
897 for (x = 0; x < 10 && dcd->amextracted; x++)
898 DosSleep(250L);
899 WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
900 FreeList(dcd->lastselection);
901 free(dcd);
902 }
903 DosPostEventSem(CompactSem);
904 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
905 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
906 break;
907 }
908 return WinDefWindowProc(hwnd, msg, mp1, mp2);
909}
910
911MRESULT EXPENTRY CollectorCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
912 MPARAM mp2)
913{
914 DIRCNRDATA *dcd = INSTDATA(hwnd);
915 DIRCNRDATA *dcdsrc;
916 ULONG size;
917
918 static INT savedSortFlags;
919
920 switch (msg) {
921 case DM_PRINTOBJECT:
922 return MRFROMLONG(DRR_TARGET);
923
924 case DM_DISCARDOBJECT:
925 if (dcd)
926 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
927 else
928 return MRFROMLONG(DRR_TARGET);
929
930 case WM_CHAR:
931 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
932 if (SHORT1FROMMP(mp1) & KC_KEYUP)
933 return (MRESULT) TRUE;
934 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
935 switch (SHORT2FROMMP(mp2)) {
936 case VK_DELETE:
937 if ((shiftstate & KC_CTRL) == KC_CTRL)
938 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
939 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
940 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
941 else
942 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
943 break;
944 }
945 }
946 if (shiftstate || fNoSearch)
947 break;
948 if (SHORT1FROMMP(mp1) & KC_CHAR) {
949 ULONG thistime, len;
950 SEARCHSTRING srch;
951 PCNRITEM pci;
952
953 if (!dcd)
954 break;
955 switch (SHORT1FROMMP(mp2)) {
956 case '\x1b':
957 case '\r':
958 case '\n':
959 dcd->lasttime = 0;
960 *dcd->szCommonName = 0;
961 break;
962 default:
963 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
964 if (thistime > dcd->lasttime + 1250)
965 *dcd->szCommonName = 0;
966 dcd->lasttime = thistime;
967 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
968 break;
969 KbdRetry:
970 len = strlen(dcd->szCommonName);
971 if (len >= CCHMAXPATH - 1) {
972 *dcd->szCommonName = 0;
973 len = 0;
974 }
975 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
976 dcd->szCommonName[len + 1] = 0;
977 memset(&srch, 0, sizeof(SEARCHSTRING));
978 srch.cb = sizeof(SEARCHSTRING);
979 srch.pszSearch = dcd->szCommonName;
980 srch.fsPrefix = TRUE;
981 srch.fsCaseSensitive = FALSE;
982 srch.usView = CV_ICON;
983 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
984 MPFROMLONG(CMA_FIRST));
985 if (pci && (INT) pci != -1) {
986 USHORT attrib = CRA_CURSORED;
987
988 /* make found item current item */
989 if (!stricmp(pci->pszFileName, dcd->szCommonName))
990 attrib |= CRA_SELECTED;
991 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
992 MPFROM2SHORT(TRUE, attrib));
993 /* make sure that record shows in viewport */
994 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
995 return (MRESULT) TRUE;
996 }
997 else {
998 if (SHORT1FROMMP(mp2) == ' ') {
999 dcd->szCommonName[len] = 0;
1000 break;
1001 }
1002 *dcd->szCommonName = 0;
1003 dcd->lasttime = 0;
1004 if (len) // retry as first letter if no match
1005
1006 goto KbdRetry;
1007 }
1008 break;
1009 }
1010 }
1011 break;
1012
1013 case WM_MOUSEMOVE:
1014 case WM_BUTTON1UP:
1015 case WM_BUTTON2UP:
1016 case WM_BUTTON3UP:
1017 case WM_CHORD:
1018 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1019 break;
1020
1021 case WM_BUTTON1MOTIONEND:
1022 {
1023 CNRINFO cnri;
1024
1025 memset(&cnri, 0, sizeof(CNRINFO));
1026 cnri.cb = sizeof(CNRINFO);
1027 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1028 MPFROMLONG(sizeof(CNRINFO)))) {
1029 if (cnri.flWindowAttr & CV_DETAIL)
1030 PrfWriteProfileData(fmprof, appname, "CollectorCnrSplitBar",
1031 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
1032 }
1033 }
1034 break;
1035
1036 case WM_PRESPARAMCHANGED:
1037 PresParamChanged(hwnd, "Collector", mp1, mp2);
1038 break;
1039
1040 case UM_COMPARE:
1041 if (dcd && mp1 && mp2) {
1042 COMPARE *cmp;
1043 CHAR *leftdir = (CHAR *) mp1, *rightdir = (CHAR *) mp2;
1044
1045 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1046 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1047 if (cmp) {
1048 cmp->size = sizeof(COMPARE);
1049 strcpy(cmp->leftdir, leftdir);
1050 strcpy(cmp->rightdir, rightdir);
1051 cmp->hwndParent = dcd->hwndParent;
1052 cmp->dcd.hwndParent = dcd->hwndParent;
1053 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, CompareDlgProc,
1054 FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1055 }
1056 }
1057 }
1058 return 0;
1059
1060 case UM_UPDATERECORDLIST:
1061 if (dcd && mp1)
1062 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1063 return 0;
1064
1065 case UM_UPDATERECORD:
1066 if (dcd && mp1) {
1067 CHAR *filename;
1068
1069 filename = mp1;
1070 if (filename)
1071 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1072 }
1073 return 0;
1074
1075 case WM_SETFOCUS:
1076 /*
1077 * put name of our window on status line
1078 */
1079 if (dcd && hwndStatus && mp2) {
1080 PCNRITEM pci = NULL;
1081
1082 if (fAutoView && hwndMain) {
1083 pci = WinSendMsg(hwnd,
1084 CM_QUERYRECORDEMPHASIS,
1085 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1086 if (pci && (INT) pci != -1 &&
1087 (!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_SLOW)))
1088 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->szFileName), MPVOID);
1089 else
1090 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1091 }
1092 if (dcd->amextracted)
1093 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1094 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1095 }
1096 break;
1097
1098 case UM_RESCAN:
1099 if (dcd) {
1100 CNRINFO cnri;
1101 CHAR s[CCHMAXPATH + 69], tb[81], tf[81], *p;
1102 PCNRITEM pci = NULL;
1103
1104 memset(&cnri, 0, sizeof(CNRINFO));
1105 cnri.cb = sizeof(CNRINFO);
1106 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1107 MPFROMLONG(sizeof(CNRINFO)));
1108 dcd->totalfiles = cnri.cRecords;
1109 commafmt(tf, sizeof(tf), dcd->totalfiles);
1110 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
1111 sprintf(s, "%s / %s", tf, tb);
1112 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1113
1114 commafmt(tf, sizeof(tf), dcd->selectedfiles);
1115 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
1116 sprintf(s, "%s / %s", tf, tb);
1117 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1118
1119 if (hwndStatus &&
1120 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1121 if (hwndMain) {
1122 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1123 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1124 if (pci && (INT) pci != -1)
1125 PostMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->szFileName), MPVOID);
1126 else
1127 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1128 }
1129 if (!fMoreButtons)
1130 sprintf(s, " %s%s%s%s", GetPString(IDS_COLLECTORTEXT),
1131 (*dcd->mask.szMask || dcd->mask.antiattr ||
1132 dcd->mask.attrFile != ALLATTRS) ? " (" : NullStr,
1133 (*dcd->mask.szMask) ? dcd->mask.szMask :
1134 (dcd->mask.antiattr ||
1135 dcd->mask.attrFile != ALLATTRS) ?
1136 GetPString(IDS_ATTRTEXT) : NullStr,
1137 (*dcd->mask.szMask || dcd->mask.antiattr ||
1138 dcd->mask.attrFile != ALLATTRS) ? ")" : NullStr);
1139 else
1140 strcpy(s, GetPString(IDS_COLLECTORTEXT));
1141 WinSetWindowText(hwndStatus, s);
1142 if (!pci)
1143 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1144 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1145 if (pci && (INT) pci != -1) {
1146 BOOL fStatus2Used = FALSE;
1147
1148 if (fSplitStatus && hwndStatus2) {
1149 if (pci->attrFile & FILE_DIRECTORY)
1150 p = pci->pszFileName;
1151 else {
1152 p = strrchr(pci->szFileName, '\\');
1153 if (p) {
1154 if (*(p + 1))
1155 p++;
1156 else
1157 p = pci->pszFileName;
1158 }
1159 else
1160 p = pci->pszFileName;
1161 }
1162 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1163 if (!fMoreButtons) {
1164 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
1165 tb, pci->date.year, pci->date.month,
1166 pci->date.day, pci->time.hours, pci->time.minutes,
1167 pci->time.seconds, pci->pszDispAttr, p);
1168 }
1169 else {
1170 if (pci->cbFile + pci->easize > 1024)
1171 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1172 else
1173 *tf = 0;
1174 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
1175 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1176 }
1177 WinSetWindowText(hwndStatus2, s);
1178 fStatus2Used = TRUE;
1179 }
1180 if (fMoreButtons) {
1181 WinSetWindowText(hwndName, pci->pszFileName);
1182 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
1183 pci->date.year, pci->date.month,
1184 pci->date.day, pci->time.hours, pci->time.minutes,
1185 pci->time.seconds);
1186 WinSetWindowText(hwndDate, s);
1187 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1188 }
1189 if (dcd->amextracted && hwndStatus2 && !fStatus2Used)
1190 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1191 }
1192 else {
1193 if (hwndStatus2)
1194 WinSetWindowText(hwndStatus2, NullStr);
1195 if (fMoreButtons) {
1196 WinSetWindowText(hwndName, NullStr);
1197 WinSetWindowText(hwndDate, NullStr);
1198 WinSetWindowText(hwndAttr, NullStr);
1199 }
1200 }
1201 }
1202 }
1203 return 0;
1204
1205 case UM_CONTAINER_FILLED:
1206 DosBeep(1000, 50); // Wake up user?
1207 WinSendMsg(hwnd,
1208 CM_INVALIDATERECORD,
1209 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1210 disable_menuitem(WinWindowFromID(WinQueryWindow(hwndMain, QW_PARENT),
1211 FID_MENU), IDM_GREP, FALSE);
1212 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1213 if (dcd) {
1214 dcd->stopflag = 0;
1215 dcd->amextracted = FALSE; // Say not busy
1216 if (dcd->namecanchange) {
1217 if (!PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID))
1218 WinSendMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1219 }
1220 else
1221 WinSetWindowPos(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
1222 QW_PARENT),
1223 HWND_TOP,
1224 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ZORDER);
1225 }
1226 return 0;
1227
1228 case UM_SETUP:
1229 if (dcd) {
1230 if (!dcd->hwndObject) {
1231 /* first time through -- set things up */
1232
1233 CNRINFO cnri;
1234
1235 RestorePresParams(hwnd, "Collector");
1236 LoadDetailsSwitches("Collector", dcd);
1237
1238 dcd->amextracted = FALSE; // Say not busy
1239 dcd->stopflag = 0;
1240 memset(&cnri, 0, sizeof(CNRINFO));
1241 cnri.cb = sizeof(CNRINFO);
1242 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1243 MPFROMLONG(sizeof(CNRINFO)));
1244 cnri.cyLineSpacing = 0;
1245 cnri.cxTreeIndent = 12L;
1246
1247 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_DETAIL));
1248 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES |
1249 CV_MINI | CV_FLOW);
1250 cnri.pSortRecord = (PVOID) SortCollectorCnr;
1251
1252 size = sizeof(ULONG);
1253 PrfQueryProfileData(fmprof, appname, "CollectorflWindowAttr",
1254 (PVOID) & cnri.flWindowAttr, &size);
1255 size = sizeof(MASK);
1256 if (PrfQueryProfileSize(fmprof, appname, "CollectorFilter", &size) &&
1257 size) {
1258 PrfQueryProfileData(fmprof, appname, "CollectorFilter", &dcd->mask,
1259 &size);
1260 SetMask(NULL, &dcd->mask);
1261 }
1262 else {
1263 dcd->mask.attrFile = (FILE_NORMAL | FILE_READONLY |
1264 FILE_DIRECTORY | FILE_HIDDEN |
1265 FILE_SYSTEM | FILE_ARCHIVED);
1266 dcd->mask.antiattr = 0;
1267 }
1268
1269 *(dcd->mask.prompt) = 0;
1270
1271 cnri.flWindowAttr |= CV_FLOW;
1272 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
1273 dcd->flWindowAttr = cnri.flWindowAttr;
1274 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1275 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1276 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1277 SetCnrCols(hwnd, FALSE);
1278 AdjustCnrColsForPref(hwnd, NULL, dcd, FALSE);
1279
1280 /* fix splitbar for collector container */
1281 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1282 size = sizeof(LONG);
1283 PrfQueryProfileData(fmprof, appname, "CollectorCnrSplitBar",
1284 &cnri.xVertSplitbar, &size);
1285 if (cnri.xVertSplitbar <= 0)
1286 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1287 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1288 MPFROMLONG(CMA_XVERTSPLITBAR));
1289
1290 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID) dcd) == -1) {
1291 Runtime_Error(pszSrcFile, __LINE__,
1292 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1293 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1294 return 0;
1295 }
1296 else
1297 DosSleep(64L);
1298 }
1299 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1300 DIR_FILTER), &dcd->mask, FALSE);
1301 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1302 DIR_SORT), CollectorsortFlags, FALSE);
1303 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1304 DIR_VIEW), dcd->flWindowAttr);
1305 }
1306 else {
1307 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1308 return 0;
1309 }
1310 return 0;
1311
1312 case WM_MENUEND:
1313 if (dcd) {
1314 HWND hwndMenu = (HWND) mp2;
1315
1316 if (hwndMenu == CollectorCnrMenu || hwndMenu == CollectorFileMenu ||
1317 hwndMenu == CollectorDirMenu) {
1318 MarkAll(hwnd, TRUE, FALSE, TRUE);
1319 if (dcd->cnremphasized) {
1320 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1321 MPFROM2SHORT(FALSE, CRA_SOURCE));
1322 dcd->cnremphasized = FALSE;
1323 }
1324 }
1325 }
1326 break;
1327
1328 case UM_OPENWINDOWFORME:
1329 if (dcd) {
1330 if (mp1 && !IsFile((CHAR *) mp1))
1331 OpenDirCnr(HWND_DESKTOP, hwndMain, dcd->hwndFrame, FALSE, (PSZ) mp1);
1332 else if (mp1 && IsFile(mp1) == 1)
1333 StartArcCnr(HWND_DESKTOP,
1334 dcd->hwndFrame, (CHAR *) mp1, 4, (ARC_TYPE *) mp2);
1335 }
1336 return 0;
1337
1338 case MM_PORTHOLEINIT:
1339 if (dcd) {
1340 switch (SHORT1FROMMP(mp1)) {
1341 case 0:
1342 case 1:
1343 {
1344 ULONG wmsg;
1345
1346 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1347 PortholeInit((HWND) WinSendMsg(dcd->hwndClient, wmsg, MPVOID,
1348 MPVOID), mp1, mp2);
1349 }
1350 break;
1351 }
1352 }
1353 break;
1354
1355 case UM_INITMENU:
1356 case WM_INITMENU:
1357 if (dcd) {
1358 switch (SHORT1FROMMP(mp1)) {
1359 case IDM_VIEWSMENU:
1360 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1361 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1362 (dcd->lastselection != NULL));
1363 break;
1364
1365 case IDM_DETAILSSETUP:
1366 SetDetailsSwitches((HWND) mp2, dcd);
1367 break;
1368
1369 case IDM_COMMANDSMENU:
1370 SetupCommandMenu((HWND) mp2, hwnd);
1371 break;
1372
1373 case IDM_SORTSUBMENU:
1374 SetSortChecks((HWND) mp2, CollectorsortFlags);
1375 break;
1376 }
1377 dcd->hwndLastMenu = (HWND) mp2;
1378 }
1379 if (msg == WM_INITMENU)
1380 break;
1381 return 0;
1382
1383 case UM_COLLECTFROMFILE:
1384 if (mp1) {
1385 if (!dcd) {
1386 free(mp1);
1387 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1388 }
1389 else {
1390 if (!PostMsg(dcd->hwndObject, UM_COLLECTFROMFILE, mp1, mp2)) {
1391 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1392 free(mp1);
1393 }
1394 }
1395 }
1396 return 0;
1397
1398 case UM_COMMAND:
1399 if (mp1) {
1400 if (dcd) {
1401 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1402 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1403 FreeListInfo((LISTINFO *) mp1);
1404 }
1405 else
1406 return (MRESULT) TRUE;
1407 }
1408 else
1409 FreeListInfo((LISTINFO *) mp1);
1410 }
1411 return 0;
1412
1413 case UM_NOTIFY:
1414 if (mp2)
1415 AddNote((CHAR *) mp2);
1416 return 0;
1417
1418 case WM_COMMAND:
1419 DosError(FERR_DISABLEHARDERR);
1420 if (dcd) {
1421 switch (SHORT1FROMMP(mp1)) {
1422 case IDM_SETTARGET:
1423 SetTargetDir(hwnd, FALSE);
1424 break;
1425
1426 case IDM_CONTEXTMENU:
1427 {
1428 PCNRITEM pci;
1429
1430 pci = (PCNRITEM) CurrentRecord(hwnd);
1431 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(COLLECTOR_CNR,
1432 CN_CONTEXTMENU),
1433 MPFROMP(pci));
1434 }
1435 break;
1436
1437 case IDM_SHOWALLFILES:
1438 {
1439 PCNRITEM pci;
1440
1441 pci = WinSendMsg(hwnd,
1442 CM_QUERYRECORDEMPHASIS,
1443 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1444 if (pci && (INT) pci != -1) {
1445 static CHAR dirname[CCHMAXPATH];
1446
1447 strcpy(dirname, pci->szFileName);
1448 MakeValidDir(dirname);
1449 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1450 }
1451 }
1452 break;
1453
1454 case IDM_BEGINEDIT:
1455 OpenEdit(hwnd);
1456 break;
1457
1458 case IDM_ENDEDIT:
1459 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1460 break;
1461
1462 case IDM_SHOWSELECT:
1463 QuickPopup(hwnd, dcd,
1464 CheckMenu(&CollectorCnrMenu, COLLECTORCNR_POPUP),
1465 IDM_SELECTSUBMENU);
1466 break;
1467
1468 case IDM_SHOWSORT:
1469 QuickPopup(hwnd, dcd,
1470 CheckMenu(&CollectorCnrMenu, COLLECTORCNR_POPUP),
1471 IDM_SORTSUBMENU);
1472 break;
1473
1474 case IDM_VIEWORARC:
1475 {
1476 SWP swp;
1477 PCNRITEM pci;
1478
1479 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1480 MPFROMLONG(CMA_FIRST),
1481 MPFROMSHORT(CRA_CURSORED));
1482 if (pci && (INT) pci != -1) {
1483 WinQueryWindowPos(dcd->hwndFrame, &swp);
1484 DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp,
1485 pci->szFileName);
1486 }
1487 }
1488 break;
1489
1490 case IDM_SEEALL:
1491 StartSeeAll(HWND_DESKTOP, FALSE, NULL);
1492 break;
1493
1494 case IDM_COLLECTSELECT:
1495 {
1496 CHAR filename[CCHMAXPATH], *p, *pp;
1497
1498 strcpy(filename, "*.LST");
1499 size = CCHMAXPATH;
1500 PrfQueryProfileData(fmprof, appname, "SaveToListName",
1501 filename, &size);
1502 pp = strrchr(filename, '\\');
1503 if (!pp)
1504 pp = filename;
1505 p = strrchr(pp, '.');
1506 if (p && *(p + 1) && p > pp + 1) {
1507 if (pp > filename)
1508 pp++;
1509 *pp = '*';
1510 pp++;
1511 if (p > pp)
1512 memmove(pp, p, strlen(p) + 1);
1513 }
1514 if (insert_filename(hwnd, filename, FALSE, FALSE)) {
1515 p = xstrdup(filename, pszSrcFile, __LINE__);
1516 if (p) {
1517 if (!PostMsg(hwnd, UM_COLLECTFROMFILE, MPFROMP(p), MPVOID))
1518 free(p);
1519 }
1520 }
1521 }
1522 break;
1523
1524 case IDM_NOTEBOOK:
1525 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1526 PostMsg(dcd->hwndParent, msg, mp1, mp2);
1527 else
1528 WinDlgBox(HWND_DESKTOP, hwnd, CfgDlgProc, FM3ModHandle,
1529 CFG_FRAME, (PVOID) "Collector");
1530 break;
1531
1532 case IDM_RESELECT:
1533 SelectList(hwnd, FALSE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1534 break;
1535
1536 case IDM_HELP:
1537 if (hwndHelp)
1538 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
1539 MPFROM2SHORT(HELP_COLLECT, 0),
1540 MPFROMSHORT(HM_RESOURCEID));
1541 break;
1542
1543 case IDM_SORTNONE:
1544 case IDM_SORTSMARTNAME:
1545 case IDM_SORTNAME:
1546 case IDM_SORTFILENAME:
1547 case IDM_SORTSIZE:
1548 case IDM_SORTEASIZE:
1549 case IDM_SORTFIRST:
1550 case IDM_SORTLAST:
1551 case IDM_SORTLWDATE:
1552 case IDM_SORTLADATE:
1553 case IDM_SORTCRDATE:
1554 case IDM_SORTSUBJECT:
1555 savedSortFlags = CollectorsortFlags;
1556 CollectorsortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1557 case IDM_SORTDIRSFIRST:
1558 case IDM_SORTDIRSLAST:
1559 case IDM_SORTREVERSE:
1560 switch (SHORT1FROMMP(mp1)) {
1561 case IDM_SORTSUBJECT:
1562 CollectorsortFlags |= SORT_SUBJECT;
1563 break;
1564 case IDM_SORTNONE:
1565 CollectorsortFlags |= SORT_NOSORT;
1566 break;
1567 case IDM_SORTSMARTNAME:
1568 if (~savedSortFlags & SORT_FILENAME)
1569 CollectorsortFlags |= SORT_FILENAME;
1570 break;
1571 case IDM_SORTFILENAME:
1572 CollectorsortFlags |= SORT_FILENAME;
1573 break;
1574 case IDM_SORTSIZE:
1575 CollectorsortFlags |= SORT_SIZE;
1576 break;
1577 case IDM_SORTEASIZE:
1578 CollectorsortFlags |= SORT_EASIZE;
1579 break;
1580 case IDM_SORTFIRST:
1581 CollectorsortFlags |= SORT_FIRSTEXTENSION;
1582 break;
1583 case IDM_SORTLAST:
1584 CollectorsortFlags |= SORT_LASTEXTENSION;
1585 break;
1586 case IDM_SORTLWDATE:
1587 CollectorsortFlags |= SORT_LWDATE;
1588 break;
1589 case IDM_SORTLADATE:
1590 CollectorsortFlags |= SORT_LADATE;
1591 break;
1592 case IDM_SORTCRDATE:
1593 CollectorsortFlags |= SORT_CRDATE;
1594 break;
1595 case IDM_SORTDIRSFIRST:
1596 if (CollectorsortFlags & SORT_DIRSFIRST)
1597 CollectorsortFlags &= (~SORT_DIRSFIRST);
1598 else {
1599 CollectorsortFlags |= SORT_DIRSFIRST;
1600 CollectorsortFlags &= (~SORT_DIRSLAST);
1601 }
1602 break;
1603 case IDM_SORTDIRSLAST:
1604 if (CollectorsortFlags & SORT_DIRSLAST)
1605 CollectorsortFlags &= (~SORT_DIRSLAST);
1606 else {
1607 CollectorsortFlags |= SORT_DIRSLAST;
1608 CollectorsortFlags &= (~SORT_DIRSFIRST);
1609 }
1610 break;
1611 case IDM_SORTREVERSE:
1612 if (CollectorsortFlags & SORT_REVERSE)
1613 CollectorsortFlags &= (~SORT_REVERSE);
1614 else
1615 CollectorsortFlags |= SORT_REVERSE;
1616 break;
1617 }
1618 PrfWriteProfileData(fmprof, appname, "CollectorSort",
1619 &CollectorsortFlags, sizeof(INT));
1620 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1621 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1622 DIR_SORT), CollectorsortFlags, FALSE);
1623 break;
1624
1625 case IDM_COLLECTFROMCLIP:
1626 {
1627 LISTINFO *li;
1628
1629 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1630 if (li) {
1631 li->list = ListFromClipboard(hwnd);
1632 if (!li->list || !li->list[0])
1633 FreeListInfo(li);
1634 else {
1635 li->type = IDM_COLLECT;
1636 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1637 FreeListInfo(li);
1638 }
1639 }
1640 }
1641 break;
1642
1643 case IDM_REMOVE:
1644 if (fAutoView && hwndMain)
1645 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1646 dcd->suspendview = 1;
1647 RemoveAll(hwnd, &dcd->ullTotalBytes, &dcd->totalfiles);
1648 dcd->suspendview = 0;
1649 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1650 break;
1651
1652 case IDM_CLEARCNR:
1653 {
1654 PCNRITEM pci;
1655
1656 pci = (PCNRITEM) WinSendMsg(hwnd,
1657 CM_QUERYRECORD,
1658 MPVOID,
1659 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
1660 if (pci && (INT) pci != -1) {
1661 WinSendMsg(hwnd,
1662 CM_REMOVERECORD,
1663 MPVOID, MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE));
1664 dcd->ullTotalBytes = dcd->selectedbytes = dcd->selectedfiles =
1665 dcd->totalfiles = 0L;
1666 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1667 }
1668 }
1669 break;
1670
1671 case DID_CANCEL:
1672 if (dcd->amextracted)
1673 dcd->stopflag = 1; // Request cancel
1674 break;
1675
1676 case IDM_COLLECTOR:
1677 if (mp2) {
1678 LISTINFO *li;
1679
1680 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1681 if (li) {
1682 li->list = mp2;
1683 if (!li->list || !li->list[0])
1684 FreeListInfo(li);
1685 else {
1686 li->type = IDM_COLLECT;
1687 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1688 FreeListInfo(li);
1689 }
1690 }
1691 else
1692 FreeList(mp2);
1693 }
1694 break;
1695
1696 case IDM_UNDELETE:
1697 {
1698 PCNRITEM pci;
1699 CHAR path[CCHMAXPATH];
1700
1701 pci = (PCNRITEM) CurrentRecord(hwnd);
1702 if (pci) {
1703 strcpy(path, pci->szFileName);
1704 MakeValidDir(path);
1705 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
1706 UNDEL_FRAME, MPFROMP(path));
1707 }
1708 }
1709 break;
1710
1711 case IDM_GREP:
1712 if (dcd->amextracted)
1713 Runtime_Error(pszSrcFile, __LINE__, "busy");
1714 else {
1715 if (WinDlgBox(HWND_DESKTOP, hwnd, GrepDlgProc,
1716 FM3ModHandle, GREP_FRAME, (PVOID) & hwnd)) {
1717 dcd->amextracted = TRUE; // Say busy scanning
1718 disable_menuitem(WinWindowFromID
1719 (WinQueryWindow(hwndMain, QW_PARENT), FID_MENU),
1720 IDM_GREP, TRUE);
1721 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1722 }
1723 }
1724 break;
1725
1726 case IDM_RESORT:
1727 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1728 break;
1729
1730 case IDM_FILTER:
1731 {
1732 BOOL empty = FALSE;
1733 PCNRITEM pci;
1734 CHAR *p;
1735
1736 if (!*dcd->mask.szMask) {
1737 empty = TRUE;
1738 pci = (PCNRITEM) CurrentRecord(hwnd);
1739 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
1740 p = strrchr(pci->szFileName, '\\');
1741 if (p) {
1742 p++;
1743 strcpy(dcd->mask.szMask, p);
1744 }
1745 }
1746 }
1747 *(dcd->mask.prompt) = 0;
1748
1749 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
1750 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
1751 size = sizeof(MASK);
1752 PrfWriteProfileData(fmprof, appname, "CollectorFilter",
1753 &dcd->mask, size);
1754 dcd->suspendview = 1;
1755 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1756 dcd->suspendview = 0;
1757 if (fAutoView && hwndMain) {
1758 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1759 MPFROMLONG(CMA_FIRST),
1760 MPFROMSHORT(CRA_CURSORED));
1761 if (pci && (INT) pci != -1 &&
1762 (!(driveflags[toupper(*pci->szFileName) - 'A'] &
1763 DRIVE_SLOW)))
1764 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->szFileName),
1765 MPVOID);
1766 else
1767 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1768 }
1769 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1770 }
1771 else if (empty)
1772 *dcd->mask.szMask = 0;
1773 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1774 DIR_FILTER), &dcd->mask, FALSE);
1775 }
1776 break;
1777
1778 case IDM_HIDEALL:
1779 if (fAutoView && hwndMain)
1780 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1781 dcd->suspendview = 1;
1782 HideAll(hwnd);
1783 dcd->suspendview = 0;
1784 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1785 break;
1786
1787 case IDM_SELECTLIST:
1788 case IDM_SELECTALL:
1789 case IDM_DESELECTALL:
1790 case IDM_SELECTALLFILES:
1791 case IDM_DESELECTALLFILES:
1792 case IDM_SELECTALLDIRS:
1793 case IDM_DESELECTALLDIRS:
1794 case IDM_SELECTMASK:
1795 case IDM_DESELECTMASK:
1796 case IDM_INVERT:
1797 case IDM_SELECTCLIP:
1798 case IDM_DESELECTCLIP:
1799 {
1800 PCNRITEM pci;
1801
1802 pci = (PCNRITEM) CurrentRecord(hwnd);
1803 if ((INT) pci == -1)
1804 pci = NULL;
1805 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
1806 if (pci) {
1807 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
1808 pci->rc.flRecordAttr |= CRA_FILTERED;
1809 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
1810 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
1811 break;
1812 }
1813 }
1814 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
1815 }
1816 break;
1817
1818 case IDM_RESCAN:
1819 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
1820 break;
1821
1822 case IDM_SHOWLNAMES:
1823 case IDM_SHOWSUBJECT:
1824 case IDM_SHOWEAS:
1825 case IDM_SHOWSIZE:
1826 case IDM_SHOWICON:
1827 case IDM_SHOWLWDATE:
1828 case IDM_SHOWLWTIME:
1829 case IDM_SHOWLADATE:
1830 case IDM_SHOWLATIME:
1831 case IDM_SHOWCRDATE:
1832 case IDM_SHOWCRTIME:
1833 case IDM_SHOWATTR:
1834 AdjustDetailsSwitches(hwnd, dcd->hwndLastMenu,
1835 SHORT1FROMMP(mp1), NULL,
1836 "Collector", dcd, FALSE);
1837 break;
1838
1839 case IDM_ICON:
1840 case IDM_TEXT:
1841 case IDM_DETAILS:
1842 case IDM_NAME:
1843 case IDM_MINIICONS:
1844 case IDM_DETAILSTITLES:
1845 {
1846 CNRINFO cnri;
1847
1848 memset(&cnri, 0, sizeof(CNRINFO));
1849 cnri.cb = sizeof(CNRINFO);
1850 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1851 MPFROMLONG(sizeof(CNRINFO)));
1852 switch (SHORT1FROMMP(mp1)) {
1853 case IDM_ICON:
1854 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1855 CV_DETAIL | CV_NAME));
1856 cnri.flWindowAttr |= CV_ICON;
1857 break;
1858 case IDM_NAME:
1859 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1860 CV_DETAIL | CV_NAME));
1861 cnri.flWindowAttr |= CV_NAME;
1862 break;
1863 case IDM_TEXT:
1864 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1865 CV_DETAIL | CV_NAME));
1866 cnri.flWindowAttr |= CV_TEXT;
1867 break;
1868 case IDM_DETAILS:
1869 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1870 CV_DETAIL | CV_NAME));
1871 cnri.flWindowAttr |= CV_DETAIL;
1872 break;
1873 case IDM_MINIICONS:
1874 if (cnri.flWindowAttr & CV_MINI)
1875 cnri.flWindowAttr &= (~CV_MINI);
1876 else
1877 cnri.flWindowAttr |= CV_MINI;
1878 break;
1879 case IDM_DETAILSTITLES:
1880 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
1881 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
1882 else
1883 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
1884 break;
1885 }
1886 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
1887 cnri.flWindowAttr |= CV_FLOW;
1888 dcd->flWindowAttr = cnri.flWindowAttr;
1889 PrfWriteProfileData(fmprof, appname, "CollectorflWindowAttr",
1890 &cnri.flWindowAttr, sizeof(ULONG));
1891 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1892 MPFROMLONG(CMA_FLWINDOWATTR));
1893 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
1894 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1895 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1896 DIR_VIEW), dcd->flWindowAttr);
1897 }
1898 break;
1899
1900 case IDM_SAVETOLIST:
1901 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
1902 SAV_FRAME, MPFROMP(&hwnd));
1903 break;
1904
1905 case IDM_SIZES:
1906 {
1907 PCNRITEM pci;
1908
1909 pci = (PCNRITEM) CurrentRecord(hwnd);
1910 if (pci && (INT) pci != -1)
1911 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DirSizeProc, FM3ModHandle,
1912 DSZ_FRAME, pci->szFileName);
1913 }
1914 break;
1915
1916 case IDM_MKDIR:
1917 {
1918 PCNRITEM pci;
1919
1920 pci = (PCNRITEM) CurrentRecord(hwnd);
1921 PMMkDir(dcd->hwndParent, (pci && (INT) pci != -1) ?
1922 pci->szFileName : NULL, FALSE);
1923 }
1924 break;
1925
1926 case IDM_DOITYOURSELF:
1927 case IDM_UPDATE:
1928 case IDM_COLLECTFROMFILE:
1929 case IDM_OPENWINDOW:
1930 case IDM_OPENSETTINGS:
1931 case IDM_OPENDEFAULT:
1932 case IDM_OPENICON:
1933 case IDM_OPENDETAILS:
1934 case IDM_OPENTREE:
1935 case IDM_OBJECT:
1936 case IDM_SHADOW:
1937 case IDM_SHADOW2:
1938 case IDM_DELETE:
1939 case IDM_PERMDELETE:
1940 case IDM_PRINT:
1941 case IDM_ATTRS:
1942 case IDM_INFO:
1943 case IDM_COPY:
1944 case IDM_MOVE:
1945 case IDM_WPSCOPY:
1946 case IDM_WPSMOVE:
1947 case IDM_COPYPRESERVE:
1948 case IDM_MOVEPRESERVE:
1949 case IDM_WILDCOPY:
1950 case IDM_WILDMOVE:
1951 case IDM_RENAME:
1952 case IDM_COMPARE:
1953 case IDM_EAS:
1954 case IDM_SUBJECT:
1955 case IDM_VIEW:
1956 case IDM_VIEWTEXT:
1957 case IDM_VIEWBINARY:
1958 case IDM_VIEWARCHIVE:
1959 case IDM_EDIT:
1960 case IDM_EDITTEXT:
1961 case IDM_EDITBINARY:
1962 case IDM_SAVETOCLIP:
1963 case IDM_APPENDTOCLIP:
1964 case IDM_ARCHIVE:
1965 case IDM_ARCHIVEM:
1966 case IDM_EXTRACT:
1967 case IDM_MCIPLAY:
1968 case IDM_UUDECODE:
1969 case IDM_MERGE:
1970 {
1971 LISTINFO *li;
1972 ULONG action = UM_ACTION;
1973
1974 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1975 if (li) {
1976 li->type = SHORT1FROMMP(mp1);
1977 li->hwnd = hwnd;
1978 li->list = BuildList(hwnd);
1979 if (li->list) {
1980 switch (SHORT1FROMMP(mp1)) {
1981 case IDM_DOITYOURSELF:
1982 case IDM_APPENDTOCLIP:
1983 case IDM_SAVETOCLIP:
1984 case IDM_ARCHIVE:
1985 case IDM_ARCHIVEM:
1986 case IDM_DELETE:
1987 case IDM_PERMDELETE:
1988 case IDM_ATTRS:
1989 case IDM_PRINT:
1990 case IDM_SHADOW:
1991 case IDM_SHADOW2:
1992 case IDM_OBJECT:
1993 case IDM_VIEW:
1994 case IDM_VIEWTEXT:
1995 case IDM_VIEWBINARY:
1996 case IDM_EDIT:
1997 case IDM_EDITTEXT:
1998 case IDM_EDITBINARY:
1999 case IDM_MCIPLAY:
2000 case IDM_UPDATE:
2001 case IDM_INFO:
2002 case IDM_EAS:
2003 action = UM_MASSACTION;
2004 break;
2005 }
2006 if (li->type == IDM_SHADOW || li->type == IDM_OBJECT ||
2007 li->type == IDM_SHADOW2)
2008 *li->targetpath = 0;
2009 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2010 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2011 FreeListInfo(li);
2012 }
2013 else if (fUnHilite)
2014 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2015 }
2016 else
2017 free(li);
2018 }
2019 }
2020 break;
2021
2022 default:
2023 if (!cmdloaded)
2024 load_commands();
2025 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2026 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2027 INT x;
2028
2029 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2030 if (x >= 0) {
2031 x++;
2032 RunCommand(hwnd, x);
2033 if (fUnHilite)
2034 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2035 }
2036 }
2037 break;
2038 }
2039 }
2040 return 0;
2041
2042 case UM_FIXCNRMLE:
2043 case UM_FIXEDITNAME:
2044 return CommonCnrProc(hwnd, msg, mp1, mp2);
2045
2046 case UM_FILESMENU:
2047 {
2048 PCNRITEM pci;
2049 HWND menuHwnd = (HWND) 0;
2050
2051 pci = (PCNRITEM) CurrentRecord(hwnd);
2052 if (pci && (INT) pci != -1) {
2053 if (pci->attrFile & FILE_DIRECTORY)
2054 menuHwnd = CheckMenu(&CollectorDirMenu, COLLECTORDIR_POPUP);
2055 else
2056 menuHwnd = CheckMenu(&CollectorFileMenu, COLLECTORFILE_POPUP);
2057 }
2058 return MRFROMLONG(menuHwnd);
2059 }
2060
2061 case WM_CONTROL:
2062 DosError(FERR_DISABLEHARDERR);
2063 if (dcd) {
2064 switch (SHORT2FROMMP(mp1)) {
2065 case CN_CONTEXTMENU:
2066 {
2067 PCNRITEM pci = (PCNRITEM) mp2;
2068
2069 if (pci) {
2070 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
2071 MPFROM2SHORT(TRUE, CRA_CURSORED));
2072 MarkAll(hwnd, FALSE, FALSE, TRUE);
2073 if (pci->attrFile & FILE_DIRECTORY)
2074 dcd->hwndLastMenu = CheckMenu(&CollectorDirMenu,
2075 COLLECTORDIR_POPUP);
2076 else
2077 dcd->hwndLastMenu = CheckMenu(&CollectorFileMenu,
2078 COLLECTORFILE_POPUP);
2079 }
2080 else {
2081 dcd->hwndLastMenu = CheckMenu(&CollectorCnrMenu,
2082 COLLECTORCNR_POPUP);
2083 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2084 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2085 MPFROM2SHORT(TRUE, CRA_SOURCE));
2086 dcd->cnremphasized = TRUE;
2087 }
2088 }
2089 if (dcd->hwndLastMenu) {
2090 if (dcd->hwndLastMenu == CollectorCnrMenu) {
2091 SetViewMenu(dcd->hwndLastMenu, dcd->flWindowAttr);
2092 SetDetailsSwitches(dcd->hwndLastMenu, dcd);
2093 if (dcd->flWindowAttr & CV_MINI)
2094 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2095 disable_menuitem(dcd->hwndLastMenu, DID_CANCEL,
2096 !dcd->amextracted);
2097 disable_menuitem(dcd->hwndLastMenu, IDM_GREP, dcd->amextracted);
2098 }
2099 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2100 if (dcd->cnremphasized) {
2101 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2102 MPFROM2SHORT(FALSE, CRA_SOURCE));
2103 dcd->cnremphasized = TRUE;
2104 }
2105 MarkAll(hwnd, TRUE, FALSE, TRUE);
2106 }
2107 }
2108 }
2109 break;
2110
2111 case CN_DROPHELP:
2112 if (mp2) {
2113 PDRAGINFO pDInfo;
2114 PCNRITEM pci;
2115 ULONG numitems;
2116 USHORT usOperation;
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.