source: trunk/dll/collect.c@ 946

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

Minor code cleanup and documentation for some changes. (Tickets 3, 7, 184)

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