source: trunk/dll/collect.c@ 908

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

Avoid out of memory traps in Compare Directories
Rework Compare Directories progress display for 2 second update rate
Start refactoring to reduce dependence on fm3dll.h
Add timer services (IsITimerExpired etc.)

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