source: trunk/dll/collect.c@ 775

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

Minor clean up add comments re recent changes

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