source: trunk/dll/collect.c@ 793

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

Move #pragma alloc_text to end for OpenWatcom compat

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