source: trunk/dll/collect.c@ 1497

Last change on this file since 1497 was 1497, checked in by Gregg Young, 16 years ago

Update ExecOnList to pass environment

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