source: trunk/dll/collect.c@ 1675

Last change on this file since 1675 was 1675, checked in by Gregg Young, 13 years ago

Enhance traget directory drop to give the option of changing the directory or carrying out an operation to the current target; Added an error message for target=None; Added parameter to SetTargetDir. Ticket 373

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