source: trunk/dll/collect.c@ 917

Last change on this file since 917 was 917, checked in by Steven Levine, 18 years ago

Correct/enhance settings notebook navigation, ticket #188 (Steven)
Reopen settings notebook to last selected page unless overridden, ticket #188 (Steven)
More Compare Directory overflow tweaks (Steven)

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