source: trunk/dll/collect.c@ 687

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

Add CheckPmDrgLimit function to fix crash when dragging to FM/2 for other apps

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