source: trunk/dll/collect.c@ 1544

Last change on this file since 1544 was 1544, checked in by Gregg Young, 15 years ago

Changes to fopen and _fsopen to allow FM2 to be loaded in high memory

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