source: trunk/dll/collect.c@ 989

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

Refactor fm3dll.h to create command.h; broken ini is now replaced with backup or new ini as available; more variable command line ledth changes

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