source: trunk/dll/collect.c@ 1159

Last change on this file since 1159 was 1159, checked in by John Small, 17 years ago

Ticket 187: Draft 1: Functions only

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