source: trunk/dll/collect.c@ 1387

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

Updated history; comments minor code cleanup for recent changes

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