source: trunk/dll/collect.c@ 1671

Last change on this file since 1671 was 1671, checked in by Steven Levine, 13 years ago

Correct UM_COLLECTFROMFILE bad list file reporting
Sync collector menu with docs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 86.8 KB
Line 
1
2/***********************************************************************
3
4 $Id: collect.c 1671 2012-09-05 18:19:29Z stevenhl $
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__,
699 "CM_QUERYCNRINFO" /* PCSZ_QUERYCNRINFO fixme */);
700 ulRecsAtStart = 0;
701 }
702
703 for (x = 0; li->list[x]; x++) {
704
705 // Allocate more container items if needed
706 if (!pci) {
707 ulRecsToInsert = ulMaxFiles - ulRecsInserted; // Left to do
708 if (ulRecsToInsert > USHRT_MAX)
709 ulRecsToInsert = USHRT_MAX; // Avoid USHORT overflows
710 pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD,
711 MPFROMLONG(EXTRA_RECORD_BYTES),
712 MPFROMLONG(ulRecsToInsert));
713 pciFirst = pci;
714 pciPrev = NULL;
715 if (!pci) {
716 Runtime_Error(pszSrcFile, __LINE__, PCSZ_CM_ALLOCRECORD);
717 break;
718 }
719 } // if need allocate
720
721 nm = 1;
722 hdir = HDIR_CREATE;
723 DosError(FERR_DISABLEHARDERR);
724 // If started with records in container, check if updating existing record
725 if (ulRecsAtStart &&
726 FindCnrRecord(dcd->hwndCnr,
727 li->list[x],
728 NULL,
729 FALSE,
730 FALSE,
731 TRUE))
732 {
733 // Updating existing record
734 PCNRITEM pciUpd = UpdateCnrRecord(dcd->hwndCnr, li->list[x], FALSE, dcd);
735 if (!pciUpd) {
736 // file has disappeared
737 Runtime_Error(pszSrcFile, __LINE__, "pci NULL for list[%u]", x);
738 }
739 else {
740 // Update OK
741 if (Filter((PMINIRECORDCORE) pciUpd, (PVOID) & dcd->mask)) {
742 pciUpd->rc.flRecordAttr &= ~CRA_FILTERED; // Ensure visible
743 // 2011-05-29 SHL fixme to check fail
744 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
745 MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
746 }
747 }
748 ulMaxFiles--; // No insert needed
749 checkToInsert = TRUE;
750 }
751 // Add new entry maybe
752 else if (*li->list[x] &&
753 !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
754 fullname, sizeof(fullname)) &&
755 !IsRoot(fullname) &&
756 !xDosFindFirst(fullname,
757 &hdir,
758 FILE_NORMAL | FILE_DIRECTORY |
759 FILE_ARCHIVED | FILE_SYSTEM |
760 FILE_HIDDEN | FILE_READONLY,
761 &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL))
762 {
763 // OK to add
764 DosFindClose(hdir);
765 priority_normal();
766 *fb4.achName = 0;
767 ullTotalBytes += FillInRecordFromFFB(dcd->hwndCnr,
768 pci,
769 fullname, &fb4, FALSE, dcd);
770 pciPrev = pci;
771 pci = (PCNRITEM) pci->rc.preccNextRecord;
772 }
773 else {
774 // DosQueryPathInfo etc. failed - try to recover
775 Runtime_Error(pszSrcFile, __LINE__, "DosQueryPathInfo failed for %s", fullname);
776 ulMaxFiles--; // Nothing to insert
777 checkToInsert = TRUE;
778 }
779
780 if (checkToInsert) {
781 checkToInsert = FALSE;
782 // Remove extra records from chain
783 while (ulRecsInserted + ulRecsToInsert > ulMaxFiles) {
784 PCNRITEM pciNext = (PCNRITEM)pci->rc.preccNextRecord;
785 if (pciPrev)
786 pciPrev->rc.preccNextRecord = (PMINIRECORDCORE)pciNext;
787 else
788 pciFirst = pciNext;
789 pci->pszFileName = NullStr; // Avoid spurious complaints
790 FreeCnrItem(dcd->hwndCnr, pci);
791 pci = pciNext;
792 ulRecsToInsert--; // Remember gone
793 }
794 }
795
796 // Check if time to insert
797 if (!pci) {
798 // All allocated CNRITEMs filled
799 if (ulRecsToInsert) {
800 // Have CNRITEMs to insert
801 memset(&ri, 0, sizeof(RECORDINSERT));
802 ri.cb = sizeof(RECORDINSERT);
803 ri.pRecordOrder = (PRECORDCORE) CMA_END;
804 ri.pRecordParent = (PRECORDCORE) 0;
805 ri.zOrder = (ULONG) CMA_TOP;
806 ri.cRecordsInsert = ulRecsToInsert;
807 ri.fInvalidateRecord = TRUE;
808 WinSendMsg(dcd->hwndCnr,
809 CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
810 // 2011-05-29 SHL fixme to complain on failure
811 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
812 ulRecsInserted += ulRecsToInsert;
813 dcd->ullTotalBytes = ullTotalBytes;
814 pciFirst = NULL;
815 ulRecsToInsert = 0;
816 }
817 } // if need CM_INSERTRECORD
818 SleepIfNeeded(&itdSleep, 1); // 09 Feb 08 SHL
819 } // for
820
821 // Clean up in case stopped early by error
822 if (pci)
823 Runtime_Error(pszSrcFile, __LINE__, "pci not NULL");
824
825 if (pciFirst) {
826 Runtime_Error(pszSrcFile, __LINE__, "pciFirst not NULL");
827 // 2011-08-08 SHL fixme to initialze pszFileName to prevent spurious complaints
828 FreeCnrItemList(dcd->hwndCnr, pciFirst);
829 }
830
831 } // if have files
832
833 if (dcd->flWindowAttr & CV_DETAIL)
834 WinSendDlgItemMsg(hwnd,
835 COLLECTOR_CNR,
836 CM_INVALIDATERECORD,
837 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
838 } // if dcd
839 return 0;
840
841 case UM_COLLECTFROMFILE:
842 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
843# ifdef FORTIFY
844 Fortify_EnterScope();
845# endif
846
847 if (dcd && mp1) {
848 // mp1 is pszFileName, mp2 is unused
849 FILESTATUS4L fs4;
850 PCNRITEM pci;
851 RECORDINSERT ri;
852 CHAR fullname[1024], *p;
853 FILE *fp;
854 ULONG errs = 0;
855 BOOL first = TRUE; // 2012-09-05 SHL
856 size_t c;
857 CHAR *moder = "r";
858
859# ifdef FORTIFY
860 Fortify_BecomeOwner(mp1);
861# endif
862
863 fp = xfsopen((CHAR *)mp1, moder, SH_DENYNO, pszSrcFile, __LINE__, TRUE);
864 if (fp) {
865 while (!feof(fp)) {
866 // Avoid too much noise if collecting from binary file - oops
867 if (!fgets(fullname, sizeof(fullname), fp)) {
868 if (ferror(fp))
869 Runtime_Error(pszSrcFile, __LINE__, "fgets");
870 break;
871 }
872
873 c = strlen(fullname);
874 if (c + 1 >= sizeof(fullname))
875 errs++; // Name too long
876 else if (!c || (fullname[c - 1] != '\n' && fullname[c - 1] != '\r'))
877 errs++; // Probably reading a binary file
878 else {
879 bstripcr(fullname);
880
881 if (*fullname == '\"') {
882 // Strip quotes
883 memmove(fullname, fullname + 1, strlen(fullname) + 1);
884 lstrip(fullname);
885 p = strchr(fullname, '\"');
886 if (p)
887 *p = 0;
888 rstrip(fullname);
889 }
890 else {
891 // Strip trailing spaces
892 p = strchr(fullname, ' ');
893 if (p)
894 *p = 0;
895 }
896 // fullname now contains name of file to collect
897 DosError(FERR_DISABLEHARDERR);
898 if (FindCnrRecord(dcd->hwndCnr,
899 fullname,
900 NULL,
901 FALSE,
902 FALSE,
903 TRUE)) {
904 // Already in container
905 pci = UpdateCnrRecord(dcd->hwndCnr, fullname, FALSE, dcd);
906 if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
907 pci->rc.flRecordAttr &= ~CRA_FILTERED;
908 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
909 MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
910 }
911 }
912 else if (IsFullName(fullname) &&
913 !IsRoot(fullname) &&
914 !DosQueryPathInfo(fullname,
915 FIL_QUERYEASIZEL,
916 &fs4,
917 sizeof(fs4))) {
918 // Add to collector containter
919 pci = WinSendMsg(dcd->hwndCnr,
920 CM_ALLOCRECORD,
921 MPFROMLONG(EXTRA_RECORD_BYTES),
922 MPFROMLONG(1));
923 if (pci) {
924 dcd->ullTotalBytes += FillInRecordFromFSA(dcd->hwndCnr, pci,
925 fullname,
926 &fs4, FALSE, NULL, dcd);
927 memset(&ri, 0, sizeof(RECORDINSERT));
928 ri.cb = sizeof(RECORDINSERT);
929 ri.pRecordOrder = (PRECORDCORE) CMA_END;
930 ri.pRecordParent = (PRECORDCORE) 0;
931 ri.zOrder = (ULONG) CMA_TOP;
932 ri.cRecordsInsert = 1;
933 ri.fInvalidateRecord = TRUE;
934 WinSendMsg(dcd->hwndCnr, CM_INSERTRECORD,
935 MPFROMP(pci), MPFROMP(&ri));
936 }
937 }
938 else
939 errs++; // Something wrong with filename or file
940 }
941 if (errs > (first ? 0 : 50)) {
942 /* prevent runaway on bad file */
943 APIRET ret = saymsg(MB_YESNO, dcd->hwndCnr,
944 GetPString(IDS_COLLECTNOLISTHDRTEXT),
945 GetPString(IDS_COLLECTNOLISTTEXT),
946 (CHAR *)mp1);
947
948 if (ret == MBID_NO)
949 break; // Give up
950 if (!first)
951 errs = 0;
952 else
953 first = FALSE;
954 }
955 } // while not eof
956 fclose(fp);
957 } // if file opened
958 free(mp1);
959 }
960# ifdef FORTIFY
961 Fortify_LeaveScope();
962# endif
963 return 0;
964
965 case UM_SELECT:
966 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
967 if (dcd) {
968 switch (SHORT1FROMMP(mp1)) {
969 case IDM_SELECTLIST:
970 {
971 CHAR filename[CCHMAXPATH], *p, *pp;
972
973 strcpy(filename, PCSZ_STARDOTLST);
974 size = CCHMAXPATH;
975 PrfQueryProfileData(fmprof, appname, "SaveToListName", filename,
976 &size);
977 pp = strrchr(filename, '\\');
978 if (!pp)
979 pp = filename;
980 p = strrchr(pp, '.');
981 if (p && *(p + 1) && p > pp + 1) {
982 if (pp > filename)
983 pp++;
984 *pp = '*';
985 pp++;
986 if (p > pp)
987 memmove(pp, p, strlen(p) + 1);
988 }
989 if (insert_filename(hwnd, filename, FALSE, FALSE))
990 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
991 NULL);
992 }
993 break;
994 case IDM_SELECTALL:
995 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
996 break;
997 case IDM_DESELECTALL:
998 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
999 break;
1000 case IDM_SELECTALLFILES:
1001 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
1002 break;
1003 case IDM_DESELECTALLFILES:
1004 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
1005 break;
1006 case IDM_SELECTALLDIRS:
1007 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
1008 break;
1009 case IDM_DESELECTALLDIRS:
1010 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
1011 break;
1012 case IDM_DESELECTMASK:
1013 case IDM_SELECTMASK:
1014 {
1015 MASK mask;
1016 PCNRITEM pci = (PCNRITEM) mp2;
1017
1018 memset(&mask, 0, sizeof(MASK));
1019 mask.fNoAttribs = TRUE;
1020 mask.fNoDirs = TRUE;
1021 mask.fText = TRUE;
1022 strcpy(mask.prompt,
1023 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
1024 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
1025 if (pci && (INT) pci != -1)
1026 strcpy(mask.szMask, pci->pszFileName);
1027 if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
1028 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
1029 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
1030 SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
1031 FALSE);
1032 else
1033 DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
1034 FALSE);
1035 }
1036 }
1037
1038 case IDM_DESELECTCLIP:
1039 case IDM_SELECTCLIP:
1040 {
1041 CHAR **list;
1042
1043 list = ListFromClipboard(hwnd);
1044 if (list) {
1045 SelectList(dcd->hwndCnr, TRUE, FALSE,
1046 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
1047 NULL, NULL, list);
1048 FreeList(list);
1049 }
1050 }
1051 break;
1052
1053 case IDM_INVERT:
1054 InvertAll(dcd->hwndCnr);
1055 break;
1056 }
1057 }
1058 return 0;
1059
1060 case UM_MASSACTION:
1061# ifdef FORTIFY
1062 Fortify_EnterScope();
1063# endif
1064 if (mp1) {
1065# ifdef FORTIFY
1066 Fortify_BecomeOwner(mp1);
1067# endif
1068 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1069 if (dcd) {
1070 WORKER *wk;
1071 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
1072 if (!wk)
1073 FreeListInfo((LISTINFO *) mp1);
1074 else {
1075 wk->size = sizeof(WORKER);
1076 wk->hwndCnr = dcd->hwndCnr;
1077 wk->hwndParent = dcd->hwndParent;
1078 wk->hwndFrame = dcd->hwndFrame;
1079 wk->hwndClient = dcd->hwndClient;
1080 wk->li = (LISTINFO *) mp1;
1081 strcpy(wk->directory, dcd->directory);
1082 if (xbeginthread(MassAction,
1083 122880,
1084 wk,
1085 pszSrcFile,
1086 __LINE__) == -1)
1087 {
1088 free(wk);
1089 FreeListInfo((LISTINFO *) mp1);
1090 }
1091 }
1092 }
1093 }
1094# ifdef FORTIFY
1095 DosSleep(1); // Let receiver take ownership
1096 Fortify_LeaveScope();
1097# endif
1098 return 0;
1099
1100 case UM_ACTION:
1101# ifdef FORTIFY
1102 Fortify_EnterScope();
1103# endif
1104 if (mp1) {
1105# ifdef FORTIFY
1106 Fortify_BecomeOwner(mp1);
1107# endif
1108 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1109 if (dcd) {
1110 WORKER *wk;
1111 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
1112 if (!wk)
1113 FreeListInfo((LISTINFO *) mp1);
1114 else {
1115 wk->size = sizeof(WORKER);
1116 wk->hwndCnr = dcd->hwndCnr;
1117 wk->hwndParent = dcd->hwndParent;
1118 wk->hwndFrame = dcd->hwndFrame;
1119 wk->hwndClient = dcd->hwndClient;
1120 wk->li = (LISTINFO *) mp1;
1121 strcpy(wk->directory, dcd->directory);
1122 if (xbeginthread(Action,
1123 122880,
1124 wk,
1125 pszSrcFile,
1126 __LINE__) == -1)
1127 {
1128 free(wk);
1129 FreeListInfo((LISTINFO *) mp1);
1130 }
1131 }
1132 }
1133 }
1134# ifdef FORTIFY
1135 DosSleep(1); // Let receiver take ownership
1136 Fortify_LeaveScope();
1137# endif
1138 return 0;
1139
1140 case WM_CLOSE:
1141 WinDestroyWindow(hwnd);
1142 break;
1143
1144 case WM_DESTROY:
1145 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1146 if (dcd) {
1147 INT x;
1148
1149 dcd->stopflag = 1;
1150 // Allow other threads to honor stop request
1151 for (x = 0; x < 100 && dcd->amextracted; x++)
1152 DosSleep(10);
1153 if (dcd->amextracted)
1154 Runtime_Error(pszSrcFile, __LINE__, "still busy");
1155 WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
1156 FreeList(dcd->lastselection);
1157 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL); // 13 Apr 10 SHL Set NULL before freeing dcd
1158 free(dcd);
1159# ifdef FORTIFY
1160 Fortify_LeaveScope();
1161# endif
1162 }
1163 DosPostEventSem(CompactSem);
1164 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1165 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1166 break;
1167 }
1168 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1169}
1170
1171MRESULT EXPENTRY CollectorCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
1172 MPARAM mp2)
1173{
1174 DIRCNRDATA *dcd = INSTDATA(hwnd);
1175 ULONG size;
1176
1177 static INT savedSortFlags;
1178
1179 switch (msg) {
1180 case DM_PRINTOBJECT:
1181 return MRFROMLONG(DRR_TARGET);
1182
1183 case DM_DISCARDOBJECT:
1184 if (dcd)
1185 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1186 else
1187 return MRFROMLONG(DRR_TARGET);
1188
1189 case WM_CHAR:
1190 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1191 if (SHORT1FROMMP(mp1) & KC_KEYUP)
1192 return (MRESULT) TRUE;
1193 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1194 switch (SHORT2FROMMP(mp2)) {
1195 case VK_DELETE:
1196 if ((shiftstate & KC_CTRL) == KC_CTRL)
1197 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
1198 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
1199 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
1200 else
1201 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
1202 break;
1203 }
1204 }
1205 if (shiftstate || fNoSearch)
1206 break;
1207 if (SHORT1FROMMP(mp1) & KC_CHAR) {
1208 ULONG thistime, len;
1209 SEARCHSTRING srch;
1210 PCNRITEM pci;
1211
1212 if (!dcd)
1213 break;
1214 switch (SHORT1FROMMP(mp2)) {
1215 case '\x1b':
1216 case '\r':
1217 case '\n':
1218 dcd->lasttime = 0;
1219 *dcd->szCommonName = 0;
1220 break;
1221 default:
1222 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1223 if (thistime > dcd->lasttime + 1250)
1224 *dcd->szCommonName = 0;
1225 dcd->lasttime = thistime;
1226 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
1227 break;
1228 KbdRetry:
1229 len = strlen(dcd->szCommonName);
1230 if (len >= CCHMAXPATH - 1) {
1231 *dcd->szCommonName = 0;
1232 len = 0;
1233 }
1234 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1235 dcd->szCommonName[len + 1] = 0;
1236 memset(&srch, 0, sizeof(SEARCHSTRING));
1237 srch.cb = sizeof(SEARCHSTRING);
1238 srch.pszSearch = dcd->szCommonName;
1239 srch.fsPrefix = TRUE;
1240 srch.fsCaseSensitive = FALSE;
1241 srch.usView = CV_ICON;
1242 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
1243 MPFROMLONG(CMA_FIRST));
1244 if (pci && (INT) pci != -1) {
1245 USHORT attrib = CRA_CURSORED;
1246
1247 /* make found item current item */
1248 if (!stricmp(pci->pszFileName, dcd->szCommonName))
1249 attrib |= CRA_SELECTED;
1250 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1251 MPFROM2SHORT(TRUE, attrib));
1252 /* make sure that record shows in viewport */
1253 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1254 return (MRESULT) TRUE;
1255 }
1256 else {
1257 if (SHORT1FROMMP(mp2) == ' ') {
1258 dcd->szCommonName[len] = 0;
1259 break;
1260 }
1261 *dcd->szCommonName = 0;
1262 dcd->lasttime = 0;
1263 if (len) // retry as first letter if no match
1264
1265 goto KbdRetry;
1266 }
1267 break;
1268 }
1269 }
1270 break;
1271
1272 case WM_MOUSEMOVE:
1273 case WM_BUTTON1UP:
1274 case WM_BUTTON2UP:
1275 case WM_BUTTON3UP:
1276 case WM_CHORD:
1277 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1278 break;
1279
1280 case WM_BUTTON1MOTIONEND:
1281 {
1282 CNRINFO cnri;
1283
1284 memset(&cnri, 0, sizeof(CNRINFO));
1285 cnri.cb = sizeof(CNRINFO);
1286 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1287 MPFROMLONG(sizeof(CNRINFO)))) {
1288 if (cnri.flWindowAttr & CV_DETAIL)
1289 PrfWriteProfileData(fmprof, appname, "CollectorCnrSplitBar",
1290 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
1291 }
1292 }
1293 break;
1294
1295 case WM_PRESPARAMCHANGED:
1296 PresParamChanged(hwnd, PCSZ_COLLECTOR, mp1, mp2);
1297 break;
1298
1299 case UM_COMPARE:
1300 if (dcd && mp1 && mp2) {
1301 COMPARE *cmp;
1302 CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
1303
1304 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1305 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1306 if (cmp) {
1307 cmp->size = sizeof(COMPARE);
1308 strcpy(cmp->leftdir, leftdir);
1309 strcpy(cmp->rightdir, rightdir);
1310 cmp->hwndParent = dcd->hwndParent;
1311 cmp->dcd.hwndParent = dcd->hwndParent;
1312 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, CompareDlgProc,
1313 FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1314 }
1315 }
1316 }
1317 return 0;
1318
1319 case UM_UPDATERECORDLIST:
1320 if (dcd && mp1)
1321 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1322 return 0;
1323
1324 case UM_UPDATERECORD:
1325 if (dcd && mp1) {
1326 CHAR *filename;
1327
1328 filename = mp1;
1329 if (filename)
1330 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1331 }
1332 return 0;
1333
1334 case WM_SETFOCUS:
1335 /*
1336 * put name of our window on status line
1337 */
1338 if (dcd && hwndStatus && mp2) {
1339 PCNRITEM pci = NULL;
1340
1341 if (fAutoView && hwndMain) {
1342 pci = WinSendMsg(hwnd,
1343 CM_QUERYRECORDEMPHASIS,
1344 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1345 if (pci && (INT) pci != -1 &&
1346 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1347 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1348 else
1349 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1350 }
1351 if (dcd->amextracted)
1352 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_INSEEKSCANTEXT)); // Say working
1353 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1354 }
1355 break;
1356
1357 case UM_RESCAN:
1358 if (dcd) {
1359 CNRINFO cnri;
1360 CHAR s[CCHMAXPATH + 69], tb[81], tf[81], szDate[DATE_BUF_BYTES] *p;
1361 PCNRITEM pci = NULL;
1362
1363 memset(&cnri, 0, sizeof(CNRINFO));
1364 cnri.cb = sizeof(CNRINFO);
1365 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1366 MPFROMLONG(sizeof(CNRINFO)));
1367 dcd->totalfiles = cnri.cRecords;
1368 commafmt(tf, sizeof(tf), dcd->totalfiles);
1369 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
1370 sprintf(s, "%s / %s", tf, tb);
1371 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1372
1373 commafmt(tf, sizeof(tf), dcd->selectedfiles);
1374 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
1375 sprintf(s, "%s / %s", tf, tb);
1376 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1377
1378 if (hwndStatus &&
1379 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1380 if (hwndMain) {
1381 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1382 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1383 if (pci && (INT) pci != -1)
1384 PostMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1385 else
1386 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1387 }
1388 if (!dcd->amextracted) {
1389 if (!fMoreButtons) {
1390 sprintf(s, " %s%s%s%s",
1391 GetPString(IDS_COLLECTORTEXT),
1392 *dcd->mask.szMask || dcd->mask.antiattr ||
1393 dcd->mask.attrFile != ALLATTRS ? " (" : NullStr,
1394 *dcd->mask.szMask ?
1395 dcd->mask.szMask :
1396 dcd->mask.antiattr ||
1397 dcd->mask.attrFile != ALLATTRS ?
1398 GetPString(IDS_ATTRTEXT) : NullStr,
1399 *dcd->mask.szMask || dcd->mask.antiattr ||
1400 dcd->mask.attrFile != ALLATTRS ?
1401 ")" : NullStr);
1402 }
1403 else
1404 strcpy(s, GetPString(IDS_COLLECTORTEXT));
1405 WinSetWindowText(hwndStatus, s);
1406 }
1407 if (!pci)
1408 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1409 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1410 if (pci && (INT) pci != -1) {
1411 BOOL fStatus2Used = FALSE;
1412
1413 if (fSplitStatus && hwndStatus2) {
1414 if (pci->attrFile & FILE_DIRECTORY)
1415 p = pci->pszFileName;
1416 else {
1417 if (!pci->pszFileName)
1418 Runtime_Error(pszSrcFile, __LINE__, "pci->pszFileName NULL for %p", pci);
1419 p = strrchr(pci->pszFileName, '\\');
1420 if (p) {
1421 if (*(p + 1))
1422 p++;
1423 else
1424 p = pci->pszFileName;
1425 }
1426 else
1427 p = pci->pszFileName;
1428 }
1429 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1430 if (!fMoreButtons) {
1431 DateFormat(szDate, pci->date);
1432 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
1433 tb, szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
1434 TimeSeparator, pci->time.seconds, pci->pszDispAttr, p);
1435 }
1436 else {
1437 if (pci->cbFile + pci->easize > 1024)
1438 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1439 else
1440 *tf = 0;
1441 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
1442 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1443 }
1444 WinSetWindowText(hwndStatus2, s);
1445 fStatus2Used = TRUE;
1446 }
1447 if (fMoreButtons) {
1448 WinSetWindowText(hwndName, pci->pszFileName);
1449 DateFormat(szDate, pci->date);
1450 sprintf(s, "%s %02u%s%02u%s%02u",
1451 szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
1452 TimeSeparator, pci->time.seconds);
1453 WinSetWindowText(hwndDate, s);
1454 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1455 }
1456 if (dcd->amextracted && hwndStatus2 && !fStatus2Used)
1457 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_INSEEKSCANTEXT)); // Say working
1458 }
1459 else {
1460 if (hwndStatus2) {
1461 if (dcd->amextracted)
1462 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_INSEEKSCANTEXT)); // Say working
1463 else
1464 WinSetWindowText(hwndStatus2, NullStr);
1465 }
1466 if (fMoreButtons) {
1467 WinSetWindowText(hwndName, NullStr);
1468 WinSetWindowText(hwndDate, NullStr);
1469 WinSetWindowText(hwndAttr, NullStr);
1470 }
1471 }
1472 }
1473 }
1474 return 0;
1475
1476 case UM_CONTAINER_FILLED:
1477 if (!fAlertBeepOff)
1478 DosBeep(1000, 50); // Wake up user?
1479 WinSendMsg(hwnd,
1480 CM_INVALIDATERECORD,
1481 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1482 disable_menuitem(WinWindowFromID(WinQueryWindow(hwndMain, QW_PARENT),
1483 FID_MENU), IDM_GREP, FALSE);
1484 disable_menuitem(TreeMenu, IDM_GREP, FALSE);
1485 disable_menuitem(DirMenu, IDM_GREP, FALSE);
1486 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1487 if (dcd) {
1488 dcd->stopflag = 0;
1489 dcd->amextracted = FALSE; // Say not busy
1490 if (dcd->namecanchange) {
1491 if (!PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID))
1492 WinSendMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1493 }
1494 else
1495 WinSetWindowPos(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
1496 QW_PARENT),
1497 HWND_TOP,
1498 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ZORDER);
1499 }
1500 return 0;
1501
1502 case UM_SETUP:
1503 if (dcd) {
1504 if (!dcd->hwndObject) {
1505 /* first time through -- set things up */
1506
1507 CNRINFO cnri;
1508
1509 RestorePresParams(hwnd, PCSZ_COLLECTOR);
1510 LoadDetailsSwitches(PCSZ_COLLECTOR, &dcd->ds, FALSE);
1511
1512 dcd->amextracted = FALSE; // Say not busy
1513 dcd->stopflag = 0;
1514 memset(&cnri, 0, sizeof(CNRINFO));
1515 cnri.cb = sizeof(CNRINFO);
1516 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1517 MPFROMLONG(sizeof(CNRINFO)));
1518 cnri.cyLineSpacing = 0;
1519 cnri.cxTreeIndent = 12;
1520
1521 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_DETAIL));
1522 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES |
1523 CV_MINI | CV_FLOW);
1524 cnri.pSortRecord = (PVOID) SortCollectorCnr;
1525
1526 size = sizeof(ULONG);
1527 PrfQueryProfileData(fmprof, appname, "CollectorflWindowAttr",
1528 (PVOID) & cnri.flWindowAttr, &size);
1529 size = sizeof(MASK);
1530 if (PrfQueryProfileSize(fmprof, appname, "CollectorFilter", &size) &&
1531 size) {
1532 PrfQueryProfileData(fmprof, appname, "CollectorFilter", &dcd->mask,
1533 &size);
1534 SetMask(NULL, &dcd->mask);
1535 }
1536 else {
1537 dcd->mask.attrFile = (FILE_NORMAL | FILE_READONLY |
1538 FILE_DIRECTORY | FILE_HIDDEN |
1539 FILE_SYSTEM | FILE_ARCHIVED);
1540 dcd->mask.antiattr = 0;
1541 }
1542
1543 *(dcd->mask.prompt) = 0;
1544
1545 cnri.flWindowAttr |= CV_FLOW;
1546 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
1547 dcd->flWindowAttr = cnri.flWindowAttr;
1548 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1549 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1550 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1551 SetCnrCols(hwnd, FALSE);
1552 AdjustCnrColsForPref(hwnd, NULL, &dcd->ds, FALSE);
1553
1554 /* fix splitbar for collector container */
1555 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1556 size = sizeof(LONG);
1557 PrfQueryProfileData(fmprof, appname, "CollectorCnrSplitBar",
1558 &cnri.xVertSplitbar, &size);
1559 if (cnri.xVertSplitbar <= 0)
1560 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1561 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1562 MPFROMLONG(CMA_XVERTSPLITBAR));
1563
1564 if (xbeginthread(MakeObjWin,
1565 245760,
1566 dcd,
1567 pszSrcFile,
1568 __LINE__) == -1)
1569 {
1570 Runtime_Error(pszSrcFile, __LINE__,
1571 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1572 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1573 return 0;
1574 }
1575 else
1576 DosSleep(32); // Let object window get started
1577 }
1578 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1579 DIR_FILTER), &dcd->mask, FALSE);
1580 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1581 DIR_SORT), CollectorsortFlags, FALSE);
1582 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1583 DIR_VIEW), dcd->flWindowAttr);
1584 }
1585 else {
1586 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1587 return 0;
1588 }
1589 return 0;
1590
1591 case WM_MENUEND:
1592 if (dcd) {
1593 HWND hwndMenu = (HWND) mp2;
1594
1595 if (hwndMenu == CollectorCnrMenu || hwndMenu == CollectorFileMenu ||
1596 hwndMenu == CollectorDirMenu) {
1597 MarkAll(hwnd, TRUE, FALSE, TRUE);
1598 if (dcd->cnremphasized) {
1599 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1600 MPFROM2SHORT(FALSE, CRA_SOURCE));
1601 dcd->cnremphasized = FALSE;
1602 }
1603 }
1604 }
1605 break;
1606
1607 case UM_OPENWINDOWFORME:
1608 if (dcd) {
1609 if (mp1 && !IsFile((CHAR *)mp1))
1610 OpenDirCnr(HWND_DESKTOP, hwndMain, dcd->hwndFrame, FALSE, (PSZ) mp1);
1611 else if (mp1 && IsFile(mp1) == 1 &&
1612 CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) != 2)
1613 StartArcCnr(HWND_DESKTOP,
1614 dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
1615 }
1616 return 0;
1617
1618 case MM_PORTHOLEINIT:
1619 if (dcd) {
1620 switch (SHORT1FROMMP(mp1)) {
1621 case 0:
1622 case 1:
1623 {
1624 ULONG wmsg;
1625
1626 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1627 PortholeInit((HWND) WinSendMsg(dcd->hwndClient, wmsg, MPVOID,
1628 MPVOID), mp1, mp2);
1629 }
1630 break;
1631 }
1632 }
1633 break;
1634
1635 case UM_INITMENU:
1636 case WM_INITMENU:
1637 if (dcd) {
1638 switch (SHORT1FROMMP(mp1)) {
1639 case IDM_VIEWSMENU:
1640 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1641 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1642 (dcd->lastselection != NULL));
1643 CopyPresParams((HWND) mp2, hwnd);
1644 break;
1645
1646 case IDM_DETAILSSETUP:
1647 SetDetailsSwitches((HWND) mp2, &dcd->ds);
1648 break;
1649
1650 case IDM_COMMANDSMENU:
1651 SetupCommandMenu((HWND) mp2, hwnd);
1652 break;
1653
1654 case IDM_SORTSUBMENU:
1655 SetSortChecks((HWND) mp2, CollectorsortFlags);
1656 break;
1657 }
1658 dcd->hwndLastMenu = (HWND) mp2;
1659 }
1660 if (msg == WM_INITMENU)
1661 break;
1662 return 0;
1663
1664 case UM_COLLECTFROMFILE:
1665 if (mp1) {
1666# ifdef FORTIFY
1667 Fortify_EnterScope();
1668 Fortify_BecomeOwner(mp1);
1669# endif
1670 if (!dcd) {
1671 Runtime_Error(pszSrcFile, __LINE__, NULL);
1672 free(mp1);
1673 }
1674 else {
1675 if (!PostMsg(dcd->hwndObject, UM_COLLECTFROMFILE, mp1, mp2)) {
1676 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
1677 free(mp1);
1678 }
1679 }
1680# ifdef FORTIFY
1681 DosSleep(1); // Let receiver take ownership
1682 Fortify_LeaveScope();
1683# endif
1684 }
1685 return 0;
1686
1687 case UM_COMMAND:
1688 if (mp1) {
1689 if (dcd) {
1690 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1691 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
1692 FreeListInfo((LISTINFO *) mp1);
1693 }
1694 else
1695 return (MRESULT) TRUE;
1696 }
1697 else
1698 FreeListInfo((LISTINFO *) mp1);
1699 }
1700 return 0;
1701
1702 case UM_NOTIFY:
1703 if (mp2)
1704 AddNote((CHAR *)mp2);
1705 return 0;
1706
1707 case WM_COMMAND:
1708 DosError(FERR_DISABLEHARDERR);
1709 if (dcd) {
1710 switch (SHORT1FROMMP(mp1)) {
1711 case IDM_SETTARGET:
1712 SetTargetDir(hwnd, FALSE);
1713 break;
1714
1715 case IDM_CONTEXTMENU:
1716 {
1717 PCNRITEM pci;
1718
1719 pci = (PCNRITEM) CurrentRecord(hwnd);
1720 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(COLLECTOR_CNR,
1721 CN_CONTEXTMENU),
1722 MPFROMP(pci));
1723 }
1724 break;
1725
1726 case IDM_SHOWALLFILES:
1727 {
1728 PCNRITEM pci;
1729
1730 pci = WinSendMsg(hwnd,
1731 CM_QUERYRECORDEMPHASIS,
1732 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1733 if (pci && (INT) pci != -1) {
1734 static CHAR dirname[CCHMAXPATH];
1735
1736 strcpy(dirname, pci->pszFileName);
1737 MakeValidDir(dirname);
1738 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1739 }
1740 }
1741 break;
1742
1743 case IDM_BEGINEDIT:
1744 OpenEdit(hwnd);
1745 break;
1746
1747 case IDM_ENDEDIT:
1748 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1749 break;
1750
1751 case IDM_SHOWSELECT:
1752 QuickPopup(hwnd, dcd,
1753 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
1754 IDM_SELECTSUBMENU);
1755 break;
1756
1757 case IDM_SHOWSORT:
1758 QuickPopup(hwnd, dcd,
1759 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
1760 IDM_SORTSUBMENU);
1761 break;
1762
1763 case IDM_VIEWORARC:
1764 {
1765 SWP swp;
1766 PCNRITEM pci;
1767
1768 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1769 MPFROMLONG(CMA_FIRST),
1770 MPFROMSHORT(CRA_CURSORED));
1771 if (pci && (INT) pci != -1) {
1772 WinQueryWindowPos(dcd->hwndFrame, &swp);
1773 DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp,
1774 pci->pszFileName);
1775 }
1776 }
1777 break;
1778
1779 case IDM_SEEALL:
1780 StartSeeAll(HWND_DESKTOP, FALSE, NULL);
1781 break;
1782
1783 case IDM_COLLECTSELECT:
1784 {
1785 CHAR filename[CCHMAXPATH], *p, *pp;
1786
1787 strcpy(filename, PCSZ_STARDOTLST);
1788 size = CCHMAXPATH;
1789 PrfQueryProfileData(fmprof, appname, "SaveToListName",
1790 filename, &size);
1791 pp = strrchr(filename, '\\');
1792 if (!pp)
1793 pp = filename;
1794 p = strrchr(pp, '.');
1795 if (p && *(p + 1) && p > pp + 1) {
1796 if (pp > filename)
1797 pp++;
1798 *pp = '*';
1799 pp++;
1800 if (p > pp)
1801 memmove(pp, p, strlen(p) + 1);
1802 }
1803 if (insert_filename(hwnd, filename, FALSE, FALSE)) {
1804# ifdef FORTIFY
1805 Fortify_EnterScope();
1806# endif
1807 p = xstrdup(filename, pszSrcFile, __LINE__);
1808 if (p) {
1809 if (!PostMsg(hwnd, UM_COLLECTFROMFILE, MPFROMP(p), MPVOID))
1810 free(p);
1811 }
1812# ifdef FORTIFY
1813 DosSleep(1); // Let receiver take ownership
1814 Fortify_LeaveScope();
1815# endif
1816 }
1817 }
1818 break;
1819
1820 case IDM_COLLECTORVIEWSETTINGS:
1821 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1822 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_COLLECTORVIEWSETTINGS), mp2);
1823 else {
1824 WinDlgBox(HWND_DESKTOP,
1825 hwnd,
1826 CfgDlgProc,
1827 FM3ModHandle,
1828 CFG_FRAME,
1829 MPFROMLONG(IDM_COLLECTORVIEWSETTINGS));
1830 }
1831 break;
1832
1833 case IDM_RESELECT:
1834 SelectList(hwnd, FALSE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1835 break;
1836
1837 case IDM_WALKDIR:
1838 case IDM_OPENDIRWINDOW:
1839 case IDM_OPENDIRICON:
1840 case IDM_OPENDIRDETAILS:
1841 case IDM_OPENDIRTREE:
1842 {
1843 CHAR newpath[CCHMAXPATH];
1844 PCNRITEM pci;
1845
1846 pci = (PCNRITEM) CurrentRecord(hwnd);
1847 if (pci && (INT) pci != -1) {
1848 strcpy(newpath, pci->pszFileName);
1849 MakeValidDir(newpath);
1850 }
1851 else
1852 strcpy(newpath, pFM2SaveDirectory);
1853 if (*newpath) {
1854 switch (SHORT1FROMMP(mp1)) {
1855 case IDM_WALKDIR:
1856 WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkAllDlgProc,
1857 FM3ModHandle, WALK_FRAME, MPFROMP(newpath));
1858 break;
1859 case IDM_OPENDIRWINDOW:
1860 WinSendMsg(hwnd, UM_OPENWINDOWFORME, MPFROMP(newpath), MPVOID);
1861 break;
1862 case IDM_OPENDIRICON:
1863 OpenObject(newpath, PCSZ_ICON, hwnd);
1864 break;
1865 case IDM_OPENDIRDETAILS:
1866 OpenObject(newpath, Details, hwnd);
1867 break;
1868 case IDM_OPENDIRTREE:
1869 OpenObject(newpath, PCSZ_TREE, hwnd);
1870 break;
1871 default:
1872 break;
1873 }
1874 }
1875 }
1876 break;
1877
1878 case IDM_HELP:
1879 if (hwndHelp)
1880 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
1881 MPFROM2SHORT(HELP_COLLECT, 0),
1882 MPFROMSHORT(HM_RESOURCEID));
1883 break;
1884
1885 case IDM_SORTNONE:
1886 case IDM_SORTSMARTNAME:
1887 case IDM_SORTNAME:
1888 case IDM_SORTFILENAME:
1889 case IDM_SORTSIZE:
1890 case IDM_SORTEASIZE:
1891 case IDM_SORTFIRST:
1892 case IDM_SORTLAST:
1893 case IDM_SORTLWDATE:
1894 case IDM_SORTLADATE:
1895 case IDM_SORTCRDATE:
1896 case IDM_SORTSUBJECT:
1897 savedSortFlags = CollectorsortFlags;
1898 CollectorsortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1899 case IDM_SORTDIRSFIRST:
1900 case IDM_SORTDIRSLAST:
1901 case IDM_SORTREVERSE:
1902 switch (SHORT1FROMMP(mp1)) {
1903 case IDM_SORTSUBJECT:
1904 CollectorsortFlags |= SORT_SUBJECT;
1905 break;
1906 case IDM_SORTNONE:
1907 CollectorsortFlags |= SORT_NOSORT;
1908 break;
1909 case IDM_SORTSMARTNAME:
1910 if (~savedSortFlags & SORT_FILENAME)
1911 CollectorsortFlags |= SORT_FILENAME;
1912 break;
1913 case IDM_SORTFILENAME:
1914 CollectorsortFlags |= SORT_FILENAME;
1915 break;
1916 case IDM_SORTSIZE:
1917 CollectorsortFlags |= SORT_SIZE;
1918 break;
1919 case IDM_SORTEASIZE:
1920 CollectorsortFlags |= SORT_EASIZE;
1921 break;
1922 case IDM_SORTFIRST:
1923 CollectorsortFlags |= SORT_FIRSTEXTENSION;
1924 break;
1925 case IDM_SORTLAST:
1926 CollectorsortFlags |= SORT_LASTEXTENSION;
1927 break;
1928 case IDM_SORTLWDATE:
1929 CollectorsortFlags |= SORT_LWDATE;
1930 break;
1931 case IDM_SORTLADATE:
1932 CollectorsortFlags |= SORT_LADATE;
1933 break;
1934 case IDM_SORTCRDATE:
1935 CollectorsortFlags |= SORT_CRDATE;
1936 break;
1937 case IDM_SORTDIRSFIRST:
1938 if (CollectorsortFlags & SORT_DIRSFIRST)
1939 CollectorsortFlags &= (~SORT_DIRSFIRST);
1940 else {
1941 CollectorsortFlags |= SORT_DIRSFIRST;
1942 CollectorsortFlags &= (~SORT_DIRSLAST);
1943 }
1944 break;
1945 case IDM_SORTDIRSLAST:
1946 if (CollectorsortFlags & SORT_DIRSLAST)
1947 CollectorsortFlags &= (~SORT_DIRSLAST);
1948 else {
1949 CollectorsortFlags |= SORT_DIRSLAST;
1950 CollectorsortFlags &= (~SORT_DIRSFIRST);
1951 }
1952 break;
1953 case IDM_SORTREVERSE:
1954 if (CollectorsortFlags & SORT_REVERSE)
1955 CollectorsortFlags &= (~SORT_REVERSE);
1956 else
1957 CollectorsortFlags |= SORT_REVERSE;
1958 break;
1959 }
1960 PrfWriteProfileData(fmprof, appname, "CollectorSort",
1961 &CollectorsortFlags, sizeof(INT));
1962 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1963 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1964 DIR_SORT), CollectorsortFlags, FALSE);
1965 break;
1966
1967 case IDM_COLLECTFROMCLIP:
1968 {
1969 LISTINFO *li;
1970# ifdef FORTIFY
1971 Fortify_EnterScope();
1972# endif
1973 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1974 if (li) {
1975 li->list = ListFromClipboard(hwnd);
1976 if (!li->list || !li->list[0])
1977 FreeListInfo(li);
1978 else {
1979 li->type = IDM_COLLECT;
1980 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1981 FreeListInfo(li);
1982 }
1983 }
1984# ifdef FORTIFY
1985 DosSleep(1); // Let receiver take ownership
1986 Fortify_LeaveScope();
1987# endif
1988 }
1989 break;
1990
1991 case IDM_REMOVE:
1992 if (fAutoView && hwndMain)
1993 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1994 dcd->suspendview = 1;
1995 RemoveAll(hwnd, &dcd->ullTotalBytes, &dcd->totalfiles);
1996 dcd->suspendview = 0;
1997 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1998 break;
1999
2000 case IDM_CLEARCNR:
2001 {
2002 PCNRITEM pci;
2003
2004 pci = (PCNRITEM) WinSendMsg(hwnd,
2005 CM_QUERYRECORD,
2006 MPVOID,
2007 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
2008 if (pci && (INT) pci != -1) {
2009 RemoveCnrItems(hwnd, NULL, 0, CMA_FREE | CMA_INVALIDATE);
2010 dcd->ullTotalBytes = dcd->selectedbytes = dcd->selectedfiles =
2011 dcd->totalfiles = 0;
2012 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2013 }
2014 }
2015 break;
2016
2017 case DID_CANCEL:
2018 if (dcd->amextracted)
2019 dcd->stopflag = 1; // Request cancel
2020 break;
2021
2022 case IDM_COLLECTOR:
2023 if (mp2) {
2024 LISTINFO *li;
2025# ifdef FORTIFY
2026 Fortify_EnterScope();
2027# endif
2028 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2029 if (li) {
2030 li->list = mp2;
2031 if (!li->list || !li->list[0])
2032 FreeListInfo(li);
2033 else {
2034 li->type = IDM_COLLECT;
2035 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
2036 FreeListInfo(li);
2037 }
2038 }
2039 else
2040 FreeList(mp2);
2041# ifdef FORTIFY
2042 DosSleep(1); // Let receiver take ownership
2043 Fortify_LeaveScope();
2044# endif
2045 }
2046 break;
2047
2048 case IDM_UNDELETE:
2049 {
2050 PCNRITEM pci;
2051 CHAR path[CCHMAXPATH];
2052 HOBJECT hObject;
2053 HWND hwndDesktop;
2054
2055 hObject = WinQueryObject("<XWP_TRASHCAN>");
2056 if (hObject != NULLHANDLE && fTrashCan) {
2057 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
2058 WinSetFocus(HWND_DESKTOP, hwndDesktop);
2059 WinOpenObject(hObject, 0, TRUE);
2060 }
2061 else {
2062 pci = (PCNRITEM) CurrentRecord(hwnd);
2063 if (pci && (INT) pci != -1) {
2064 strcpy(path, pci->pszFileName);
2065 MakeValidDir(path);
2066 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
2067 UNDEL_FRAME, MPFROMP(path));
2068 }
2069 }
2070 }
2071 break;
2072
2073 case IDM_GREP:
2074 case UM_GREP:
2075 if (dcd->amextracted) {
2076 saymsg(MB_OK | MB_ICONASTERISK,
2077 hwnd,
2078 GetPString(IDS_WARNINGTEXT),
2079 "Collector busy - please try again later");
2080 }
2081 else {
2082 GREPINFO *GrepInfo;
2083
2084 GrepInfo = xmallocz(sizeof(GREPINFO), pszSrcFile, __LINE__);
2085 if (GrepInfo) {
2086 GrepInfo->hwnd = &hwnd;
2087 if (msg == UM_GREP && mp2)
2088 GrepInfo->szGrepPath = mp2;
2089 if (WinDlgBox(HWND_DESKTOP, hwnd, GrepDlgProc,
2090 FM3ModHandle, GREP_FRAME, (PVOID) GrepInfo)) {
2091 free(GrepInfo);
2092 dcd->amextracted = TRUE; // Say busy scanning
2093 disable_menuitem(WinWindowFromID
2094 (WinQueryWindow(hwndMain, QW_PARENT), FID_MENU),
2095 IDM_GREP, TRUE);
2096 disable_menuitem(TreeMenu, IDM_GREP, TRUE);
2097 disable_menuitem(DirMenu, IDM_GREP, TRUE);
2098 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2099 }
2100 else
2101 free(GrepInfo);
2102 }
2103 }
2104 break;
2105
2106 case IDM_RESORT:
2107 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
2108 break;
2109
2110 case IDM_FILTER:
2111 {
2112 BOOL empty = FALSE;
2113 PCNRITEM pci;
2114 CHAR *p;
2115
2116 if (!*dcd->mask.szMask) {
2117 empty = TRUE;
2118 pci = (PCNRITEM) CurrentRecord(hwnd);
2119 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
2120 p = strrchr(pci->pszFileName, '\\');
2121 if (p) {
2122 p++;
2123 strcpy(dcd->mask.szMask, p);
2124 }
2125 }
2126 }
2127 *(dcd->mask.prompt) = 0;
2128
2129 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2130 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
2131 size = sizeof(MASK);
2132 PrfWriteProfileData(fmprof, appname, "CollectorFilter",
2133 &dcd->mask, size);
2134 dcd->suspendview = 1;
2135 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2136 dcd->suspendview = 0;
2137 if (fAutoView && hwndMain) {
2138 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
2139 MPFROMLONG(CMA_FIRST),
2140 MPFROMSHORT(CRA_CURSORED));
2141 if (pci && (INT) pci != -1 &&
2142 (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
2143 DRIVE_SLOW)))
2144 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName),
2145 MPVOID);
2146 else
2147 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2148 }
2149 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2150 }
2151 else if (empty)
2152 *dcd->mask.szMask = 0;
2153 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2154 DIR_FILTER), &dcd->mask, FALSE);
2155 }
2156 break;
2157
2158 case IDM_UNHIDEALL:
2159 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2160 break;
2161
2162 case IDM_HIDEALL:
2163 if (fAutoView && hwndMain)
2164 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2165 dcd->suspendview = 1;
2166 HideAll(hwnd);
2167 dcd->suspendview = 0;
2168 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2169 break;
2170
2171 case IDM_SELECTLIST:
2172 case IDM_SELECTALL:
2173 case IDM_DESELECTALL:
2174 case IDM_SELECTALLFILES:
2175 case IDM_DESELECTALLFILES:
2176 case IDM_SELECTALLDIRS:
2177 case IDM_DESELECTALLDIRS:
2178 case IDM_SELECTMASK:
2179 case IDM_DESELECTMASK:
2180 case IDM_INVERT:
2181 case IDM_SELECTCLIP:
2182 case IDM_DESELECTCLIP:
2183 {
2184 PCNRITEM pci;
2185
2186 pci = (PCNRITEM) CurrentRecord(hwnd);
2187 if ((INT) pci == -1)
2188 pci = NULL;
2189 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2190 if (pci) {
2191 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2192 pci->rc.flRecordAttr |= CRA_FILTERED;
2193 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2194 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2195 break;
2196 }
2197 }
2198 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2199 }
2200 break;
2201
2202 case IDM_RESCAN:
2203 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
2204 break;
2205
2206 case IDM_SHOWLNAMES:
2207 case IDM_SHOWSUBJECT:
2208 case IDM_SHOWEAS:
2209 case IDM_SHOWSIZE:
2210 case IDM_SHOWICON:
2211 case IDM_SHOWLWDATE:
2212 case IDM_SHOWLWTIME:
2213 case IDM_SHOWLADATE:
2214 case IDM_SHOWLATIME:
2215 case IDM_SHOWCRDATE:
2216 case IDM_SHOWCRTIME:
2217 case IDM_SHOWATTR:
2218 AdjustDetailsSwitches(hwnd, dcd->hwndLastMenu,
2219 SHORT1FROMMP(mp1), NULL,
2220 PCSZ_COLLECTOR, &dcd->ds, FALSE);
2221 break;
2222
2223 case IDM_ICON:
2224 case IDM_TEXT:
2225 case IDM_DETAILS:
2226 case IDM_NAME:
2227 case IDM_MINIICONS:
2228 case IDM_DETAILSTITLES:
2229 {
2230 CNRINFO cnri;
2231
2232 memset(&cnri, 0, sizeof(CNRINFO));
2233 cnri.cb = sizeof(CNRINFO);
2234 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2235 MPFROMLONG(sizeof(CNRINFO)));
2236 switch (SHORT1FROMMP(mp1)) {
2237 case IDM_ICON:
2238 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2239 CV_DETAIL | CV_NAME));
2240 cnri.flWindowAttr |= CV_ICON;
2241 break;
2242 case IDM_NAME:
2243 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2244 CV_DETAIL | CV_NAME));
2245 cnri.flWindowAttr |= CV_NAME;
2246 break;
2247 case IDM_TEXT:
2248 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2249 CV_DETAIL | CV_NAME));
2250 cnri.flWindowAttr |= CV_TEXT;
2251 break;
2252 case IDM_DETAILS:
2253 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2254 CV_DETAIL | CV_NAME));
2255 cnri.flWindowAttr |= CV_DETAIL;
2256 break;
2257 case IDM_MINIICONS:
2258 if (cnri.flWindowAttr & CV_MINI)
2259 cnri.flWindowAttr &= (~CV_MINI);
2260 else
2261 cnri.flWindowAttr |= CV_MINI;
2262 break;
2263 case IDM_DETAILSTITLES:
2264 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2265 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2266 else
2267 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2268 break;
2269 }
2270 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2271 cnri.flWindowAttr |= CV_FLOW;
2272 dcd->flWindowAttr = cnri.flWindowAttr;
2273 PrfWriteProfileData(fmprof, appname, "CollectorflWindowAttr",
2274 &cnri.flWindowAttr, sizeof(ULONG));
2275 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2276 MPFROMLONG(CMA_FLWINDOWATTR));
2277 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2278 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2279 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2280 DIR_VIEW), dcd->flWindowAttr);
2281 }
2282 break;
2283
2284 case IDM_SAVETOLIST:
2285 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2286 SAV_FRAME, MPFROMP(&hwnd));
2287 break;
2288
2289 case IDM_SIZES:
2290 {
2291 PCNRITEM pci;
2292
2293 pci = (PCNRITEM) CurrentRecord(hwnd);
2294 if (pci && (INT) pci != -1)
2295 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DirSizeProc, FM3ModHandle,
2296 DSZ_FRAME, pci->pszFileName);
2297 }
2298 break;
2299
2300 case IDM_MKDIR:
2301 {
2302 PCNRITEM pci;
2303
2304 pci = (PCNRITEM) CurrentRecord(hwnd);
2305 PMMkDir(dcd->hwndParent, (pci && (INT) pci != -1) ?
2306 pci->pszFileName : NULL, FALSE);
2307 }
2308 break;
2309
2310 case IDM_DOITYOURSELF:
2311 case IDM_UPDATE:
2312 case IDM_COLLECTFROMFILE:
2313 case IDM_OPENWINDOW:
2314 case IDM_OPENSETTINGS:
2315 case IDM_OPENDEFAULT:
2316 case IDM_OPENICON:
2317 case IDM_OPENDETAILS:
2318 case IDM_OPENTREE:
2319 case IDM_OBJECT:
2320 case IDM_SHADOW:
2321 case IDM_SHADOW2:
2322 case IDM_DELETE:
2323 case IDM_PERMDELETE:
2324 case IDM_PRINT:
2325 case IDM_ATTRS:
2326 case IDM_INFO:
2327 case IDM_COPY:
2328 case IDM_MOVE:
2329 case IDM_WPSCOPY:
2330 case IDM_WPSMOVE:
2331 case IDM_COPYPRESERVE:
2332 case IDM_MOVEPRESERVE:
2333 case IDM_WILDCOPY:
2334 case IDM_WILDMOVE:
2335 case IDM_RENAME:
2336 case IDM_COMPARE:
2337 case IDM_EAS:
2338 case IDM_SUBJECT:
2339 case IDM_VIEW:
2340 case IDM_VIEWTEXT:
2341 case IDM_VIEWBINARY:
2342 case IDM_VIEWARCHIVE:
2343 case IDM_EDIT:
2344 case IDM_EDITTEXT:
2345 case IDM_EDITBINARY:
2346 case IDM_SAVETOCLIP:
2347 case IDM_SAVETOCLIPFILENAME:
2348 case IDM_APPENDTOCLIP:
2349 case IDM_APPENDTOCLIPFILENAME:
2350 case IDM_ARCHIVE:
2351 case IDM_ARCHIVEM:
2352 case IDM_EXTRACT:
2353 case IDM_MCIPLAY:
2354 case IDM_UUDECODE:
2355 case IDM_UNLOCKFILE:
2356 case IDM_MERGE:
2357 {
2358 LISTINFO *li;
2359 ULONG action = UM_ACTION;
2360# ifdef FORTIFY
2361 Fortify_EnterScope();
2362# endif
2363 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2364 if (li) {
2365 li->type = SHORT1FROMMP(mp1);
2366 li->hwnd = hwnd;
2367 li->list = BuildList(hwnd);
2368 if (li->list) {
2369 switch (SHORT1FROMMP(mp1)) {
2370 case IDM_DOITYOURSELF:
2371 case IDM_APPENDTOCLIP:
2372 case IDM_APPENDTOCLIPFILENAME:
2373 case IDM_SAVETOCLIP:
2374 case IDM_SAVETOCLIPFILENAME:
2375 case IDM_ARCHIVE:
2376 case IDM_ARCHIVEM:
2377 case IDM_DELETE:
2378 case IDM_PERMDELETE:
2379 case IDM_ATTRS:
2380 case IDM_PRINT:
2381 case IDM_SHADOW:
2382 case IDM_SHADOW2:
2383 case IDM_OBJECT:
2384 case IDM_VIEW:
2385 case IDM_VIEWTEXT:
2386 case IDM_VIEWBINARY:
2387 case IDM_EDIT:
2388 case IDM_EDITTEXT:
2389 case IDM_EDITBINARY:
2390 case IDM_MCIPLAY:
2391 case IDM_UPDATE:
2392 case IDM_INFO:
2393 case IDM_EAS:
2394 action = UM_MASSACTION;
2395 break;
2396 }
2397 if (li->type == IDM_SHADOW || li->type == IDM_OBJECT ||
2398 li->type == IDM_SHADOW2)
2399 *li->targetpath = 0;
2400 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2401 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
2402 FreeListInfo(li);
2403 }
2404 else if (fUnHilite)
2405 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2406 }
2407 else
2408 free(li);
2409 }
2410# ifdef FORTIFY
2411 Fortify_LeaveScope();
2412# endif
2413 }
2414 break;
2415
2416 default:
2417 if (!cmdloaded)
2418 load_commands();
2419 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2420 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2421 INT x;
2422
2423 x = SHORT1FROMMP(mp1); // - IDM_COMMANDSTART;
2424 if (x >= 0) {
2425 //x++;
2426 RunCommand(hwnd, x);
2427 if (fUnHilite)
2428 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2429 }
2430 }
2431 break;
2432 }
2433 }
2434 return 0;
2435
2436 case UM_FIXCNRMLE:
2437 case UM_FIXEDITNAME:
2438 return CommonCnrProc(hwnd, msg, mp1, mp2);
2439
2440 case UM_FILESMENU:
2441 {
2442 PCNRITEM pci;
2443 HWND menuHwnd = (HWND) 0;
2444
2445 pci = (PCNRITEM) CurrentRecord(hwnd);
2446 if (pci && (INT) pci != -1) {
2447 if (pci->attrFile & FILE_DIRECTORY)
2448 menuHwnd = CheckMenu(hwnd, &CollectorDirMenu, COLLECTORDIR_POPUP);
2449 else
2450 menuHwnd = CheckMenu(hwnd, &CollectorFileMenu, COLLECTORFILE_POPUP);
2451 }
2452 return MRFROMLONG(menuHwnd);
2453 }
2454
2455 case WM_CONTROL:
2456 DosError(FERR_DISABLEHARDERR);
2457 if (dcd) {
2458 switch (SHORT2FROMMP(mp1)) {
2459 case CN_CONTEXTMENU:
2460 {
2461 PCNRITEM pci = (PCNRITEM) mp2;
2462
2463 if (pci) {
2464 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
2465 MPFROM2SHORT(TRUE, CRA_CURSORED));
2466 MarkAll(hwnd, FALSE, FALSE, TRUE);
2467 if (pci->attrFile & FILE_DIRECTORY)
2468 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorDirMenu,
2469 COLLECTORDIR_POPUP);
2470 else
2471 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorFileMenu,
2472 COLLECTORFILE_POPUP);
2473 }
2474 else {
2475 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorCnrMenu,
2476 COLLECTORCNR_POPUP);
2477 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2478 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2479 MPFROM2SHORT(TRUE, CRA_SOURCE));
2480 dcd->cnremphasized = TRUE;
2481 }
2482 }
2483 if (dcd->hwndLastMenu) {
2484 if (dcd->hwndLastMenu == CollectorCnrMenu) {
2485 SetViewMenu(dcd->hwndLastMenu, dcd->flWindowAttr);
2486 SetDetailsSwitches(dcd->hwndLastMenu, &dcd->ds);
2487 CopyPresParams(dcd->hwndLastMenu, hwnd);
2488 if (dcd->flWindowAttr & CV_MINI)
2489 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2490 disable_menuitem(dcd->hwndLastMenu, DID_CANCEL,
2491 !dcd->amextracted);
2492 disable_menuitem(dcd->hwndLastMenu, IDM_GREP, dcd->amextracted);
2493 }
2494 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2495 if (dcd->cnremphasized) {
2496 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2497 MPFROM2SHORT(FALSE, CRA_SOURCE));
2498 dcd->cnremphasized = TRUE;
2499 }
2500 MarkAll(hwnd, TRUE, FALSE, TRUE);
2501 }
2502 }
2503 }
2504 break;
2505
2506 case CN_DROPHELP:
2507 if (mp2) {
2508 PDRAGINFO pDInfo;
2509 PCNRITEM pci;
2510 ULONG numitems;
2511 USHORT usOperation;
2512
2513 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2514 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2515 if (!DrgAccessDraginfo(pDInfo)) {
2516 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2517 PCSZ_DRGACCESSDRAGINFO);
2518 return 0;
2519 }
2520 numitems = DrgQueryDragitemCount(pDInfo);
2521 usOperation = pDInfo->usOperation;
2522 if (usOperation == DO_DEFAULT)
2523 usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
2524 FreeDragInfoData(hwnd, pDInfo);
2525 saymsg(MB_ENTER | MB_ICONASTERISK,
2526 hwnd,
2527 GetPString(IDS_DROPHELPHDRTEXT),
2528 GetPString(IDS_DROPHELPTEXT),
2529 numitems,
2530 &"s"[numitems == 1],
2531 (pci) ? NullStr : GetPString(IDS_NOTEXT),
2532 (pci) ? NullStr : " ",
2533 (pci) ? pci->pszFileName : NullStr,
2534 (pci) ? " " : NullStr,
2535 GetPString((usOperation == DO_COPY) ?
2536 IDS_COPYTEXT :
2537 (usOperation == DO_LINK) ?
2538 IDS_LINKTEXT : IDS_MOVETEXT));
2539 }
2540 return 0;
2541
2542 case CN_DRAGLEAVE:
2543 if (mp2) {
2544 PDRAGINFO pDInfo;
2545
2546 // fixme to know why needed
2547 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2548 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
2549 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2550 }
2551 return 0;
2552
2553 case CN_DRAGAFTER:
2554 case CN_DRAGOVER:
2555 if (mp2) {
2556 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2557 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2558 PCNRITEM pci;
2559 USHORT uso;
2560
2561 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2562 // if(SHORT1FROMMP(mp1) == CN_DRAGAFTER)
2563 // pci = NULL;
2564 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2565 if (!DrgAccessDraginfo(pDInfo)) {
2566 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2567 PCSZ_DRGACCESSDRAGINFO);
2568 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2569 }
2570 if (pci) {
2571 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2572 DrgFreeDraginfo(pDInfo);
2573 return (MRFROM2SHORT(DOR_NODROP, 0));
2574 }
2575 uso = pDInfo->usOperation;
2576 if (uso == DO_DEFAULT)
2577 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
2578 if (!(pci->attrFile & FILE_DIRECTORY)) {
2579 if (uso != DO_LINK && uso != DO_MOVE && uso != DO_COPY) {
2580 DrgFreeDraginfo(pDInfo);
2581 return MRFROM2SHORT(DOR_NODROP, 0);
2582 }
2583 if (uso != DO_LINK &&
2584 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2585 DRIVE_NOTWRITEABLE)) {
2586 ARC_TYPE *info = NULL;
2587
2588 if (!fQuickArcFind &&
2589 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2590 DRIVE_SLOW))
2591 info = find_type(pci->pszFileName, NULL);
2592 else
2593 info = quick_find_type(pci->pszFileName, NULL);
2594 if (!info || ((uso == DO_MOVE && !info->move) ||
2595 (uso == DO_COPY && !info->create))) {
2596 DrgFreeDraginfo(pDInfo);
2597 return MRFROM2SHORT(DOR_NODROP, 0);
2598 }
2599 }
2600 }
2601 }
2602 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
2603 0); /* Index to DRAGITEM */
2604 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
2605 (CHAR *) DRM_OS2FILE, /* mechanisms and data */
2606 NULL)) {
2607 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2608 if (pci) {
2609 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
2610 DRIVE_NOTWRITEABLE)
2611 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2612 if (toupper(*pci->pszFileName) < 'C')
2613 return MRFROM2SHORT(DOR_DROP, DO_COPY);
2614 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2615 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2616 }
2617 else
2618 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2619 DO_COPY);
2620 }
2621 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2622 }
2623 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2624
2625 case CN_INITDRAG:
2626 if (mp2) {
2627 BOOL wasemphasized = FALSE;
2628 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2629 PCNRITEM pci;
2630
2631 if (pcd) {
2632 pci = (PCNRITEM) pcd->pRecord;
2633 if (pci) {
2634 if (pci->rc.flRecordAttr & CRA_SELECTED)
2635 wasemphasized = TRUE;
2636 if (IsRoot(pci->pszFileName))
2637 break;
2638 if (hwndStatus2)
2639 WinSetWindowText(hwndStatus2,
2640 (CHAR *) GetPString(IDS_DRAGFILEOBJTEXT));
2641 if (DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE)) {
2642 if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
2643 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2644 }
2645 if (hwndStatus2)
2646 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2647 }
2648 }
2649 }
2650 return 0;
2651
2652 case CN_DROP:
2653 if (mp2) {
2654 LISTINFO *li;
2655 ULONG action = UM_ACTION;
2656
2657 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
2658 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
2659 if (li) {
2660 if (!*li->targetpath) {
2661 li->type = IDM_COLLECT;
2662 action = UM_COLLECT;
2663 }
2664 else {
2665 if (li->list && li->list[0] && IsRoot(li->list[0]))
2666 li->type = DO_LINK;
2667 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2668 CHECKLIST cl;
2669
2670 memset(&cl, 0, sizeof(cl));
2671 cl.size = sizeof(cl);
2672 cl.flags = li->type;
2673 cl.list = li->list;
2674 cl.cmd = li->type;
2675 cl.prompt = li->targetpath;
2676 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2677 DropListProc, FM3ModHandle,
2678 DND_FRAME, MPFROMP(&cl));
2679 if (li->type == DID_ERROR)
2680 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2681 GetPString(IDS_DRAGDROPDIALOGTEXT));
2682 if (!li->type) {
2683 FreeListInfo(li);
2684 return 0;
2685 }
2686 li->list = cl.list;
2687 if (!li->list || !li->list[0]) {
2688 FreeListInfo(li);
2689 return 0;
2690 }
2691 }
2692 switch (li->type) {
2693 case DND_LAUNCH:
2694 strcat(li->targetpath, " %a");
2695 ExecOnList(dcd->hwndParent, li->targetpath,
2696 PROMPT | WINDOWED, NULL, NULL, li->list, NULL,
2697 pszSrcFile, __LINE__);
2698 FreeList(li->list);
2699 li->list = NULL;
2700 break;
2701 case DO_LINK:
2702 if (fLinkSetsIcon) {
2703 li->type = IDM_SETICON;
2704 action = UM_MASSACTION;
2705 }
2706 else
2707 li->type = IDM_COMPARE;
2708 break;
2709 case DND_EXTRACT:
2710 if (*li->targetpath && !IsFile(li->targetpath))
2711 li->type = IDM_EXTRACT;
2712 break;
2713 case DND_MOVE:
2714 li->type = IDM_MOVE;
2715 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2716 action = UM_MASSACTION;
2717 li->type = IDM_ARCHIVEM;
2718 }
2719 break;
2720 case DND_WILDMOVE:
2721 li->type = IDM_WILDMOVE;
2722 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2723 action = UM_MASSACTION;
2724 li->type = IDM_ARCHIVEM;
2725 }
2726 break;
2727 case DND_OBJECT:
2728 li->type = IDM_OBJECT;
2729 action = UM_MASSACTION;
2730 break;
2731 case DND_SHADOW:
2732 li->type = IDM_SHADOW;
2733 action = UM_MASSACTION;
2734 break;
2735 case DND_COMPARE:
2736 li->type = IDM_COMPARE;
2737 break;
2738 case DND_SETICON:
2739 action = UM_MASSACTION;
2740 li->type = IDM_SETICON;
2741 break;
2742 case DND_WILDCOPY:
2743 li->type = IDM_WILDCOPY;
2744 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2745 action = UM_MASSACTION;
2746 li->type = IDM_ARCHIVE;
2747 }
2748 break;
2749 case DND_COPY:
2750 li->type = IDM_COPY;
2751 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2752 action = UM_MASSACTION;
2753 li->type = IDM_ARCHIVE;
2754 }
2755 break;
2756 default:
2757 if (*li->arcname && li->info) {
2758 action = UM_MASSACTION;
2759 li->type =
2760 (li->type ==
2761 DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
2762 }
2763 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2764 action = UM_MASSACTION;
2765 li->type =
2766 (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2767 }
2768 else
2769 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2770 break;
2771 } // switch
2772 } // if !collect
2773 if (!li->list || !li->list[0])
2774 FreeListInfo(li);
2775 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
2776 FreeListInfo(li);
2777 else {
2778 USHORT usop = 0;
2779
2780 switch (li->type) {
2781 case IDM_COPY:
2782 case IDM_WILDCOPY:
2783 usop = DO_COPY;
2784 break;
2785 case IDM_MOVE:
2786 case IDM_WILDMOVE:
2787 case IDM_ARCHIVEM:
2788 usop = DO_MOVE;
2789 break;
2790 }
2791 if (usop)
2792 return MRFROM2SHORT(DOR_DROP, usop);
2793 }
2794 }
2795 }
2796 return 0;
2797
2798 case CN_BEGINEDIT:
2799 case CN_REALLOCPSZ:
2800 case CN_ENDEDIT:
2801 {
2802 MRESULT mre;
2803
2804 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
2805 if (mre != (MRESULT) - 1)
2806 return mre;
2807 }
2808 break;
2809
2810 case CN_EMPHASIS:
2811 if (mp2) {
2812 PNOTIFYRECORDEMPHASIS pre = mp2;
2813 PCNRITEM pci;
2814 CHAR s[CCHMAXPATH + 91], tb[81], tf[81], szDate[DATE_BUF_BYTES], *p;
2815
2816 pci = (PCNRITEM) ((pre) ? pre->pRecord : NULL);
2817 if (!pci) {
2818 if (hwndStatus2)
2819 WinSetWindowText(hwndStatus2, NullStr);
2820 if (fMoreButtons) {
2821 WinSetWindowText(hwndName, NullStr);
2822 WinSetWindowText(hwndDate, NullStr);
2823 WinSetWindowText(hwndAttr, NullStr);
2824 }
2825 if (hwndMain)
2826 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2827 break;
2828 }
2829 if (pre->fEmphasisMask & CRA_SELECTED) {
2830 if (pci->rc.flRecordAttr & CRA_SELECTED) {
2831 dcd->selectedbytes += (pci->cbFile + pci->easize);
2832 dcd->selectedfiles++;
2833 }
2834 else if (dcd->selectedfiles) {
2835 dcd->selectedbytes -= (pci->cbFile + pci->easize);
2836 dcd->selectedfiles--;
2837 }
2838 if (!dcd->suspendview) {
2839 commafmt(tf, sizeof(tf), dcd->selectedfiles);
2840 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
2841 sprintf(s, "%s / %s", tf, tb);
2842 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
2843 }
2844 }
2845 if (!dcd->suspendview &&
2846 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
2847 if (pre->fEmphasisMask & CRA_CURSORED) {
2848 if (pci->rc.flRecordAttr & CRA_CURSORED) {
2849 if (fSplitStatus && hwndStatus2) {
2850 if (pci->attrFile & FILE_DIRECTORY)
2851 p = pci->pszFileName;
2852 else {
2853 p = strrchr(pci->pszFileName, '\\');
2854 if (p) {
2855 if (*(p + 1))
2856 p++;
2857 else
2858 p = pci->pszFileName;
2859 }
2860 else
2861 p = pci->pszFileName;
2862 }
2863 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
2864 if (!fMoreButtons) {
2865 DateFormat(szDate, pci->date);
2866 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
2867 tb, szDate, pci->time.hours, TimeSeparator,
2868 pci->time.minutes, TimeSeparator, pci->time.seconds,
2869 pci->pszDispAttr, p);
2870 }
2871 else {
2872 if (pci->cbFile + pci->easize > 1024)
2873 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize,
2874 ' ');
2875 else
2876 *tf = 0;
2877 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
2878 tb,
2879 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
2880 }
2881 WinSetWindowText(hwndStatus2, s);
2882 }
2883 if (fMoreButtons) {
2884 WinSetWindowText(hwndName, pci->pszFileName);
2885 DateFormat(szDate, pci->date);
2886 sprintf(s, "%s %02u%s%02u%s%02u",
2887 szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
2888 TimeSeparator, pci->time.seconds);
2889 WinSetWindowText(hwndDate, s);
2890 WinSetWindowText(hwndAttr, pci->pszDispAttr);
2891 }
2892 }
2893 }
2894 }
2895 if (!dcd->suspendview && hwndMain &&
2896 (pre->fEmphasisMask & CRA_CURSORED) &&
2897 (pci->rc.flRecordAttr & CRA_CURSORED) &&
2898 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame)
2899 WinSendMsg(hwndMain, UM_LOADFILE,
2900 MPFROMP(((fComments
2901 || (pci->attrFile & FILE_DIRECTORY) ==
2902 0) ? pci->pszFileName : NULL)), MPVOID);
2903 }
2904 break;
2905
2906 case CN_ENTER:
2907 if (mp2) {
2908 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
2909 FILEFINDBUF3 ffb;
2910 HDIR hDir = HDIR_CREATE;
2911 ULONG nm = 1;
2912 APIRET status = 0;
2913
2914 SetShiftState();
2915 if (pci) {
2916 if (pci->rc.flRecordAttr & CRA_INUSE)
2917 break;
2918 DosError(FERR_DISABLEHARDERR);
2919 status = DosFindFirst(pci->pszFileName, &hDir,
2920 FILE_NORMAL | FILE_DIRECTORY |
2921 FILE_ARCHIVED | FILE_READONLY |
2922 FILE_HIDDEN | FILE_SYSTEM,
2923 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
2924 priority_bumped();
2925 if (!status) {
2926 DosFindClose(hDir);
2927 if (ffb.attrFile & FILE_DIRECTORY) {
2928 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
2929 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0),
2930 MPVOID);
2931 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
2932 (KC_CTRL | KC_SHIFT))
2933 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
2934 else if (shiftstate & KC_CTRL)
2935 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
2936 else
2937 OpenDirCnr(HWND_DESKTOP,
2938 hwndMain,
2939 dcd->hwndFrame, FALSE, pci->pszFileName);
2940 }
2941 else {
2942 SWP swp;
2943
2944 WinSendMsg(hwnd,
2945 CM_SETRECORDEMPHASIS,
2946 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
2947 WinQueryWindowPos(dcd->hwndFrame, &swp);
2948 DefaultViewKeys(hwnd,
2949 dcd->hwndFrame,
2950 dcd->hwndParent, &swp, pci->pszFileName);
2951 WinSendMsg(hwnd,
2952 CM_SETRECORDEMPHASIS,
2953 MPFROMP(pci),
2954 MPFROM2SHORT(FALSE, CRA_INUSE |
2955 ((fUnHilite) ? CRA_SELECTED : 0)));
2956 }
2957 }
2958 else
2959 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
2960 }
2961 }
2962 break;
2963 }
2964 }
2965 return 0;
2966
2967 case UM_LOADFILE:
2968 if (dcd && mp2) {
2969
2970 HWND hwnd;
2971
2972 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
2973 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
2974 (CHAR *)mp2, dcd->hwndFrame);
2975 else
2976 hwnd = StartMLEEditor(dcd->hwndParent,
2977 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
2978 free((CHAR *)mp2);
2979 return MRFROMLONG(hwnd);
2980 }
2981 return 0;
2982
2983 case UM_CLOSE:
2984 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
2985 QW_PARENT));
2986 return 0;
2987
2988 case UM_FOLDUP:
2989 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
2990 DosExit(EXIT_PROCESS, 1);
2991 return 0;
2992
2993 case WM_CLOSE:
2994 if (dcd) {
2995 dcd->namecanchange = TRUE;
2996 dcd->stopflag = 1;
2997 if (dcd->amextracted)
2998 return 0; // Can not close yet
2999 }
3000 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3001 if (dcd) {
3002 if (!dcd->dontclose && ParentIsDesktop(hwnd, dcd->hwndParent))
3003 PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
3004 if (dcd->hwndObject) {
3005 DosSleep(32); // Allow UM_FOLDUP to process
3006 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3007 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
3008 }
3009 }
3010 else
3011 WinSendMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
3012 return 0;
3013
3014 case WM_DESTROY:
3015 if (CollectorDirMenu)
3016 WinDestroyWindow(CollectorDirMenu);
3017 if (CollectorFileMenu)
3018 WinDestroyWindow(CollectorFileMenu);
3019 if (CollectorCnrMenu)
3020 WinDestroyWindow(CollectorCnrMenu);
3021 CollectorCnrMenu = CollectorFileMenu = CollectorDirMenu = (HWND) 0;
3022 Collector = (HWND) 0;
3023 EmptyCnr(hwnd);
3024 break;
3025 }
3026 if (dcd && dcd->oldproc){
3027 return dcd->oldproc(hwnd, msg, mp1, mp2);
3028 }
3029 else
3030 return PFNWPCnr(hwnd, msg, mp1, mp2);
3031}
3032
3033MRESULT EXPENTRY CollectorMenuProc(HWND hwnd, ULONG msg, MPARAM mp1,
3034 MPARAM mp2)
3035{
3036 PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
3037 static short sLastMenuitem;
3038
3039 switch (msg) {
3040 case WM_MOUSEMOVE: {
3041 if (fOtherHelp) {
3042 RECTL rectl;
3043 SHORT i, sCurrentMenuitem;
3044 SHORT MenuItems = 5;
3045 SHORT asMenuIDs[5] = {IDM_GREP,
3046 IDM_SEEALL,
3047 IDM_CLEARCNR,
3048 IDM_REMOVE,
3049 0};
3050 PCSZ szHelpString = NULL;
3051
3052 for (i=0; i<MenuItems; i++) {
3053 sCurrentMenuitem = asMenuIDs[i];
3054 oldMenuProc(hwnd,MM_QUERYITEMRECT,
3055 MPFROM2SHORT(asMenuIDs[i], FALSE),
3056 &rectl);
3057
3058 if (MOUSEMSG(&msg)->x > rectl.xLeft &&
3059 MOUSEMSG(&msg)->x < rectl.xRight &&
3060 MOUSEMSG(&msg)->y > rectl.yBottom &&
3061 MOUSEMSG(&msg)->y < rectl.yTop)
3062 break;
3063 } // for
3064
3065 switch (sCurrentMenuitem) {
3066 case 0:
3067 break;
3068 case IDM_GREP:
3069 szHelpString = GetPString(IDS_COLMENUSEEKSCANHELP);
3070 break;
3071 case IDM_SEEALL:
3072 szHelpString = GetPString(IDS_COLMENUSEEALLHELP);
3073 break;
3074 case IDM_CLEARCNR:
3075 szHelpString = GetPString(IDS_COLMENUCLEARCNRHELP);
3076 break;
3077 case IDM_REMOVE:
3078 szHelpString = GetPString(IDS_COLMENUREMOVECNRHELP);
3079 break;
3080 default:
3081 break;
3082 }
3083
3084 if (sLastMenuitem != sCurrentMenuitem && szHelpString) {
3085 sLastMenuitem = sCurrentMenuitem;
3086 MakeBubble(hwnd, TRUE, szHelpString);
3087 }
3088 else if (hwndBubble && !sCurrentMenuitem){
3089 sLastMenuitem = sCurrentMenuitem;
3090 WinDestroyWindow(hwndBubble);
3091 }
3092 }
3093 }
3094 }
3095 return oldMenuProc(hwnd, msg, mp1, mp2);
3096}
3097
3098HWND StartCollector(HWND hwndParent, INT flags)
3099{
3100 HWND hwndFrame = (HWND) 0;
3101 HWND hwndClient;
3102 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3103 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3104 USHORT id;
3105 DIRCNRDATA *dcd;
3106
3107 static USHORT idinc = 0;
3108
3109 if (ParentIsDesktop(hwndParent, hwndParent))
3110 FrameFlags |= (FCF_TASKLIST | FCF_SHELLPOSITION | FCF_MENU);
3111 if (Collector) {
3112 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
3113 QW_PARENT),
3114 QW_PARENT),
3115 HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE);
3116 return WinQueryWindow(WinQueryWindow(Collector, QW_PARENT), QW_PARENT);
3117 }
3118 hwndFrame = WinCreateStdWindow(hwndParent,
3119 WS_VISIBLE,
3120 &FrameFlags,
3121 (CHAR *) WC_COLLECTOR,
3122 NULL,
3123 WS_VISIBLE | fwsAnimate,
3124 FM3ModHandle, COLLECTOR_FRAME, &hwndClient);
3125 if (hwndFrame && hwndClient) {
3126 id = COLLECTOR_FRAME + idinc++;
3127 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3128# ifdef FORTIFY
3129 Fortify_EnterScope();
3130# endif
3131 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3132 if (!dcd) {
3133 Runtime_Error(pszSrcFile, __LINE__, NULL);
3134 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3135 hwndFrame = (HWND) 0;
3136 }
3137 else {
3138 dcd->size = sizeof(DIRCNRDATA);
3139 dcd->id = id;
3140 dcd->type = COLLECTOR_FRAME;
3141 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3142 dcd->hwndFrame = hwndFrame;
3143 dcd->hwndClient = hwndClient;
3144 if (flags & 4)
3145 dcd->dontclose = TRUE;
3146 {
3147 PFNWP oldproc;
3148
3149 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) CollectorFrameWndProc);
3150 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3151 }
3152 dcd->hwndCnr = WinCreateWindow(hwndClient,
3153 WC_CONTAINER,
3154 NULL,
3155 CCS_AUTOPOSITION | CCS_MINIICONS |
3156 CCS_MINIRECORDCORE | ulCnrType |
3157 WS_VISIBLE,
3158 0,
3159 0,
3160 0,
3161 0,
3162 hwndClient,
3163 HWND_TOP,
3164 (ULONG) COLLECTOR_CNR, NULL, NULL);
3165 if (!dcd->hwndCnr) {
3166 Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
3167 PCSZ_WINCREATEWINDOW);
3168 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3169 free(dcd);
3170 hwndFrame = (HWND) 0;
3171 }
3172 else {
3173 Collector = dcd->hwndCnr;
3174 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3175 WinSetWindowText(hwndFrame, (CHAR *) GetPString(IDS_COLLECTORTITLETEXT));
3176 if (FrameFlags & FCF_MENU) {
3177 PFNWP oldmenuproc;
3178 HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
3179
3180 oldmenuproc = WinSubclassWindow(hwndMenu, (PFNWP) CollectorMenuProc);
3181 WinSetWindowPtr(hwndMenu, QWL_USER, (PVOID) oldmenuproc);
3182 if (!fToolbar) {
3183 if (hwndMenu) {
3184
3185 WinSendMsg(hwndMenu,
3186 MM_DELETEITEM,
3187 MPFROM2SHORT(IDM_SEEALL, FALSE), MPVOID);
3188 WinSendMsg(hwndMenu,
3189 MM_DELETEITEM,
3190 MPFROM2SHORT(IDM_GREP, FALSE), MPVOID);
3191 WinSendMsg(hwndMenu,
3192 MM_DELETEITEM,
3193 MPFROM2SHORT(IDM_CLEARCNR, FALSE), MPVOID);
3194 WinSendMsg(hwndMenu,
3195 MM_DELETEITEM,
3196 MPFROM2SHORT(IDM_REMOVE, FALSE), MPVOID);
3197 }
3198 }
3199 }
3200 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3201 (PFNWP) CollectorCnrWndProc);
3202 {
3203 USHORT ids[] = { DIR_TOTALS,
3204 DIR_SELECTED,
3205 DIR_VIEW,
3206 DIR_SORT,
3207 DIR_FILTER,
3208 0
3209 };
3210
3211 CommonCreateTextChildren(dcd->hwndClient,
3212 WC_COLSTATUS, ids);
3213 }
3214 if (FrameFlags & FCF_SHELLPOSITION)
3215 PostMsg(hwndClient, UM_SIZE, MPVOID, MPVOID);
3216 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3217 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3218 }
3219 }
3220# ifdef FORTIFY
3221 DosSleep(1); // Let receiver take ownership
3222 Fortify_LeaveScope();
3223# endif
3224 }
3225 return hwndFrame;
3226}
3227
3228#pragma alloc_text(COLLECTOR,CollectorCnrWndProc,CollectorObjWndProc)
3229#pragma alloc_text(COLLECTOR,CollectorClientWndProc,CollectorTextProc)
3230#pragma alloc_text(COLLECTOR,CollectorFrameWndProc)
3231#pragma alloc_text(STARTUP,StartCollector)
Note: See TracBrowser for help on using the repository browser.