source: trunk/dll/collect.c@ 1439

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

Changes to allow high mem loading of dll; Refactor .LONGNAME and .SUBJECT EA fetch to FetchCommonEAs. Add szFSType to FillInRecordFromFSA use to bypass EA scan and size formatting for tree container; Fix labels/FS type to work on scan on NOPRESCAN Drives; Fixed dbl directory names on restore of dir cnrs; (Tickets 47, 339, 363, 368, 369, 370)

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