source: trunk/dll/collect.c@ 1370

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

Seek and scan called from the dir or drive context menu opens seek and scan and provides the path to start the search from. (Ticket 167)

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