source: trunk/dll/collect.c@ 1639

Last change on this file since 1639 was 1615, checked in by Gregg Young, 14 years ago

Have collector file count and KIBs update at the same time. (Ticket 455)

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