source: trunk/dll/collect.c@ 1664

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

Changes to use Unlock to unlock files if Unlock.exe is in path both from menu/toolbar and as part of copy, move and delete operations. Changes to allow copy and move over readonly files with a warning dialog; also added a warning dialog for delete of readonly files

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