source: trunk/dll/collect.c@ 1084

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

Added ability to save/append either the full path name (already present) or just the filename to the clipboard. Changed the menu text to make these easier to find. Removed the final return/newline from the list. Ticket 137

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