source: trunk/dll/collect.c@ 858

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

Removed large file APIs from code where hey are not needed.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 70.9 KB
Line 
1
2/***********************************************************************
3
4 $Id: collect.c 847 2007-09-29 18:45:16Z 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 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
42 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
43
44
45***********************************************************************/
46
47#define INCL_DOS
48#define INCL_WIN
49#define INCL_GPI
50#define INCL_DOSERRORS
51#define INCL_LONGLONG
52#include <os2.h>
53
54#include <stdarg.h>
55#include <stdio.h>
56#include <stdlib.h>
57#include <string.h>
58#include <ctype.h>
59#include <time.h>
60#include <share.h>
61#include <limits.h>
62#include <process.h> // _beginthread
63
64#include "fm3dll.h"
65#include "fm3dlg.h"
66#include "fm3str.h"
67#include "mle.h"
68#include "grep.h"
69
70#pragma data_seg(DATA1)
71
72static PSZ pszSrcFile = __FILE__;
73
74MRESULT EXPENTRY CollectorFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
75 MPARAM mp2)
76{
77 return CommonFrameWndProc(COLLECTOR_CNR, hwnd, msg, mp1, mp2);
78}
79
80MRESULT EXPENTRY CollectorTextProc(HWND hwnd, ULONG msg, MPARAM mp1,
81 MPARAM mp2)
82{
83 DIRCNRDATA *dcd;
84
85 static BOOL emphasized = FALSE;
86 static HWND hwndButtonPopup = (HWND) 0;
87 static ULONG timestamp = ULONG_MAX;
88 static USHORT lastid = 0;
89
90 switch (msg) {
91 case WM_CREATE:
92 return CommonTextProc(hwnd, msg, mp1, mp2);
93
94 case UM_CONTEXTMENU:
95 case WM_CONTEXTMENU:
96 {
97 USHORT id;
98
99 id = WinQueryWindowUShort(hwnd, QWS_ID);
100 switch (id) {
101 case DIR_SELECTED:
102 case DIR_VIEW:
103 case DIR_SORT:
104 {
105 POINTL ptl = { 0, 0 };
106 SWP swp;
107
108 if (hwndButtonPopup)
109 WinDestroyWindow(hwndButtonPopup);
110 if (id == lastid) {
111 ULONG check;
112
113 DosQuerySysInfo(QSV_MS_COUNT,
114 QSV_MS_COUNT, &check, sizeof(check));
115 if (check < timestamp + 500) {
116 lastid = 0;
117 goto MenuAbort;
118 }
119 }
120 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
121 if (hwndButtonPopup) {
122 WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
123 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
124 QW_PARENT),
125 COLLECTOR_CNR), QWL_USER);
126 if (id == DIR_VIEW) {
127 if (dcd) {
128 SetViewMenu(hwndButtonPopup, dcd->flWindowAttr);
129 SetDetailsSwitches(hwndButtonPopup, dcd);
130 }
131
132 /* don't have tree view in collector */
133 WinSendMsg(hwndButtonPopup,
134 MM_DELETEITEM,
135 MPFROM2SHORT(IDM_TREEVIEW, FALSE), MPVOID);
136
137 }
138 else if (id == DIR_SORT) {
139 if (dcd)
140 SetSortChecks(hwndButtonPopup, dcd->sortFlags);
141 }
142 ptl.x = 0;
143 if (WinPopupMenu(HWND_OBJECT,
144 HWND_OBJECT,
145 hwndButtonPopup, -32767, -32767, 0, 0)) {
146 WinQueryWindowPos(hwndButtonPopup, &swp);
147 ptl.y = -(swp.cy + 2);
148 }
149 else {
150 WinQueryWindowPos(hwnd, &swp);
151 ptl.y = swp.cy + 2;
152 }
153 if (WinPopupMenu(hwnd,
154 hwnd,
155 hwndButtonPopup,
156 ptl.x,
157 ptl.y,
158 0,
159 PU_HCONSTRAIN | PU_VCONSTRAIN |
160 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
161 CenterOverWindow(hwndButtonPopup);
162 PaintRecessedWindow(hwnd, NULLHANDLE, FALSE, FALSE);
163 }
164 }
165 }
166 break;
167 default:
168 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
169 COLLECTOR_CNR),
170 WM_CONTROL,
171 MPFROM2SHORT(COLLECTOR_CNR, CN_CONTEXTMENU), MPVOID);
172 break;
173 }
174 }
175 MenuAbort:
176 if (msg == UM_CONTEXTMENU)
177 return 0;
178 break;
179
180 case WM_MENUEND:
181 if (hwndButtonPopup == (HWND) mp2) {
182 lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
183 WinDestroyWindow(hwndButtonPopup);
184 hwndButtonPopup = (HWND) 0;
185 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &timestamp,
186 sizeof(timestamp));
187 switch (lastid) {
188 case DIR_SELECTED:
189 case DIR_VIEW:
190 case DIR_SORT:
191 PaintRecessedWindow(hwnd, NULLHANDLE, TRUE, FALSE);
192 break;
193 }
194 }
195 break;
196
197 case WM_COMMAND:
198 {
199 DIRCNRDATA *dcd;
200 MRESULT mr;
201
202 mr = WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,
203 QW_PARENT),
204 COLLECTOR_CNR), msg, mp1, mp2);
205 if (hwndButtonPopup &&
206 SHORT1FROMMP(mp1) > IDM_DETAILSTITLES &&
207 SHORT1FROMMP(mp1) < IDM_DETAILSSETUP) {
208 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
209 QW_PARENT),
210 COLLECTOR_CNR), QWL_USER);
211 if (dcd)
212 SetDetailsSwitches(hwndButtonPopup, dcd);
213 }
214 return mr;
215 }
216
217 case WM_MOUSEMOVE:
218 {
219 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
220 char *s = NULL;
221
222 if (fOtherHelp) {
223 if ((!hwndBubble ||
224 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
225 !WinQueryCapture(HWND_DESKTOP)) {
226 switch (id) {
227 case DIR_SELECTED:
228 s = GetPString(IDS_COLSELECTEDHELP);
229 break;
230 case DIR_TOTALS:
231 s = GetPString(IDS_COLTOTALSHELP);
232 break;
233 case DIR_VIEW:
234 s = GetPString(IDS_DIRCNRVIEWHELP);
235 break;
236 case DIR_SORT:
237 s = GetPString(IDS_DIRCNRSORTHELP);
238 break;
239 case DIR_FILTER:
240 s = GetPString(IDS_DIRCNRFILTERHELP);
241 break;
242 default:
243 break;
244 }
245 if (s)
246 MakeBubble(hwnd, TRUE, s);
247 else if (hwndBubble)
248 WinDestroyWindow(hwndBubble);
249 }
250 }
251 switch (id) {
252 case DIR_FILTER:
253 case DIR_SORT:
254 case DIR_VIEW:
255 case DIR_SELECTED:
256 return CommonTextButton(hwnd, msg, mp1, mp2);
257 }
258 }
259 break;
260
261 case WM_BUTTON3UP:
262 case WM_BUTTON1UP:
263 case WM_BUTTON3DOWN:
264 case WM_BUTTON1DOWN:
265 {
266 USHORT id;
267
268 id = WinQueryWindowUShort(hwnd, QWS_ID);
269 switch (id) {
270 case DIR_FILTER:
271 case DIR_SORT:
272 case DIR_VIEW:
273 case DIR_SELECTED:
274 return CommonTextButton(hwnd, msg, mp1, mp2);
275 }
276 }
277 break;
278
279 case UM_CLICKED:
280 case UM_CLICKED3:
281 {
282 USHORT id, cmd = 0;
283
284 id = WinQueryWindowUShort(hwnd, QWS_ID);
285 switch (id) {
286 case DIR_VIEW:
287 case DIR_SORT:
288 case DIR_SELECTED:
289 PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
290 break;
291 case DIR_FILTER:
292 cmd = IDM_FILTER;
293 break;
294 default:
295 break;
296 }
297 if (cmd)
298 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
299 COLLECTOR_CNR),
300 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
301 }
302 return 0;
303
304 case DM_DROP:
305 case DM_DRAGOVER:
306 case DM_DRAGLEAVE:
307 case DM_DROPHELP:
308 if (msg == DM_DRAGOVER) {
309 if (!emphasized) {
310 emphasized = TRUE;
311 DrawTargetEmphasis(hwnd, emphasized);
312 }
313 }
314 else {
315 if (emphasized) {
316 emphasized = FALSE;
317 DrawTargetEmphasis(hwnd, emphasized);
318 }
319 }
320 {
321 CNRDRAGINFO cnd;
322 USHORT dcmd;
323
324 switch (msg) {
325 case DM_DROP:
326 dcmd = CN_DROP;
327 break;
328 case DM_DRAGOVER:
329 dcmd = CN_DRAGOVER;
330 break;
331 case DM_DRAGLEAVE:
332 dcmd = CN_DRAGLEAVE;
333 break;
334 case DM_DROPHELP:
335 dcmd = CN_DROPHELP;
336 break;
337 }
338 memset(&cnd, 0, sizeof(cnd));
339 cnd.pDragInfo = (PDRAGINFO) mp1;
340 cnd.pRecord = NULL;
341 return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_CONTROL,
342 MPFROM2SHORT(COLLECTOR_CNR, dcmd), MPFROMP(&cnd));
343 }
344 }
345 return PFNWPStatic(hwnd, msg, mp1, mp2);
346}
347
348MRESULT EXPENTRY CollectorClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
349 MPARAM mp2)
350{
351 switch (msg) {
352 case UM_CONTAINERHWND:
353 return MRFROMLONG(WinWindowFromID(hwnd, COLLECTOR_CNR));
354
355 case UM_VIEWSMENU:
356 return MRFROMLONG(CheckMenu(&CollectorCnrMenu, COLLECTORCNR_POPUP));
357
358 case MM_PORTHOLEINIT:
359 case WM_INITMENU:
360 case UM_INITMENU:
361 case UM_CONTAINER_FILLED:
362 case UM_FILESMENU:
363 case UM_UPDATERECORD:
364 case UM_UPDATERECORDLIST:
365 return WinSendMsg(WinWindowFromID(hwnd, COLLECTOR_CNR), msg, mp1, mp2);
366
367 case WM_PSETFOCUS:
368 case WM_SETFOCUS:
369 if (mp2)
370 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
371 break;
372
373 case UM_FOCUSME:
374 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, COLLECTOR_CNR));
375 break;
376
377 case WM_PAINT:
378 {
379 HPS hps;
380 RECTL rcl;
381
382 hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
383 if (hps) {
384 WinQueryWindowRect(hwnd, &rcl);
385 WinFillRect(hps, &rcl, CLR_PALEGRAY);
386 CommonTextPaint(hwnd, hps);
387 WinEndPaint(hps);
388 }
389 }
390 break;
391
392 case UM_SIZE:
393 case WM_SIZE:
394 if (msg == UM_SIZE) {
395 SWP swp;
396
397 WinQueryWindowPos(hwnd, &swp);
398 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
399 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
400 }
401 {
402 USHORT cx, cy, bx;
403
404 cx = SHORT1FROMMP(mp2);
405 cy = SHORT2FROMMP(mp2);
406 WinSetWindowPos(WinWindowFromID(hwnd, COLLECTOR_CNR), HWND_TOP,
407 0, 0, cx, cy - 24, SWP_SHOW | SWP_MOVE | SWP_SIZE);
408 WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
409 2,
410 cy - 22,
411 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
412 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
413 2 + (cx / 3) + 2,
414 cy - 22,
415 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
416 bx = (cx - (2 + (((cx / 3) + 2) * 2))) / 3;
417 WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
418 2 + (((cx / 3) + 2) * 2),
419 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
420 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
421 2 + (((cx / 3) + 2) * 2) + bx,
422 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
423 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
424 2 + (((cx / 3) + 2) * 2) + (bx * 2),
425 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
426 }
427 CommonTextPaint(hwnd, NULLHANDLE);
428 if (msg == UM_SIZE) {
429 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
430 SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
431 return 0;
432 }
433 break;
434
435 case UM_COMMAND:
436 case WM_COMMAND:
437 case WM_CONTROL:
438 case WM_CLOSE:
439 return WinSendMsg(WinWindowFromID(hwnd, COLLECTOR_CNR), msg, mp1, mp2);
440 }
441 return WinDefWindowProc(hwnd, msg, mp1, mp2);
442}
443
444MRESULT EXPENTRY CollectorObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
445 MPARAM mp2)
446{
447 ULONG size;
448 DIRCNRDATA *dcd;
449
450 switch (msg) {
451 case WM_CREATE:
452 break;
453
454 case DM_PRINTOBJECT:
455 return MRFROMLONG(DRR_TARGET);
456
457 case DM_DISCARDOBJECT:
458 dcd = INSTDATA(hwnd);
459 if (fFM2Deletes && dcd) {
460 LISTINFO *li;
461 CNRDRAGINFO cni;
462
463 cni.pRecord = NULL;
464 cni.pDragInfo = (PDRAGINFO) mp1;
465 li = DoFileDrop(dcd->hwndCnr, NULL, FALSE, MPVOID, MPFROMP(&cni));
466 CheckPmDrgLimit(cni.pDragInfo);
467 if (li) {
468 li->type = fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE;
469 if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
470 FreeListInfo(li);
471 else
472 return MRFROMLONG(DRR_SOURCE);
473 }
474 }
475 return MRFROMLONG(DRR_TARGET);
476
477 case UM_UPDATERECORDLIST:
478 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
479 if (dcd && mp1) {
480 INT numentries = 0;
481 CHAR **list = (CHAR **) mp1;
482
483 while (list[numentries])
484 numentries++;
485 if (numentries)
486 UpdateCnrList(dcd->hwndCnr, list, numentries, FALSE, dcd);
487 }
488 return 0;
489
490 case UM_SETUP:
491 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
492 if (dcd) {
493 /* set unique id */
494 WinSetWindowUShort(hwnd,
495 QWS_ID,
496 COLLECTOROBJ_FRAME + (COLLECTOR_FRAME - dcd->id));
497 dcd->hwndObject = hwnd;
498 if (ParentIsDesktop(hwnd, dcd->hwndParent))
499 DosSleep(100); //05 Aug 07 GKY 250
500 }
501 else
502 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
503 return 0;
504
505 case UM_COMMAND:
506 if (mp1) {
507 LISTINFO *li = (LISTINFO *) mp1;
508
509 switch (li->type) {
510 case IDM_DOITYOURSELF:
511 case IDM_APPENDTOCLIP:
512 case IDM_SAVETOCLIP:
513 case IDM_ARCHIVE:
514 case IDM_ARCHIVEM:
515 case IDM_VIEW:
516 case IDM_VIEWTEXT:
517 case IDM_VIEWBINARY:
518 case IDM_VIEWARCHIVE:
519 case IDM_EDIT:
520 case IDM_EDITTEXT:
521 case IDM_EDITBINARY:
522 case IDM_OBJECT:
523 case IDM_SHADOW:
524 case IDM_SHADOW2:
525 case IDM_PRINT:
526 case IDM_ATTRS:
527 case IDM_DELETE:
528 case IDM_PERMDELETE:
529 case IDM_FAKEEXTRACT:
530 case IDM_FAKEEXTRACTM:
531 case IDM_MCIPLAY:
532 case IDM_UPDATE:
533 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
534 return (MRESULT) TRUE;
535 break;
536 default:
537 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
538 return (MRESULT) TRUE;
539 }
540 }
541 return 0;
542
543 case UM_COLLECT:
544 DosError(FERR_DISABLEHARDERR);
545 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
546 if (dcd) {
547 LISTINFO *li = (LISTINFO *) mp1;
548 INT x;
549 FILEFINDBUF4L fb4;
550 HDIR hdir;
551 ULONG nm;
552 PCNRITEM pci, pciFirst, pciT, pciP = NULL;
553 RECORDINSERT ri;
554 ULONG ulMaxFiles;
555 ULONGLONG ullTotalBytes;
556 CHAR fullname[CCHMAXPATH];
557
558 WinSetWindowText(WinWindowFromID(dcd->hwndClient, DIR_SELECTED),
559 GetPString(IDS_COLLECTINGTEXT));
560 for (ulMaxFiles = 0; li->list[ulMaxFiles]; ulMaxFiles++) ; // Count
561
562 if (ulMaxFiles) {
563 pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD,
564 MPFROMLONG(EXTRA_RECORD_BYTES),
565 MPFROMLONG(ulMaxFiles));
566 if (!pci) {
567 Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
568 ulMaxFiles);
569 break;
570 }
571 else {
572 pciFirst = pci;
573 for (x = 0; li->list[x]; x++) {
574 nm = 1;
575 hdir = HDIR_CREATE;
576 DosError(FERR_DISABLEHARDERR);
577 if (*li->list[x] &&
578 !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
579 fullname, sizeof(fullname)) &&
580 !IsRoot(fullname) &&
581 !FindCnrRecord(dcd->hwndCnr,
582 fullname,
583 NULL,
584 FALSE,
585 FALSE,
586 TRUE) &&
587 !xDosFindFirst(fullname,
588 &hdir,
589 FILE_NORMAL | FILE_DIRECTORY |
590 FILE_ARCHIVED | FILE_SYSTEM |
591 FILE_HIDDEN | FILE_READONLY,
592 &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL)) {
593 DosFindClose(hdir);
594 priority_normal();
595 *fb4.achName = 0;
596 ullTotalBytes = FillInRecordFromFFB(dcd->hwndCnr,
597 pci,
598 fullname, &fb4, FALSE, dcd);
599 dcd->ullTotalBytes += ullTotalBytes;
600 pciP = pci;
601 pci = (PCNRITEM) pci->rc.preccNextRecord;
602 }
603 else {
604 pciT = pci;
605 pci = (PCNRITEM) pci->rc.preccNextRecord;
606 if (pciP)
607 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
608 else
609 pciFirst = pci;
610 FreeCnrItem(hwnd, pciT);
611 ulMaxFiles--;
612 }
613 DosSleep(0); //26 Aug 07 GKY 1
614 }
615 if (ulMaxFiles) {
616 memset(&ri, 0, sizeof(RECORDINSERT));
617 ri.cb = sizeof(RECORDINSERT);
618 ri.pRecordOrder = (PRECORDCORE) CMA_END;
619 ri.pRecordParent = (PRECORDCORE) 0;
620 ri.zOrder = (ULONG) CMA_TOP;
621 ri.cRecordsInsert = ulMaxFiles;
622 ri.fInvalidateRecord = TRUE;
623 WinSendMsg(dcd->hwndCnr,
624 CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
625 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
626 }
627 }
628 }
629 }
630 if (dcd->flWindowAttr & CV_DETAIL)
631 WinSendDlgItemMsg(hwnd,
632 COLLECTOR_CNR,
633 CM_INVALIDATERECORD,
634 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
635 return 0;
636
637 case UM_COLLECTFROMFILE:
638 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
639 if (dcd && mp1) {
640 FILESTATUS4L fs4;
641 PCNRITEM pci;
642 RECORDINSERT ri;
643 CHAR fullname[1024], *p;
644 FILE *fp;
645 ULONG errs = 0;
646 BOOL first = FALSE;
647 size_t c;
648
649 fp = _fsopen((CHAR *) mp1, "r", SH_DENYNO);
650 if (fp) {
651 while (!feof(fp)) {
652 // Avoid too much noise if collecting from binary file - oops
653 if (!fgets(fullname, sizeof(fullname), fp)) {
654 if (ferror(fp))
655 Runtime_Error(pszSrcFile, __LINE__, "fgets");
656 break;
657 }
658
659 c = strlen(fullname);
660 if (c + 1 >= sizeof(fullname))
661 errs++;
662 else if (!c || (fullname[c - 1] != '\n' && fullname[c - 1] != '\r'))
663 errs++;
664 else {
665 bstripcr(fullname);
666
667 if (*fullname == '\"') {
668 memmove(fullname, fullname + 1, strlen(fullname) + 1);
669 lstrip(fullname);
670 p = strchr(fullname, '\"');
671 if (p)
672 *p = 0;
673 rstrip(fullname);
674 }
675 else {
676 p = strchr(fullname, ' ');
677 if (p)
678 *p = 0;
679 }
680 /* fullname now contains name of file to collect */
681 DosError(FERR_DISABLEHARDERR);
682 if (IsFullName(fullname) &&
683 !IsRoot(fullname) &&
684 !DosQueryPathInfo(fullname,
685 FIL_QUERYEASIZEL,
686 &fs4,
687 sizeof(fs4)) &&
688 !FindCnrRecord(dcd->hwndCnr,
689 fullname, NULL, FALSE, FALSE, TRUE)) {
690 /* collect it */
691 pci = WinSendMsg(dcd->hwndCnr,
692 CM_ALLOCRECORD,
693 MPFROMLONG(EXTRA_RECORD_BYTES),
694 MPFROMLONG(1));
695 if (pci) {
696 dcd->ullTotalBytes += FillInRecordFromFSA(dcd->hwndCnr, pci,
697 fullname,
698 &fs4, FALSE, dcd);
699 memset(&ri, 0, sizeof(RECORDINSERT));
700 ri.cb = sizeof(RECORDINSERT);
701 ri.pRecordOrder = (PRECORDCORE) CMA_END;
702 ri.pRecordParent = (PRECORDCORE) 0;
703 ri.zOrder = (ULONG) CMA_TOP;
704 ri.cRecordsInsert = 1;
705 ri.fInvalidateRecord = TRUE;
706 WinSendMsg(dcd->hwndCnr, CM_INSERTRECORD,
707 MPFROMP(pci), MPFROMP(&ri));
708 }
709 }
710 else
711 errs++;
712 }
713 if (errs > (first ? 0 : 50)) {
714 /* prevent runaway on bad file */
715 APIRET ret = saymsg(MB_YESNO, dcd->hwndCnr,
716 GetPString(IDS_COLLECTNOLISTHDRTEXT),
717 GetPString(IDS_COLLECTNOLISTTEXT),
718 (CHAR *) mp1);
719
720 if (ret == MBID_NO)
721 break;
722 if (!first)
723 errs = 0;
724 else
725 first = FALSE;
726 }
727 } // while not eof
728 fclose(fp);
729 }
730 }
731 xfree(mp1);
732 return 0;
733
734 case UM_SELECT:
735 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
736 if (dcd) {
737 switch (SHORT1FROMMP(mp1)) {
738 case IDM_SELECTLIST:
739 {
740 CHAR filename[CCHMAXPATH], *p, *pp;
741
742 strcpy(filename, "*.LST");
743 size = CCHMAXPATH;
744 PrfQueryProfileData(fmprof, appname, "SaveToListName", filename,
745 &size);
746 pp = strrchr(filename, '\\');
747 if (!pp)
748 pp = filename;
749 p = strrchr(pp, '.');
750 if (p && *(p + 1) && p > pp + 1) {
751 if (pp > filename)
752 pp++;
753 *pp = '*';
754 pp++;
755 if (p > pp)
756 memmove(pp, p, strlen(p) + 1);
757 }
758 if (insert_filename(hwnd, filename, FALSE, FALSE))
759 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
760 NULL);
761 }
762 break;
763 case IDM_SELECTALL:
764 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
765 break;
766 case IDM_DESELECTALL:
767 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
768 break;
769 case IDM_SELECTALLFILES:
770 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
771 break;
772 case IDM_DESELECTALLFILES:
773 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
774 break;
775 case IDM_SELECTALLDIRS:
776 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
777 break;
778 case IDM_DESELECTALLDIRS:
779 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
780 break;
781 case IDM_DESELECTMASK:
782 case IDM_SELECTMASK:
783 {
784 MASK mask;
785 PCNRITEM pci = (PCNRITEM) mp2;
786
787 memset(&mask, 0, sizeof(MASK));
788 mask.fNoAttribs = TRUE;
789 mask.fNoDirs = TRUE;
790 mask.fText = TRUE;
791 strcpy(mask.prompt,
792 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
793 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
794 if (pci && (INT) pci != -1)
795 strcpy(mask.szMask, pci->pszFileName);
796 if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
797 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
798 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
799 SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
800 FALSE);
801 else
802 DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
803 FALSE);
804 }
805 }
806
807 case IDM_DESELECTCLIP:
808 case IDM_SELECTCLIP:
809 {
810 CHAR **list;
811
812 list = ListFromClipboard(hwnd);
813 if (list) {
814 SelectList(dcd->hwndCnr, TRUE, FALSE,
815 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
816 NULL, NULL, list);
817 FreeList(list);
818 }
819 }
820 break;
821
822 case IDM_INVERT:
823 InvertAll(dcd->hwndCnr);
824 break;
825 }
826 }
827 return 0;
828
829 case UM_MASSACTION:
830 if (mp1) {
831 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
832 if (dcd) {
833 WORKER *wk;
834
835 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
836 if (!wk)
837 FreeListInfo((LISTINFO *) mp1);
838 else {
839 wk->size = sizeof(WORKER);
840 wk->hwndCnr = dcd->hwndCnr;
841 wk->hwndParent = dcd->hwndParent;
842 wk->hwndFrame = dcd->hwndFrame;
843 wk->hwndClient = dcd->hwndClient;
844 wk->li = (LISTINFO *) mp1;
845 strcpy(wk->directory, dcd->directory);
846 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
847 Runtime_Error(pszSrcFile, __LINE__,
848 GetPString(IDS_COULDNTSTARTTHREADTEXT));
849 free(wk);
850 FreeListInfo((LISTINFO *) mp1);
851 }
852 }
853 }
854 }
855 return 0;
856
857 case UM_ACTION:
858 if (mp1) {
859 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
860 if (dcd) {
861 WORKER *wk;
862
863 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
864 if (!wk)
865 FreeListInfo((LISTINFO *) mp1);
866 else {
867 wk->size = sizeof(WORKER);
868 wk->hwndCnr = dcd->hwndCnr;
869 wk->hwndParent = dcd->hwndParent;
870 wk->hwndFrame = dcd->hwndFrame;
871 wk->hwndClient = dcd->hwndClient;
872 wk->li = (LISTINFO *) mp1;
873 strcpy(wk->directory, dcd->directory);
874 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
875 Runtime_Error(pszSrcFile, __LINE__,
876 GetPString(IDS_COULDNTSTARTTHREADTEXT));
877 free(wk);
878 FreeListInfo((LISTINFO *) mp1);
879 }
880 }
881 }
882 }
883 return 0;
884
885 case WM_CLOSE:
886 WinDestroyWindow(hwnd);
887 break;
888
889 case WM_DESTROY:
890 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
891 if (dcd) {
892 INT x;
893
894 dcd->stopflag = 1;
895 // Allow rescan logic to quiesce
896 for (x = 0; x < 10 && dcd->amextracted; x++)
897 DosSleep(100); //05 Aug 07 GKY 250
898 WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
899 FreeList(dcd->lastselection);
900 free(dcd);
901 }
902 DosPostEventSem(CompactSem);
903 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
904 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
905 break;
906 }
907 return WinDefWindowProc(hwnd, msg, mp1, mp2);
908}
909
910MRESULT EXPENTRY CollectorCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
911 MPARAM mp2)
912{
913 DIRCNRDATA *dcd = INSTDATA(hwnd);
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->pszFileName) - 'A'] & DRIVE_SLOW)))
1086 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), 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->pszFileName), 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->pszFileName, '\\');
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 = 12;
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(32); //05 Aug 07 GKY 64
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->pszFileName);
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->pszFileName);
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 RemoveCnrItems(hwnd, NULL, 0, CMA_FREE | CMA_INVALIDATE);
1660 dcd->ullTotalBytes = dcd->selectedbytes = dcd->selectedfiles =
1661 dcd->totalfiles = 0;
1662 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1663 }
1664 }
1665 break;
1666
1667 case DID_CANCEL:
1668 if (dcd->amextracted)
1669 dcd->stopflag = 1; // Request cancel
1670 break;
1671
1672 case IDM_COLLECTOR:
1673 if (mp2) {
1674 LISTINFO *li;
1675
1676 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1677 if (li) {
1678 li->list = mp2;
1679 if (!li->list || !li->list[0])
1680 FreeListInfo(li);
1681 else {
1682 li->type = IDM_COLLECT;
1683 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1684 FreeListInfo(li);
1685 }
1686 }
1687 else
1688 FreeList(mp2);
1689 }
1690 break;
1691
1692 case IDM_UNDELETE:
1693 {
1694 PCNRITEM pci;
1695 CHAR path[CCHMAXPATH];
1696
1697 pci = (PCNRITEM) CurrentRecord(hwnd);
1698 if (pci) {
1699 strcpy(path, pci->pszFileName);
1700 MakeValidDir(path);
1701 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
1702 UNDEL_FRAME, MPFROMP(path));
1703 }
1704 }
1705 break;
1706
1707 case IDM_GREP:
1708 if (dcd->amextracted) {
1709 saymsg(MB_OK | MB_ICONASTERISK,
1710 hwnd,
1711 GetPString(IDS_WARNINGTEXT),
1712 "Collector busy - please try again later");
1713 }
1714 else {
1715 if (WinDlgBox(HWND_DESKTOP, hwnd, GrepDlgProc,
1716 FM3ModHandle, GREP_FRAME, (PVOID) & hwnd)) {
1717 dcd->amextracted = TRUE; // Say busy scanning
1718 disable_menuitem(WinWindowFromID
1719 (WinQueryWindow(hwndMain, QW_PARENT), FID_MENU),
1720 IDM_GREP, TRUE);
1721 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1722 }
1723 }
1724 break;
1725
1726 case IDM_RESORT:
1727 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1728 break;
1729
1730 case IDM_FILTER:
1731 {
1732 BOOL empty = FALSE;
1733 PCNRITEM pci;
1734 CHAR *p;
1735
1736 if (!*dcd->mask.szMask) {
1737 empty = TRUE;
1738 pci = (PCNRITEM) CurrentRecord(hwnd);
1739 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
1740 p = strrchr(pci->pszFileName, '\\');
1741 if (p) {
1742 p++;
1743 strcpy(dcd->mask.szMask, p);
1744 }
1745 }
1746 }
1747 *(dcd->mask.prompt) = 0;
1748
1749 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
1750 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
1751 size = sizeof(MASK);
1752 PrfWriteProfileData(fmprof, appname, "CollectorFilter",
1753 &dcd->mask, size);
1754 dcd->suspendview = 1;
1755 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1756 dcd->suspendview = 0;
1757 if (fAutoView && hwndMain) {
1758 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1759 MPFROMLONG(CMA_FIRST),
1760 MPFROMSHORT(CRA_CURSORED));
1761 if (pci && (INT) pci != -1 &&
1762 (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
1763 DRIVE_SLOW)))
1764 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName),
1765 MPVOID);
1766 else
1767 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1768 }
1769 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1770 }
1771 else if (empty)
1772 *dcd->mask.szMask = 0;
1773 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1774 DIR_FILTER), &dcd->mask, FALSE);
1775 }
1776 break;
1777
1778 case IDM_HIDEALL:
1779 if (fAutoView && hwndMain)
1780 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1781 dcd->suspendview = 1;
1782 HideAll(hwnd);
1783 dcd->suspendview = 0;
1784 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1785 break;
1786
1787 case IDM_SELECTLIST:
1788 case IDM_SELECTALL:
1789 case IDM_DESELECTALL:
1790 case IDM_SELECTALLFILES:
1791 case IDM_DESELECTALLFILES:
1792 case IDM_SELECTALLDIRS:
1793 case IDM_DESELECTALLDIRS:
1794 case IDM_SELECTMASK:
1795 case IDM_DESELECTMASK:
1796 case IDM_INVERT:
1797 case IDM_SELECTCLIP:
1798 case IDM_DESELECTCLIP:
1799 {
1800 PCNRITEM pci;
1801
1802 pci = (PCNRITEM) CurrentRecord(hwnd);
1803 if ((INT) pci == -1)
1804 pci = NULL;
1805 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
1806 if (pci) {
1807 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
1808 pci->rc.flRecordAttr |= CRA_FILTERED;
1809 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
1810 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
1811 break;
1812 }
1813 }
1814 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
1815 }
1816 break;
1817
1818 case IDM_RESCAN:
1819 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
1820 break;
1821
1822 case IDM_SHOWLNAMES:
1823 case IDM_SHOWSUBJECT:
1824 case IDM_SHOWEAS:
1825 case IDM_SHOWSIZE:
1826 case IDM_SHOWICON:
1827 case IDM_SHOWLWDATE:
1828 case IDM_SHOWLWTIME:
1829 case IDM_SHOWLADATE:
1830 case IDM_SHOWLATIME:
1831 case IDM_SHOWCRDATE:
1832 case IDM_SHOWCRTIME:
1833 case IDM_SHOWATTR:
1834 AdjustDetailsSwitches(hwnd, dcd->hwndLastMenu,
1835 SHORT1FROMMP(mp1), NULL,
1836 "Collector", dcd, FALSE);
1837 break;
1838
1839 case IDM_ICON:
1840 case IDM_TEXT:
1841 case IDM_DETAILS:
1842 case IDM_NAME:
1843 case IDM_MINIICONS:
1844 case IDM_DETAILSTITLES:
1845 {
1846 CNRINFO cnri;
1847
1848 memset(&cnri, 0, sizeof(CNRINFO));
1849 cnri.cb = sizeof(CNRINFO);
1850 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1851 MPFROMLONG(sizeof(CNRINFO)));
1852 switch (SHORT1FROMMP(mp1)) {
1853 case IDM_ICON:
1854 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1855 CV_DETAIL | CV_NAME));
1856 cnri.flWindowAttr |= CV_ICON;
1857 break;
1858 case IDM_NAME:
1859 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1860 CV_DETAIL | CV_NAME));
1861 cnri.flWindowAttr |= CV_NAME;
1862 break;
1863 case IDM_TEXT:
1864 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1865 CV_DETAIL | CV_NAME));
1866 cnri.flWindowAttr |= CV_TEXT;
1867 break;
1868 case IDM_DETAILS:
1869 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1870 CV_DETAIL | CV_NAME));
1871 cnri.flWindowAttr |= CV_DETAIL;
1872 break;
1873 case IDM_MINIICONS:
1874 if (cnri.flWindowAttr & CV_MINI)
1875 cnri.flWindowAttr &= (~CV_MINI);
1876 else
1877 cnri.flWindowAttr |= CV_MINI;
1878 break;
1879 case IDM_DETAILSTITLES:
1880 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
1881 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
1882 else
1883 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
1884 break;
1885 }
1886 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
1887 cnri.flWindowAttr |= CV_FLOW;
1888 dcd->flWindowAttr = cnri.flWindowAttr;
1889 PrfWriteProfileData(fmprof, appname, "CollectorflWindowAttr",
1890 &cnri.flWindowAttr, sizeof(ULONG));
1891 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1892 MPFROMLONG(CMA_FLWINDOWATTR));
1893 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
1894 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1895 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1896 DIR_VIEW), dcd->flWindowAttr);
1897 }
1898 break;
1899
1900 case IDM_SAVETOLIST:
1901 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
1902 SAV_FRAME, MPFROMP(&hwnd));
1903 break;
1904
1905 case IDM_SIZES:
1906 {
1907 PCNRITEM pci;
1908
1909 pci = (PCNRITEM) CurrentRecord(hwnd);
1910 if (pci && (INT) pci != -1)
1911 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DirSizeProc, FM3ModHandle,
1912 DSZ_FRAME, pci->pszFileName);
1913 }
1914 break;
1915
1916 case IDM_MKDIR:
1917 {
1918 PCNRITEM pci;
1919
1920 pci = (PCNRITEM) CurrentRecord(hwnd);
1921 PMMkDir(dcd->hwndParent, (pci && (INT) pci != -1) ?
1922 pci->pszFileName : NULL, FALSE);
1923 }
1924 break;
1925
1926 case IDM_DOITYOURSELF:
1927 case IDM_UPDATE:
1928 case IDM_COLLECTFROMFILE:
1929 case IDM_OPENWINDOW:
1930 case IDM_OPENSETTINGS:
1931 case IDM_OPENDEFAULT:
1932 case IDM_OPENICON:
1933 case IDM_OPENDETAILS:
1934 case IDM_OPENTREE:
1935 case IDM_OBJECT:
1936 case IDM_SHADOW:
1937 case IDM_SHADOW2:
1938 case IDM_DELETE:
1939 case IDM_PERMDELETE:
1940 case IDM_PRINT:
1941 case IDM_ATTRS:
1942 case IDM_INFO:
1943 case IDM_COPY:
1944 case IDM_MOVE:
1945 case IDM_WPSCOPY:
1946 case IDM_WPSMOVE:
1947 case IDM_COPYPRESERVE:
1948 case IDM_MOVEPRESERVE:
1949 case IDM_WILDCOPY:
1950 case IDM_WILDMOVE:
1951 case IDM_RENAME:
1952 case IDM_COMPARE:
1953 case IDM_EAS:
1954 case IDM_SUBJECT:
1955 case IDM_VIEW:
1956 case IDM_VIEWTEXT:
1957 case IDM_VIEWBINARY:
1958 case IDM_VIEWARCHIVE:
1959 case IDM_EDIT:
1960 case IDM_EDITTEXT:
1961 case IDM_EDITBINARY:
1962 case IDM_SAVETOCLIP:
1963 case IDM_APPENDTOCLIP:
1964 case IDM_ARCHIVE:
1965 case IDM_ARCHIVEM:
1966 case IDM_EXTRACT:
1967 case IDM_MCIPLAY:
1968 case IDM_UUDECODE:
1969 case IDM_MERGE:
1970 {
1971 LISTINFO *li;
1972 ULONG action = UM_ACTION;
1973
1974 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1975 if (li) {
1976 li->type = SHORT1FROMMP(mp1);
1977 li->hwnd = hwnd;
1978 li->list = BuildList(hwnd);
1979 if (li->list) {
1980 switch (SHORT1FROMMP(mp1)) {
1981 case IDM_DOITYOURSELF:
1982 case IDM_APPENDTOCLIP:
1983 case IDM_SAVETOCLIP:
1984 case IDM_ARCHIVE:
1985 case IDM_ARCHIVEM:
1986 case IDM_DELETE:
1987 case IDM_PERMDELETE:
1988 case IDM_ATTRS:
1989 case IDM_PRINT:
1990 case IDM_SHADOW:
1991 case IDM_SHADOW2:
1992 case IDM_OBJECT:
1993 case IDM_VIEW:
1994 case IDM_VIEWTEXT:
1995 case IDM_VIEWBINARY:
1996 case IDM_EDIT:
1997 case IDM_EDITTEXT:
1998 case IDM_EDITBINARY:
1999 case IDM_MCIPLAY:
2000 case IDM_UPDATE:
2001 case IDM_INFO:
2002 case IDM_EAS:
2003 action = UM_MASSACTION;
2004 break;
2005 }
2006 if (li->type == IDM_SHADOW || li->type == IDM_OBJECT ||
2007 li->type == IDM_SHADOW2)
2008 *li->targetpath = 0;
2009 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2010 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2011 FreeListInfo(li);
2012 }
2013 else if (fUnHilite)
2014 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2015 }
2016 else
2017 free(li);
2018 }
2019 }
2020 break;
2021
2022 default:
2023 if (!cmdloaded)
2024 load_commands();
2025 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2026 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2027 INT x;
2028
2029 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2030 if (x >= 0) {
2031 x++;
2032 RunCommand(hwnd, x);
2033 if (fUnHilite)
2034 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2035 }
2036 }
2037 break;
2038 }
2039 }
2040 return 0;
2041
2042 case UM_FIXCNRMLE:
2043 case UM_FIXEDITNAME:
2044 return CommonCnrProc(hwnd, msg, mp1, mp2);
2045
2046 case UM_FILESMENU:
2047 {
2048 PCNRITEM pci;
2049 HWND menuHwnd = (HWND) 0;
2050
2051 pci = (PCNRITEM) CurrentRecord(hwnd);
2052 if (pci && (INT) pci != -1) {
2053 if (pci->attrFile & FILE_DIRECTORY)
2054 menuHwnd = CheckMenu(&CollectorDirMenu, COLLECTORDIR_POPUP);
2055 else
2056 menuHwnd = CheckMenu(&CollectorFileMenu, COLLECTORFILE_POPUP);
2057 }
2058 return MRFROMLONG(menuHwnd);
2059 }
2060
2061 case WM_CONTROL:
2062 DosError(FERR_DISABLEHARDERR);
2063 if (dcd) {
2064 switch (SHORT2FROMMP(mp1)) {
2065 case CN_CONTEXTMENU:
2066 {
2067 PCNRITEM pci = (PCNRITEM) mp2;
2068
2069 if (pci) {
2070 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
2071 MPFROM2SHORT(TRUE, CRA_CURSORED));
2072 MarkAll(hwnd, FALSE, FALSE, TRUE);
2073 if (pci->attrFile & FILE_DIRECTORY)
2074 dcd->hwndLastMenu = CheckMenu(&CollectorDirMenu,
2075 COLLECTORDIR_POPUP);
2076 else
2077 dcd->hwndLastMenu = CheckMenu(&CollectorFileMenu,
2078 COLLECTORFILE_POPUP);
2079 }
2080 else {
2081 dcd->hwndLastMenu = CheckMenu(&CollectorCnrMenu,
2082 COLLECTORCNR_POPUP);
2083 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2084 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2085 MPFROM2SHORT(TRUE, CRA_SOURCE));
2086 dcd->cnremphasized = TRUE;
2087 }
2088 }
2089 if (dcd->hwndLastMenu) {
2090 if (dcd->hwndLastMenu == CollectorCnrMenu) {
2091 SetViewMenu(dcd->hwndLastMenu, dcd->flWindowAttr);
2092 SetDetailsSwitches(dcd->hwndLastMenu, dcd);
2093 if (dcd->flWindowAttr & CV_MINI)
2094 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2095 disable_menuitem(dcd->hwndLastMenu, DID_CANCEL,
2096 !dcd->amextracted);
2097 disable_menuitem(dcd->hwndLastMenu, IDM_GREP, dcd->amextracted);
2098 }
2099 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2100 if (dcd->cnremphasized) {
2101 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2102 MPFROM2SHORT(FALSE, CRA_SOURCE));
2103 dcd->cnremphasized = TRUE;
2104 }
2105 MarkAll(hwnd, TRUE, FALSE, TRUE);
2106 }
2107 }
2108 }
2109 break;
2110
2111 case CN_DROPHELP:
2112 if (mp2) {
2113 PDRAGINFO pDInfo;
2114 PCNRITEM pci;
2115 ULONG numitems;
2116 USHORT usOperation;
2117
2118 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2119 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2120 if (!DrgAccessDraginfo(pDInfo)) {
2121 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2122 "DrgAccessDraginfo");
2123 return 0;
2124 }
2125 numitems = DrgQueryDragitemCount(pDInfo);
2126 usOperation = pDInfo->usOperation;
2127 FreeDragInfoData(hwnd, pDInfo);
2128 saymsg(MB_ENTER | MB_ICONASTERISK,
2129 hwnd,
2130 GetPString(IDS_DROPHELPHDRTEXT),
2131 GetPString(IDS_DROPHELPTEXT),
2132 numitems,
2133 &"s"[numitems == 1],
2134 (pci) ? NullStr : GetPString(IDS_NOTEXT),
2135 (pci) ? NullStr : " ",
2136 (pci) ? pci->pszFileName : NullStr,
2137 (pci) ? " " : NullStr,
2138 GetPString((usOperation == DO_COPY) ?
2139 IDS_COPYTEXT :
2140 (usOperation == DO_LINK) ?
2141 IDS_LINKTEXT : IDS_MOVETEXT));
2142 }
2143 return 0;
2144
2145 case CN_DRAGLEAVE:
2146 if (mp2) {
2147 PDRAGINFO pDInfo;
2148
2149 // fixme to know why needed
2150 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2151 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
2152 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2153 }
2154 return 0;
2155
2156 case CN_DRAGAFTER:
2157 case CN_DRAGOVER:
2158 if (mp2) {
2159 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2160 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2161 PCNRITEM pci;
2162 USHORT uso;
2163
2164 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2165 // if(SHORT1FROMMP(mp1) == CN_DRAGAFTER)
2166 // pci = NULL;
2167 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2168 if (!DrgAccessDraginfo(pDInfo)) {
2169 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2170 "DrgAccessDraginfo");
2171 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2172 }
2173 if (pci) {
2174 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2175 DrgFreeDraginfo(pDInfo);
2176 return (MRFROM2SHORT(DOR_NODROP, 0));
2177 }
2178 uso = pDInfo->usOperation;
2179 if (uso == DO_DEFAULT)
2180 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
2181 if (!(pci->attrFile & FILE_DIRECTORY)) {
2182 if (uso != DO_LINK && uso != DO_MOVE && uso != DO_COPY) {
2183 DrgFreeDraginfo(pDInfo);
2184 return MRFROM2SHORT(DOR_NODROP, 0);
2185 }
2186 if (uso != DO_LINK &&
2187 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2188 DRIVE_NOTWRITEABLE)) {
2189 ARC_TYPE *info = NULL;
2190
2191 if (!fQuickArcFind &&
2192 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2193 DRIVE_SLOW))
2194 info = find_type(pci->pszFileName, NULL);
2195 else
2196 info = quick_find_type(pci->pszFileName, NULL);
2197 if (!info || ((uso == DO_MOVE && !info->move) ||
2198 (uso == DO_COPY && !info->create))) {
2199 DrgFreeDraginfo(pDInfo);
2200 return MRFROM2SHORT(DOR_NODROP, 0);
2201 }
2202 }
2203 }
2204 }
2205 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
2206 0); /* Index to DRAGITEM */
2207 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
2208 DRM_OS2FILE, /* mechanisms and data */
2209 NULL)) {
2210 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2211 if (pci) {
2212 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
2213 DRIVE_NOTWRITEABLE)
2214 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2215 if (toupper(*pci->pszFileName) < 'C')
2216 return MRFROM2SHORT(DOR_DROP, DO_COPY);
2217 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2218 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2219 }
2220 else
2221 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2222 DO_COPY);
2223 }
2224 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2225 }
2226 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2227
2228 case CN_INITDRAG:
2229 if (mp2) {
2230 BOOL wasemphasized = FALSE;
2231 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2232 PCNRITEM pci;
2233
2234 if (pcd) {
2235 pci = (PCNRITEM) pcd->pRecord;
2236 if (pci) {
2237 if (pci->rc.flRecordAttr & CRA_SELECTED)
2238 wasemphasized = TRUE;
2239 if (IsRoot(pci->pszFileName))
2240 break;
2241 if (hwndStatus2)
2242 WinSetWindowText(hwndStatus2,
2243 GetPString(IDS_DRAGFILEOBJTEXT));
2244 if (DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE)) {
2245 if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
2246 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2247 }
2248 if (hwndStatus2)
2249 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2250 }
2251 }
2252 }
2253 return 0;
2254
2255 case CN_DROP:
2256 if (mp2) {
2257 LISTINFO *li;
2258 ULONG action = UM_ACTION;
2259
2260 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
2261 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
2262 if (li) {
2263 if (!*li->targetpath) {
2264 li->type = IDM_COLLECT;
2265 action = UM_COLLECT;
2266 }
2267 else {
2268 if (li->list && li->list[0] && IsRoot(li->list[0]))
2269 li->type = DO_LINK;
2270 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2271 CHECKLIST cl;
2272
2273 memset(&cl, 0, sizeof(cl));
2274 cl.size = sizeof(cl);
2275 cl.flags = li->type;
2276 cl.list = li->list;
2277 cl.cmd = li->type;
2278 cl.prompt = li->targetpath;
2279 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2280 DropListProc, FM3ModHandle,
2281 DND_FRAME, MPFROMP(&cl));
2282 if (li->type == DID_ERROR)
2283 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2284 "Drag & Drop Dialog");
2285 if (!li->type) {
2286 FreeListInfo(li);
2287 return 0;
2288 }
2289 li->list = cl.list;
2290 if (!li->list || !li->list[0]) {
2291 FreeListInfo(li);
2292 return 0;
2293 }
2294 }
2295 switch (li->type) {
2296 case DND_LAUNCH:
2297 strcat(li->targetpath, " %a");
2298 ExecOnList(dcd->hwndParent, li->targetpath,
2299 PROMPT | WINDOWED, NULL, li->list, NULL);
2300 FreeList(li->list);
2301 li->list = NULL;
2302 break;
2303 case DO_LINK:
2304 if (fLinkSetsIcon) {
2305 li->type = IDM_SETICON;
2306 action = UM_MASSACTION;
2307 }
2308 else
2309 li->type = IDM_COMPARE;
2310 break;
2311 case DND_EXTRACT:
2312 if (*li->targetpath && !IsFile(li->targetpath))
2313 li->type = IDM_EXTRACT;
2314 break;
2315 case DND_MOVE:
2316 li->type = IDM_MOVE;
2317 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2318 action = UM_MASSACTION;
2319 li->type = IDM_ARCHIVEM;
2320 }
2321 break;
2322 case DND_WILDMOVE:
2323 li->type = IDM_WILDMOVE;
2324 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2325 action = UM_MASSACTION;
2326 li->type = IDM_ARCHIVEM;
2327 }
2328 break;
2329 case DND_OBJECT:
2330 li->type = IDM_OBJECT;
2331 action = UM_MASSACTION;
2332 break;
2333 case DND_SHADOW:
2334 li->type = IDM_SHADOW;
2335 action = UM_MASSACTION;
2336 break;
2337 case DND_COMPARE:
2338 li->type = IDM_COMPARE;
2339 break;
2340 case DND_SETICON:
2341 action = UM_MASSACTION;
2342 li->type = IDM_SETICON;
2343 break;
2344 case DND_WILDCOPY:
2345 li->type = IDM_WILDCOPY;
2346 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2347 action = UM_MASSACTION;
2348 li->type = IDM_ARCHIVE;
2349 }
2350 break;
2351 case DND_COPY:
2352 li->type = IDM_COPY;
2353 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2354 action = UM_MASSACTION;
2355 li->type = IDM_ARCHIVE;
2356 }
2357 break;
2358 default:
2359 if (*li->arcname && li->info) {
2360 action = UM_MASSACTION;
2361 li->type =
2362 (li->type ==
2363 DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
2364 }
2365 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2366 action = UM_MASSACTION;
2367 li->type =
2368 (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2369 }
2370 else
2371 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2372 break;
2373 }
2374 }
2375 if (!li->list || !li->list[0])
2376 FreeListInfo(li);
2377 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
2378 FreeListInfo(li);
2379 else {
2380 USHORT usop = 0;
2381
2382 switch (li->type) {
2383 case IDM_COPY:
2384 case IDM_WILDCOPY:
2385 usop = DO_COPY;
2386 break;
2387 case IDM_MOVE:
2388 case IDM_WILDMOVE:
2389 case IDM_ARCHIVEM:
2390 usop = DO_MOVE;
2391 break;
2392 }
2393 if (usop)
2394 return MRFROM2SHORT(DOR_DROP, usop);
2395 }
2396 }
2397 }
2398 return 0;
2399
2400 case CN_BEGINEDIT:
2401 case CN_REALLOCPSZ:
2402 case CN_ENDEDIT:
2403 {
2404 MRESULT mre;
2405
2406 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
2407 if (mre != (MRESULT) - 1)
2408 return mre;
2409 }
2410 break;
2411
2412 case CN_EMPHASIS:
2413 if (mp2) {
2414 PNOTIFYRECORDEMPHASIS pre = mp2;
2415 PCNRITEM pci;
2416 CHAR s[CCHMAXPATH + 91], tb[81], tf[81], *p;
2417
2418 pci = (PCNRITEM) ((pre) ? pre->pRecord : NULL);
2419 if (!pci) {
2420 if (hwndStatus2)
2421 WinSetWindowText(hwndStatus2, NullStr);
2422 if (fMoreButtons) {
2423 WinSetWindowText(hwndName, NullStr);
2424 WinSetWindowText(hwndDate, NullStr);
2425 WinSetWindowText(hwndAttr, NullStr);
2426 }
2427 if (hwndMain)
2428 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2429 break;
2430 }
2431 if (pre->fEmphasisMask & CRA_SELECTED) {
2432 if (pci->rc.flRecordAttr & CRA_SELECTED) {
2433 dcd->selectedbytes += (pci->cbFile + pci->easize);
2434 dcd->selectedfiles++;
2435 }
2436 else if (dcd->selectedfiles) {
2437 dcd->selectedbytes -= (pci->cbFile + pci->easize);
2438 dcd->selectedfiles--;
2439 }
2440 if (!dcd->suspendview) {
2441 commafmt(tf, sizeof(tf), dcd->selectedfiles);
2442 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
2443 sprintf(s, "%s / %s", tf, tb);
2444 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
2445 }
2446 }
2447 if (!dcd->suspendview &&
2448 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
2449 if (pre->fEmphasisMask & CRA_CURSORED) {
2450 if (pci->rc.flRecordAttr & CRA_CURSORED) {
2451 if (fSplitStatus && hwndStatus2) {
2452 if (pci->attrFile & FILE_DIRECTORY)
2453 p = pci->pszFileName;
2454 else {
2455 p = strrchr(pci->pszFileName, '\\');
2456 if (p) {
2457 if (*(p + 1))
2458 p++;
2459 else
2460 p = pci->pszFileName;
2461 }
2462 else
2463 p = pci->pszFileName;
2464 }
2465 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
2466 if (!fMoreButtons)
2467 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
2468 tb, pci->date.year,
2469 pci->date.month, pci->date.day, pci->time.hours,
2470 pci->time.minutes, pci->time.seconds,
2471 pci->pszDispAttr, p);
2472 else {
2473 if (pci->cbFile + pci->easize > 1024)
2474 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize,
2475 ' ');
2476 else
2477 *tf = 0;
2478 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
2479 tb,
2480 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
2481 }
2482 WinSetWindowText(hwndStatus2, s);
2483 }
2484 if (fMoreButtons) {
2485 WinSetWindowText(hwndName, pci->pszFileName);
2486 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
2487 pci->date.year, pci->date.month,
2488 pci->date.day, pci->time.hours, pci->time.minutes,
2489 pci->time.seconds);
2490 WinSetWindowText(hwndDate, s);
2491 WinSetWindowText(hwndAttr, pci->pszDispAttr);
2492 }
2493 }
2494 }
2495 }
2496 if (!dcd->suspendview && hwndMain &&
2497 (pre->fEmphasisMask & CRA_CURSORED) &&
2498 (pci->rc.flRecordAttr & CRA_CURSORED) &&
2499 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame)
2500 WinSendMsg(hwndMain, UM_LOADFILE,
2501 MPFROMP(((fComments
2502 || (pci->attrFile & FILE_DIRECTORY) ==
2503 0) ? pci->pszFileName : NULL)), MPVOID);
2504 }
2505 break;
2506
2507 case CN_ENTER:
2508 if (mp2) {
2509 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
2510 FILEFINDBUF3 ffb;
2511 HDIR hDir = HDIR_CREATE;
2512 ULONG nm = 1;
2513 APIRET status = 0;
2514
2515 SetShiftState();
2516 if (pci) {
2517 if (pci->rc.flRecordAttr & CRA_INUSE)
2518 break;
2519 DosError(FERR_DISABLEHARDERR);
2520 status = DosFindFirst(pci->pszFileName, &hDir,
2521 FILE_NORMAL | FILE_DIRECTORY |
2522 FILE_ARCHIVED | FILE_READONLY |
2523 FILE_HIDDEN | FILE_SYSTEM,
2524 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
2525 priority_bumped();
2526 if (!status) {
2527 DosFindClose(hDir);
2528 if (ffb.attrFile & FILE_DIRECTORY) {
2529 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
2530 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0),
2531 MPVOID);
2532 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
2533 (KC_CTRL | KC_SHIFT))
2534 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
2535 else if (shiftstate & KC_CTRL)
2536 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
2537 else
2538 OpenDirCnr(HWND_DESKTOP,
2539 hwndMain,
2540 dcd->hwndFrame, FALSE, pci->pszFileName);
2541 }
2542 else {
2543 SWP swp;
2544
2545 WinSendMsg(hwnd,
2546 CM_SETRECORDEMPHASIS,
2547 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
2548 WinQueryWindowPos(dcd->hwndFrame, &swp);
2549 DefaultViewKeys(hwnd,
2550 dcd->hwndFrame,
2551 dcd->hwndParent, &swp, pci->pszFileName);
2552 WinSendMsg(hwnd,
2553 CM_SETRECORDEMPHASIS,
2554 MPFROMP(pci),
2555 MPFROM2SHORT(FALSE, CRA_INUSE |
2556 ((fUnHilite) ? CRA_SELECTED : 0)));
2557 }
2558 }
2559 else
2560 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
2561 }
2562 }
2563 break;
2564 }
2565 }
2566 return 0;
2567
2568 case UM_LOADFILE:
2569 if (dcd && mp2) {
2570 HWND ret;
2571
2572 ret = StartMLEEditor(dcd->hwndParent,
2573 (INT) mp1, (CHAR *) mp2, dcd->hwndFrame);
2574 if (mp2)
2575 free((CHAR *) mp2);
2576 return MRFROMLONG(ret);
2577 }
2578 return 0;
2579
2580 case UM_CLOSE:
2581 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
2582 QW_PARENT));
2583 return 0;
2584
2585 case UM_FOLDUP:
2586 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
2587 DosExit(EXIT_PROCESS, 1);
2588 return 0;
2589
2590 case WM_CLOSE:
2591 if (dcd) {
2592 dcd->namecanchange = TRUE;
2593 dcd->stopflag = 1;
2594 if (dcd->amextracted)
2595 return 0; // Can not close yet
2596 }
2597 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
2598 if (dcd) {
2599 if (!dcd->dontclose && ParentIsDesktop(hwnd, dcd->hwndParent))
2600 PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
2601 if (dcd->hwndObject) {
2602 DosSleep(32); //05 Aug 07 GKY 64
2603 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
2604 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
2605 }
2606 }
2607 else
2608 WinSendMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
2609 return 0;
2610
2611 case WM_DESTROY:
2612 if (CollectorDirMenu)
2613 WinDestroyWindow(CollectorDirMenu);
2614 if (CollectorFileMenu)
2615 WinDestroyWindow(CollectorFileMenu);
2616 if (CollectorCnrMenu)
2617 WinDestroyWindow(CollectorCnrMenu);
2618 CollectorCnrMenu = CollectorFileMenu = CollectorDirMenu = (HWND) 0;
2619 Collector = (HWND) 0;
2620 EmptyCnr(hwnd);
2621 break;
2622 }
2623 if (dcd && dcd->oldproc){
2624 return dcd->oldproc(hwnd, msg, mp1, mp2);
2625 }
2626 else
2627 return 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}
2744
2745#pragma alloc_text(COLLECTOR,CollectorCnrWndProc,CollectorObjWndProc)
2746#pragma alloc_text(COLLECTOR,CollectorClientWndProc,CollectorTextProc)
2747#pragma alloc_text(COLLECTOR,CollectorFrameWndProc)
2748#pragma alloc_text(STARTUP,StartCollector)
Note: See TracBrowser for help on using the repository browser.