source: trunk/dll/collect.c@ 551

Last change on this file since 551 was 551, checked in by Gregg Young, 19 years ago

Indentation cleanup

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