source: trunk/dll/collect.c@ 617

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

Drag drop work around for number of files limitation in PM

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