source: trunk/dll/collect.c@ 1120

Last change on this file since 1120 was 1120, checked in by Gregg Young, 17 years ago

Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if less than 10 KiB (It hangs and can't be closed) (Ticket 214) Also some cleanup of the error messages for CheckDriveSpaceAvail.

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