source: trunk/dll/collect.c@ 1612

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

Rework UM_COLLECT to avoid freeing wrong CNRITEM
Corrects ticket #461
This revision corrects bad commit comment for @1611

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