source: trunk/dll/collect.c@ 1611

Last change on this file since 1611 was 1611, checked in by Steven Levine, 14 years ago

Allow SVN/CVS file ignore in Seek and scan

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