source: trunk/dll/collect.c@ 1505

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

Changes to get FM2 to compile with the latest watcom 1.9 beta (mostly type casts of CHAR CONSTANT * to CHAR *). Changes to get the environment settings working everywhere again (broken by the change that moved commands to the INI); Added an environment size variable (set to 2048 which was the largest I found hard coded). Still need to find everywhere the environment size is set and use this variable.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 82.5 KB
Line 
1
2/***********************************************************************
3
4 $Id: collect.c 1498 2010-01-18 00:57:01Z 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
774# ifdef FORTIFY
775 Fortify_BecomeOwner(mp1);
776# endif
777
778 fp = _fsopen((CHAR *)mp1, "r", SH_DENYNO);
779 if (fp) {
780 while (!feof(fp)) {
781 // Avoid too much noise if collecting from binary file - oops
782 if (!fgets(fullname, sizeof(fullname), fp)) {
783 if (ferror(fp))
784 Runtime_Error(pszSrcFile, __LINE__, "fgets");
785 break;
786 }
787
788 c = strlen(fullname);
789 if (c + 1 >= sizeof(fullname))
790 errs++;
791 else if (!c || (fullname[c - 1] != '\n' && fullname[c - 1] != '\r'))
792 errs++;
793 else {
794 bstripcr(fullname);
795
796 if (*fullname == '\"') {
797 memmove(fullname, fullname + 1, strlen(fullname) + 1);
798 lstrip(fullname);
799 p = strchr(fullname, '\"');
800 if (p)
801 *p = 0;
802 rstrip(fullname);
803 }
804 else {
805 p = strchr(fullname, ' ');
806 if (p)
807 *p = 0;
808 }
809 /* fullname now contains name of file to collect */
810 DosError(FERR_DISABLEHARDERR);
811 if (FindCnrRecord(dcd->hwndCnr,
812 fullname,
813 NULL,
814 FALSE,
815 FALSE,
816 TRUE)) {
817 pci = UpdateCnrRecord(dcd->hwndCnr, fullname, FALSE, dcd);
818 if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
819 pci->rc.flRecordAttr &= ~CRA_FILTERED;
820 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
821 MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
822 }
823 /*pci = (PCNRITEM) pci->rc.preccNextRecord;
824 if (pciP)
825 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
826 else
827 pciFirst = pci;*/
828 }
829 else if (IsFullName(fullname) &&
830 !IsRoot(fullname) &&
831 !DosQueryPathInfo(fullname,
832 FIL_QUERYEASIZEL,
833 &fs4,
834 sizeof(fs4))) {
835 /* collect it */
836 pci = WinSendMsg(dcd->hwndCnr,
837 CM_ALLOCRECORD,
838 MPFROMLONG(EXTRA_RECORD_BYTES),
839 MPFROMLONG(1));
840 if (pci) {
841 dcd->ullTotalBytes += FillInRecordFromFSA(dcd->hwndCnr, pci,
842 fullname,
843 &fs4, FALSE, NULL, dcd);
844 memset(&ri, 0, sizeof(RECORDINSERT));
845 ri.cb = sizeof(RECORDINSERT);
846 ri.pRecordOrder = (PRECORDCORE) CMA_END;
847 ri.pRecordParent = (PRECORDCORE) 0;
848 ri.zOrder = (ULONG) CMA_TOP;
849 ri.cRecordsInsert = 1;
850 ri.fInvalidateRecord = TRUE;
851 WinSendMsg(dcd->hwndCnr, CM_INSERTRECORD,
852 MPFROMP(pci), MPFROMP(&ri));
853 }
854 }
855 else
856 errs++;
857 }
858 if (errs > (first ? 0 : 50)) {
859 /* prevent runaway on bad file */
860 APIRET ret = saymsg(MB_YESNO, dcd->hwndCnr,
861 GetPString(IDS_COLLECTNOLISTHDRTEXT),
862 GetPString(IDS_COLLECTNOLISTTEXT),
863 (CHAR *)mp1);
864
865 if (ret == MBID_NO)
866 break;
867 if (!first)
868 errs = 0;
869 else
870 first = FALSE;
871 }
872 } // while not eof
873 fclose(fp);
874 }
875 free(mp1);
876 }
877# ifdef FORTIFY
878 Fortify_LeaveScope();
879# endif
880 return 0;
881
882 case UM_SELECT:
883 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
884 if (dcd) {
885 switch (SHORT1FROMMP(mp1)) {
886 case IDM_SELECTLIST:
887 {
888 CHAR filename[CCHMAXPATH], *p, *pp;
889
890 strcpy(filename, PCSZ_STARDOTLST);
891 size = CCHMAXPATH;
892 PrfQueryProfileData(fmprof, appname, "SaveToListName", filename,
893 &size);
894 pp = strrchr(filename, '\\');
895 if (!pp)
896 pp = filename;
897 p = strrchr(pp, '.');
898 if (p && *(p + 1) && p > pp + 1) {
899 if (pp > filename)
900 pp++;
901 *pp = '*';
902 pp++;
903 if (p > pp)
904 memmove(pp, p, strlen(p) + 1);
905 }
906 if (insert_filename(hwnd, filename, FALSE, FALSE))
907 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
908 NULL);
909 }
910 break;
911 case IDM_SELECTALL:
912 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
913 break;
914 case IDM_DESELECTALL:
915 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
916 break;
917 case IDM_SELECTALLFILES:
918 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
919 break;
920 case IDM_DESELECTALLFILES:
921 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
922 break;
923 case IDM_SELECTALLDIRS:
924 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
925 break;
926 case IDM_DESELECTALLDIRS:
927 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
928 break;
929 case IDM_DESELECTMASK:
930 case IDM_SELECTMASK:
931 {
932 MASK mask;
933 PCNRITEM pci = (PCNRITEM) mp2;
934
935 memset(&mask, 0, sizeof(MASK));
936 mask.fNoAttribs = TRUE;
937 mask.fNoDirs = TRUE;
938 mask.fText = TRUE;
939 strcpy(mask.prompt,
940 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
941 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
942 if (pci && (INT) pci != -1)
943 strcpy(mask.szMask, pci->pszFileName);
944 if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
945 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
946 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
947 SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
948 FALSE);
949 else
950 DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
951 FALSE);
952 }
953 }
954
955 case IDM_DESELECTCLIP:
956 case IDM_SELECTCLIP:
957 {
958 CHAR **list;
959
960 list = ListFromClipboard(hwnd);
961 if (list) {
962 SelectList(dcd->hwndCnr, TRUE, FALSE,
963 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
964 NULL, NULL, list);
965 FreeList(list);
966 }
967 }
968 break;
969
970 case IDM_INVERT:
971 InvertAll(dcd->hwndCnr);
972 break;
973 }
974 }
975 return 0;
976
977 case UM_MASSACTION:
978# ifdef FORTIFY
979 Fortify_EnterScope();
980# endif
981 if (mp1) {
982# ifdef FORTIFY
983 Fortify_BecomeOwner(mp1);
984# endif
985 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
986 if (dcd) {
987 WORKER *wk;
988 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
989 if (!wk)
990 FreeListInfo((LISTINFO *) mp1);
991 else {
992 wk->size = sizeof(WORKER);
993 wk->hwndCnr = dcd->hwndCnr;
994 wk->hwndParent = dcd->hwndParent;
995 wk->hwndFrame = dcd->hwndFrame;
996 wk->hwndClient = dcd->hwndClient;
997 wk->li = (LISTINFO *) mp1;
998 strcpy(wk->directory, dcd->directory);
999 if (xbeginthread(MassAction,
1000 122880,
1001 wk,
1002 pszSrcFile,
1003 __LINE__) == -1)
1004 {
1005 free(wk);
1006 FreeListInfo((LISTINFO *) mp1);
1007 }
1008 }
1009 }
1010 }
1011# ifdef FORTIFY
1012 DosSleep(1); // Let receiver take ownership
1013 Fortify_LeaveScope();
1014# endif
1015 return 0;
1016
1017 case UM_ACTION:
1018# ifdef FORTIFY
1019 Fortify_EnterScope();
1020# endif
1021 if (mp1) {
1022# ifdef FORTIFY
1023 Fortify_BecomeOwner(mp1);
1024# endif
1025 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1026 if (dcd) {
1027 WORKER *wk;
1028 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
1029 if (!wk)
1030 FreeListInfo((LISTINFO *) mp1);
1031 else {
1032 wk->size = sizeof(WORKER);
1033 wk->hwndCnr = dcd->hwndCnr;
1034 wk->hwndParent = dcd->hwndParent;
1035 wk->hwndFrame = dcd->hwndFrame;
1036 wk->hwndClient = dcd->hwndClient;
1037 wk->li = (LISTINFO *) mp1;
1038 strcpy(wk->directory, dcd->directory);
1039 if (xbeginthread(Action,
1040 122880,
1041 wk,
1042 pszSrcFile,
1043 __LINE__) == -1)
1044 {
1045 free(wk);
1046 FreeListInfo((LISTINFO *) mp1);
1047 }
1048 }
1049 }
1050 }
1051# ifdef FORTIFY
1052 DosSleep(1); // Let receiver take ownership
1053 Fortify_LeaveScope();
1054# endif
1055 return 0;
1056
1057 case WM_CLOSE:
1058 WinDestroyWindow(hwnd);
1059 break;
1060
1061 case WM_DESTROY:
1062 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1063 if (dcd) {
1064 INT x;
1065
1066 dcd->stopflag = 1;
1067 // Allow other threads to honor stop request
1068 for (x = 0; x < 100 && dcd->amextracted; x++)
1069 DosSleep(10);
1070 if (dcd->amextracted)
1071 Runtime_Error(pszSrcFile, __LINE__, "still busy");
1072 WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
1073 FreeList(dcd->lastselection);
1074 free(dcd);
1075# ifdef FORTIFY
1076 Fortify_LeaveScope();
1077# endif
1078 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
1079 }
1080 DosPostEventSem(CompactSem);
1081 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1082 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1083 break;
1084 }
1085 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1086}
1087
1088MRESULT EXPENTRY CollectorCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
1089 MPARAM mp2)
1090{
1091 DIRCNRDATA *dcd = INSTDATA(hwnd);
1092 ULONG size;
1093
1094 static INT savedSortFlags;
1095
1096 switch (msg) {
1097 case DM_PRINTOBJECT:
1098 return MRFROMLONG(DRR_TARGET);
1099
1100 case DM_DISCARDOBJECT:
1101 if (dcd)
1102 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1103 else
1104 return MRFROMLONG(DRR_TARGET);
1105
1106 case WM_CHAR:
1107 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1108 if (SHORT1FROMMP(mp1) & KC_KEYUP)
1109 return (MRESULT) TRUE;
1110 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1111 switch (SHORT2FROMMP(mp2)) {
1112 case VK_DELETE:
1113 if ((shiftstate & KC_CTRL) == KC_CTRL)
1114 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
1115 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
1116 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
1117 else
1118 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
1119 break;
1120 }
1121 }
1122 if (shiftstate || fNoSearch)
1123 break;
1124 if (SHORT1FROMMP(mp1) & KC_CHAR) {
1125 ULONG thistime, len;
1126 SEARCHSTRING srch;
1127 PCNRITEM pci;
1128
1129 if (!dcd)
1130 break;
1131 switch (SHORT1FROMMP(mp2)) {
1132 case '\x1b':
1133 case '\r':
1134 case '\n':
1135 dcd->lasttime = 0;
1136 *dcd->szCommonName = 0;
1137 break;
1138 default:
1139 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1140 if (thistime > dcd->lasttime + 1250)
1141 *dcd->szCommonName = 0;
1142 dcd->lasttime = thistime;
1143 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
1144 break;
1145 KbdRetry:
1146 len = strlen(dcd->szCommonName);
1147 if (len >= CCHMAXPATH - 1) {
1148 *dcd->szCommonName = 0;
1149 len = 0;
1150 }
1151 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1152 dcd->szCommonName[len + 1] = 0;
1153 memset(&srch, 0, sizeof(SEARCHSTRING));
1154 srch.cb = sizeof(SEARCHSTRING);
1155 srch.pszSearch = dcd->szCommonName;
1156 srch.fsPrefix = TRUE;
1157 srch.fsCaseSensitive = FALSE;
1158 srch.usView = CV_ICON;
1159 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
1160 MPFROMLONG(CMA_FIRST));
1161 if (pci && (INT) pci != -1) {
1162 USHORT attrib = CRA_CURSORED;
1163
1164 /* make found item current item */
1165 if (!stricmp(pci->pszFileName, dcd->szCommonName))
1166 attrib |= CRA_SELECTED;
1167 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1168 MPFROM2SHORT(TRUE, attrib));
1169 /* make sure that record shows in viewport */
1170 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1171 return (MRESULT) TRUE;
1172 }
1173 else {
1174 if (SHORT1FROMMP(mp2) == ' ') {
1175 dcd->szCommonName[len] = 0;
1176 break;
1177 }
1178 *dcd->szCommonName = 0;
1179 dcd->lasttime = 0;
1180 if (len) // retry as first letter if no match
1181
1182 goto KbdRetry;
1183 }
1184 break;
1185 }
1186 }
1187 break;
1188
1189 case WM_MOUSEMOVE:
1190 case WM_BUTTON1UP:
1191 case WM_BUTTON2UP:
1192 case WM_BUTTON3UP:
1193 case WM_CHORD:
1194 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1195 break;
1196
1197 case WM_BUTTON1MOTIONEND:
1198 {
1199 CNRINFO cnri;
1200
1201 memset(&cnri, 0, sizeof(CNRINFO));
1202 cnri.cb = sizeof(CNRINFO);
1203 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1204 MPFROMLONG(sizeof(CNRINFO)))) {
1205 if (cnri.flWindowAttr & CV_DETAIL)
1206 PrfWriteProfileData(fmprof, appname, "CollectorCnrSplitBar",
1207 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
1208 }
1209 }
1210 break;
1211
1212 case WM_PRESPARAMCHANGED:
1213 PresParamChanged(hwnd, PCSZ_COLLECTOR, mp1, mp2);
1214 break;
1215
1216 case UM_COMPARE:
1217 if (dcd && mp1 && mp2) {
1218 COMPARE *cmp;
1219 CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
1220
1221 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1222 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1223 if (cmp) {
1224 cmp->size = sizeof(COMPARE);
1225 strcpy(cmp->leftdir, leftdir);
1226 strcpy(cmp->rightdir, rightdir);
1227 cmp->hwndParent = dcd->hwndParent;
1228 cmp->dcd.hwndParent = dcd->hwndParent;
1229 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, CompareDlgProc,
1230 FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1231 }
1232 }
1233 }
1234 return 0;
1235
1236 case UM_UPDATERECORDLIST:
1237 if (dcd && mp1)
1238 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1239 return 0;
1240
1241 case UM_UPDATERECORD:
1242 if (dcd && mp1) {
1243 CHAR *filename;
1244
1245 filename = mp1;
1246 if (filename)
1247 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1248 }
1249 return 0;
1250
1251 case WM_SETFOCUS:
1252 /*
1253 * put name of our window on status line
1254 */
1255 if (dcd && hwndStatus && mp2) {
1256 PCNRITEM pci = NULL;
1257
1258 if (fAutoView && hwndMain) {
1259 pci = WinSendMsg(hwnd,
1260 CM_QUERYRECORDEMPHASIS,
1261 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1262 if (pci && (INT) pci != -1 &&
1263 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1264 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1265 else
1266 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1267 }
1268 if (dcd->amextracted)
1269 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_INSEEKSCANTEXT)); // Say working
1270 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1271 }
1272 break;
1273
1274 case UM_RESCAN:
1275 if (dcd) {
1276 CNRINFO cnri;
1277 CHAR s[CCHMAXPATH + 69], tb[81], tf[81], szDate[DATE_BUF_BYTES] *p;
1278 PCNRITEM pci = NULL;
1279
1280 memset(&cnri, 0, sizeof(CNRINFO));
1281 cnri.cb = sizeof(CNRINFO);
1282 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1283 MPFROMLONG(sizeof(CNRINFO)));
1284 dcd->totalfiles = cnri.cRecords;
1285 commafmt(tf, sizeof(tf), dcd->totalfiles);
1286 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
1287 sprintf(s, "%s / %s", tf, tb);
1288 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1289
1290 commafmt(tf, sizeof(tf), dcd->selectedfiles);
1291 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
1292 sprintf(s, "%s / %s", tf, tb);
1293 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1294
1295 if (hwndStatus &&
1296 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1297 if (hwndMain) {
1298 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1299 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1300 if (pci && (INT) pci != -1)
1301 PostMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1302 else
1303 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1304 }
1305 if (!dcd->amextracted) {
1306 if (!fMoreButtons) {
1307 sprintf(s, " %s%s%s%s",
1308 GetPString(IDS_COLLECTORTEXT),
1309 *dcd->mask.szMask || dcd->mask.antiattr ||
1310 dcd->mask.attrFile != ALLATTRS ? " (" : NullStr,
1311 *dcd->mask.szMask ?
1312 dcd->mask.szMask :
1313 dcd->mask.antiattr ||
1314 dcd->mask.attrFile != ALLATTRS ?
1315 GetPString(IDS_ATTRTEXT) : NullStr,
1316 *dcd->mask.szMask || dcd->mask.antiattr ||
1317 dcd->mask.attrFile != ALLATTRS ?
1318 ")" : NullStr);
1319 }
1320 else
1321 strcpy(s, GetPString(IDS_COLLECTORTEXT));
1322 WinSetWindowText(hwndStatus, s);
1323 }
1324 if (!pci)
1325 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1326 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1327 if (pci && (INT) pci != -1) {
1328 BOOL fStatus2Used = FALSE;
1329
1330 if (fSplitStatus && hwndStatus2) {
1331 if (pci->attrFile & FILE_DIRECTORY)
1332 p = pci->pszFileName;
1333 else {
1334 p = strrchr(pci->pszFileName, '\\');
1335 if (p) {
1336 if (*(p + 1))
1337 p++;
1338 else
1339 p = pci->pszFileName;
1340 }
1341 else
1342 p = pci->pszFileName;
1343 }
1344 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1345 if (!fMoreButtons) {
1346 DateFormat(szDate, pci->date);
1347 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
1348 tb, szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
1349 TimeSeparator, pci->time.seconds, pci->pszDispAttr, p);
1350 }
1351 else {
1352 if (pci->cbFile + pci->easize > 1024)
1353 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1354 else
1355 *tf = 0;
1356 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
1357 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1358 }
1359 WinSetWindowText(hwndStatus2, s);
1360 fStatus2Used = TRUE;
1361 }
1362 if (fMoreButtons) {
1363 WinSetWindowText(hwndName, pci->pszFileName);
1364 DateFormat(szDate, pci->date);
1365 sprintf(s, "%s %02u%s%02u%s%02u",
1366 szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
1367 TimeSeparator, pci->time.seconds);
1368 WinSetWindowText(hwndDate, s);
1369 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1370 }
1371 if (dcd->amextracted && hwndStatus2 && !fStatus2Used)
1372 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_INSEEKSCANTEXT)); // Say working
1373 }
1374 else {
1375 if (hwndStatus2) {
1376 if (dcd->amextracted)
1377 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_INSEEKSCANTEXT)); // Say working
1378 else
1379 WinSetWindowText(hwndStatus2, NullStr);
1380 }
1381 if (fMoreButtons) {
1382 WinSetWindowText(hwndName, NullStr);
1383 WinSetWindowText(hwndDate, NullStr);
1384 WinSetWindowText(hwndAttr, NullStr);
1385 }
1386 }
1387 }
1388 }
1389 return 0;
1390
1391 case UM_CONTAINER_FILLED:
1392 if (!fAlertBeepOff)
1393 DosBeep(1000, 50); // Wake up user?
1394 WinSendMsg(hwnd,
1395 CM_INVALIDATERECORD,
1396 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1397 disable_menuitem(WinWindowFromID(WinQueryWindow(hwndMain, QW_PARENT),
1398 FID_MENU), IDM_GREP, FALSE);
1399 disable_menuitem(TreeMenu, IDM_GREP, FALSE);
1400 disable_menuitem(DirMenu, IDM_GREP, FALSE);
1401 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1402 if (dcd) {
1403 dcd->stopflag = 0;
1404 dcd->amextracted = FALSE; // Say not busy
1405 if (dcd->namecanchange) {
1406 if (!PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID))
1407 WinSendMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1408 }
1409 else
1410 WinSetWindowPos(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
1411 QW_PARENT),
1412 HWND_TOP,
1413 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ZORDER);
1414 }
1415 return 0;
1416
1417 case UM_SETUP:
1418 if (dcd) {
1419 if (!dcd->hwndObject) {
1420 /* first time through -- set things up */
1421
1422 CNRINFO cnri;
1423
1424 RestorePresParams(hwnd, PCSZ_COLLECTOR);
1425 LoadDetailsSwitches(PCSZ_COLLECTOR, &dcd->ds, FALSE);
1426
1427 dcd->amextracted = FALSE; // Say not busy
1428 dcd->stopflag = 0;
1429 memset(&cnri, 0, sizeof(CNRINFO));
1430 cnri.cb = sizeof(CNRINFO);
1431 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1432 MPFROMLONG(sizeof(CNRINFO)));
1433 cnri.cyLineSpacing = 0;
1434 cnri.cxTreeIndent = 12;
1435
1436 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_DETAIL));
1437 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES |
1438 CV_MINI | CV_FLOW);
1439 cnri.pSortRecord = (PVOID) SortCollectorCnr;
1440
1441 size = sizeof(ULONG);
1442 PrfQueryProfileData(fmprof, appname, "CollectorflWindowAttr",
1443 (PVOID) & cnri.flWindowAttr, &size);
1444 size = sizeof(MASK);
1445 if (PrfQueryProfileSize(fmprof, appname, "CollectorFilter", &size) &&
1446 size) {
1447 PrfQueryProfileData(fmprof, appname, "CollectorFilter", &dcd->mask,
1448 &size);
1449 SetMask(NULL, &dcd->mask);
1450 }
1451 else {
1452 dcd->mask.attrFile = (FILE_NORMAL | FILE_READONLY |
1453 FILE_DIRECTORY | FILE_HIDDEN |
1454 FILE_SYSTEM | FILE_ARCHIVED);
1455 dcd->mask.antiattr = 0;
1456 }
1457
1458 *(dcd->mask.prompt) = 0;
1459
1460 cnri.flWindowAttr |= CV_FLOW;
1461 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
1462 dcd->flWindowAttr = cnri.flWindowAttr;
1463 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1464 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1465 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1466 SetCnrCols(hwnd, FALSE);
1467 AdjustCnrColsForPref(hwnd, NULL, &dcd->ds, FALSE);
1468
1469 /* fix splitbar for collector container */
1470 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1471 size = sizeof(LONG);
1472 PrfQueryProfileData(fmprof, appname, "CollectorCnrSplitBar",
1473 &cnri.xVertSplitbar, &size);
1474 if (cnri.xVertSplitbar <= 0)
1475 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1476 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1477 MPFROMLONG(CMA_XVERTSPLITBAR));
1478
1479 if (xbeginthread(MakeObjWin,
1480 245760,
1481 dcd,
1482 pszSrcFile,
1483 __LINE__) == -1)
1484 {
1485 Runtime_Error(pszSrcFile, __LINE__,
1486 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1487 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1488 return 0;
1489 }
1490 else
1491 DosSleep(32); // Let object window get started
1492 }
1493 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1494 DIR_FILTER), &dcd->mask, FALSE);
1495 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1496 DIR_SORT), CollectorsortFlags, FALSE);
1497 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1498 DIR_VIEW), dcd->flWindowAttr);
1499 }
1500 else {
1501 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1502 return 0;
1503 }
1504 return 0;
1505
1506 case WM_MENUEND:
1507 if (dcd) {
1508 HWND hwndMenu = (HWND) mp2;
1509
1510 if (hwndMenu == CollectorCnrMenu || hwndMenu == CollectorFileMenu ||
1511 hwndMenu == CollectorDirMenu) {
1512 MarkAll(hwnd, TRUE, FALSE, TRUE);
1513 if (dcd->cnremphasized) {
1514 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1515 MPFROM2SHORT(FALSE, CRA_SOURCE));
1516 dcd->cnremphasized = FALSE;
1517 }
1518 }
1519 }
1520 break;
1521
1522 case UM_OPENWINDOWFORME:
1523 if (dcd) {
1524 if (mp1 && !IsFile((CHAR *)mp1))
1525 OpenDirCnr(HWND_DESKTOP, hwndMain, dcd->hwndFrame, FALSE, (PSZ) mp1);
1526 else if (mp1 && IsFile(mp1) == 1 &&
1527 CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) != 2)
1528 StartArcCnr(HWND_DESKTOP,
1529 dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
1530 }
1531 return 0;
1532
1533 case MM_PORTHOLEINIT:
1534 if (dcd) {
1535 switch (SHORT1FROMMP(mp1)) {
1536 case 0:
1537 case 1:
1538 {
1539 ULONG wmsg;
1540
1541 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1542 PortholeInit((HWND) WinSendMsg(dcd->hwndClient, wmsg, MPVOID,
1543 MPVOID), mp1, mp2);
1544 }
1545 break;
1546 }
1547 }
1548 break;
1549
1550 case UM_INITMENU:
1551 case WM_INITMENU:
1552 if (dcd) {
1553 switch (SHORT1FROMMP(mp1)) {
1554 case IDM_VIEWSMENU:
1555 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1556 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1557 (dcd->lastselection != NULL));
1558 CopyPresParams((HWND) mp2, hwnd);
1559 break;
1560
1561 case IDM_DETAILSSETUP:
1562 SetDetailsSwitches((HWND) mp2, &dcd->ds);
1563 break;
1564
1565 case IDM_COMMANDSMENU:
1566 SetupCommandMenu((HWND) mp2, hwnd);
1567 break;
1568
1569 case IDM_SORTSUBMENU:
1570 SetSortChecks((HWND) mp2, CollectorsortFlags);
1571 break;
1572 }
1573 dcd->hwndLastMenu = (HWND) mp2;
1574 }
1575 if (msg == WM_INITMENU)
1576 break;
1577 return 0;
1578
1579 case UM_COLLECTFROMFILE:
1580 if (mp1) {
1581# ifdef FORTIFY
1582 Fortify_EnterScope();
1583 Fortify_BecomeOwner(mp1);
1584# endif
1585 if (!dcd) {
1586 Runtime_Error(pszSrcFile, __LINE__, NULL);
1587 free(mp1);
1588 }
1589 else {
1590 if (!PostMsg(dcd->hwndObject, UM_COLLECTFROMFILE, mp1, mp2)) {
1591 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
1592 free(mp1);
1593 }
1594 }
1595# ifdef FORTIFY
1596 DosSleep(1); // Let receiver take ownership
1597 Fortify_LeaveScope();
1598# endif
1599 }
1600 return 0;
1601
1602 case UM_COMMAND:
1603 if (mp1) {
1604 if (dcd) {
1605 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1606 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
1607 FreeListInfo((LISTINFO *) mp1);
1608 }
1609 else
1610 return (MRESULT) TRUE;
1611 }
1612 else
1613 FreeListInfo((LISTINFO *) mp1);
1614 }
1615 return 0;
1616
1617 case UM_NOTIFY:
1618 if (mp2)
1619 AddNote((CHAR *)mp2);
1620 return 0;
1621
1622 case WM_COMMAND:
1623 DosError(FERR_DISABLEHARDERR);
1624 if (dcd) {
1625 switch (SHORT1FROMMP(mp1)) {
1626 case IDM_SETTARGET:
1627 SetTargetDir(hwnd, FALSE);
1628 break;
1629
1630 case IDM_CONTEXTMENU:
1631 {
1632 PCNRITEM pci;
1633
1634 pci = (PCNRITEM) CurrentRecord(hwnd);
1635 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(COLLECTOR_CNR,
1636 CN_CONTEXTMENU),
1637 MPFROMP(pci));
1638 }
1639 break;
1640
1641 case IDM_SHOWALLFILES:
1642 {
1643 PCNRITEM pci;
1644
1645 pci = WinSendMsg(hwnd,
1646 CM_QUERYRECORDEMPHASIS,
1647 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1648 if (pci && (INT) pci != -1) {
1649 static CHAR dirname[CCHMAXPATH];
1650
1651 strcpy(dirname, pci->pszFileName);
1652 MakeValidDir(dirname);
1653 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1654 }
1655 }
1656 break;
1657
1658 case IDM_BEGINEDIT:
1659 OpenEdit(hwnd);
1660 break;
1661
1662 case IDM_ENDEDIT:
1663 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1664 break;
1665
1666 case IDM_SHOWSELECT:
1667 QuickPopup(hwnd, dcd,
1668 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
1669 IDM_SELECTSUBMENU);
1670 break;
1671
1672 case IDM_SHOWSORT:
1673 QuickPopup(hwnd, dcd,
1674 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
1675 IDM_SORTSUBMENU);
1676 break;
1677
1678 case IDM_VIEWORARC:
1679 {
1680 SWP swp;
1681 PCNRITEM pci;
1682
1683 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1684 MPFROMLONG(CMA_FIRST),
1685 MPFROMSHORT(CRA_CURSORED));
1686 if (pci && (INT) pci != -1) {
1687 WinQueryWindowPos(dcd->hwndFrame, &swp);
1688 DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp,
1689 pci->pszFileName);
1690 }
1691 }
1692 break;
1693
1694 case IDM_SEEALL:
1695 StartSeeAll(HWND_DESKTOP, FALSE, NULL);
1696 break;
1697
1698 case IDM_COLLECTSELECT:
1699 {
1700 CHAR filename[CCHMAXPATH], *p, *pp;
1701
1702 strcpy(filename, PCSZ_STARDOTLST);
1703 size = CCHMAXPATH;
1704 PrfQueryProfileData(fmprof, appname, "SaveToListName",
1705 filename, &size);
1706 pp = strrchr(filename, '\\');
1707 if (!pp)
1708 pp = filename;
1709 p = strrchr(pp, '.');
1710 if (p && *(p + 1) && p > pp + 1) {
1711 if (pp > filename)
1712 pp++;
1713 *pp = '*';
1714 pp++;
1715 if (p > pp)
1716 memmove(pp, p, strlen(p) + 1);
1717 }
1718 if (insert_filename(hwnd, filename, FALSE, FALSE)) {
1719# ifdef FORTIFY
1720 Fortify_EnterScope();
1721# endif
1722 p = xstrdup(filename, pszSrcFile, __LINE__);
1723 if (p) {
1724 if (!PostMsg(hwnd, UM_COLLECTFROMFILE, MPFROMP(p), MPVOID))
1725 free(p);
1726 }
1727# ifdef FORTIFY
1728 DosSleep(1); // Let receiver take ownership
1729 Fortify_LeaveScope();
1730# endif
1731 }
1732 }
1733 break;
1734
1735 case IDM_COLLECTORVIEWSETTINGS:
1736 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1737 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_COLLECTORVIEWSETTINGS), mp2);
1738 else {
1739 WinDlgBox(HWND_DESKTOP,
1740 hwnd,
1741 CfgDlgProc,
1742 FM3ModHandle,
1743 CFG_FRAME,
1744 MPFROMLONG(IDM_COLLECTORVIEWSETTINGS));
1745 }
1746 break;
1747
1748 case IDM_RESELECT:
1749 SelectList(hwnd, FALSE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1750 break;
1751
1752 case IDM_HELP:
1753 if (hwndHelp)
1754 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
1755 MPFROM2SHORT(HELP_COLLECT, 0),
1756 MPFROMSHORT(HM_RESOURCEID));
1757 break;
1758
1759 case IDM_SORTNONE:
1760 case IDM_SORTSMARTNAME:
1761 case IDM_SORTNAME:
1762 case IDM_SORTFILENAME:
1763 case IDM_SORTSIZE:
1764 case IDM_SORTEASIZE:
1765 case IDM_SORTFIRST:
1766 case IDM_SORTLAST:
1767 case IDM_SORTLWDATE:
1768 case IDM_SORTLADATE:
1769 case IDM_SORTCRDATE:
1770 case IDM_SORTSUBJECT:
1771 savedSortFlags = CollectorsortFlags;
1772 CollectorsortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1773 case IDM_SORTDIRSFIRST:
1774 case IDM_SORTDIRSLAST:
1775 case IDM_SORTREVERSE:
1776 switch (SHORT1FROMMP(mp1)) {
1777 case IDM_SORTSUBJECT:
1778 CollectorsortFlags |= SORT_SUBJECT;
1779 break;
1780 case IDM_SORTNONE:
1781 CollectorsortFlags |= SORT_NOSORT;
1782 break;
1783 case IDM_SORTSMARTNAME:
1784 if (~savedSortFlags & SORT_FILENAME)
1785 CollectorsortFlags |= SORT_FILENAME;
1786 break;
1787 case IDM_SORTFILENAME:
1788 CollectorsortFlags |= SORT_FILENAME;
1789 break;
1790 case IDM_SORTSIZE:
1791 CollectorsortFlags |= SORT_SIZE;
1792 break;
1793 case IDM_SORTEASIZE:
1794 CollectorsortFlags |= SORT_EASIZE;
1795 break;
1796 case IDM_SORTFIRST:
1797 CollectorsortFlags |= SORT_FIRSTEXTENSION;
1798 break;
1799 case IDM_SORTLAST:
1800 CollectorsortFlags |= SORT_LASTEXTENSION;
1801 break;
1802 case IDM_SORTLWDATE:
1803 CollectorsortFlags |= SORT_LWDATE;
1804 break;
1805 case IDM_SORTLADATE:
1806 CollectorsortFlags |= SORT_LADATE;
1807 break;
1808 case IDM_SORTCRDATE:
1809 CollectorsortFlags |= SORT_CRDATE;
1810 break;
1811 case IDM_SORTDIRSFIRST:
1812 if (CollectorsortFlags & SORT_DIRSFIRST)
1813 CollectorsortFlags &= (~SORT_DIRSFIRST);
1814 else {
1815 CollectorsortFlags |= SORT_DIRSFIRST;
1816 CollectorsortFlags &= (~SORT_DIRSLAST);
1817 }
1818 break;
1819 case IDM_SORTDIRSLAST:
1820 if (CollectorsortFlags & SORT_DIRSLAST)
1821 CollectorsortFlags &= (~SORT_DIRSLAST);
1822 else {
1823 CollectorsortFlags |= SORT_DIRSLAST;
1824 CollectorsortFlags &= (~SORT_DIRSFIRST);
1825 }
1826 break;
1827 case IDM_SORTREVERSE:
1828 if (CollectorsortFlags & SORT_REVERSE)
1829 CollectorsortFlags &= (~SORT_REVERSE);
1830 else
1831 CollectorsortFlags |= SORT_REVERSE;
1832 break;
1833 }
1834 PrfWriteProfileData(fmprof, appname, "CollectorSort",
1835 &CollectorsortFlags, sizeof(INT));
1836 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1837 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1838 DIR_SORT), CollectorsortFlags, FALSE);
1839 break;
1840
1841 case IDM_COLLECTFROMCLIP:
1842 {
1843 LISTINFO *li;
1844# ifdef FORTIFY
1845 Fortify_EnterScope();
1846# endif
1847 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1848 if (li) {
1849 li->list = ListFromClipboard(hwnd);
1850 if (!li->list || !li->list[0])
1851 FreeListInfo(li);
1852 else {
1853 li->type = IDM_COLLECT;
1854 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1855 FreeListInfo(li);
1856 }
1857 }
1858# ifdef FORTIFY
1859 DosSleep(1); // Let receiver take ownership
1860 Fortify_LeaveScope();
1861# endif
1862 }
1863 break;
1864
1865 case IDM_REMOVE:
1866 if (fAutoView && hwndMain)
1867 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1868 dcd->suspendview = 1;
1869 RemoveAll(hwnd, &dcd->ullTotalBytes, &dcd->totalfiles);
1870 dcd->suspendview = 0;
1871 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1872 break;
1873
1874 case IDM_CLEARCNR:
1875 {
1876 PCNRITEM pci;
1877
1878 pci = (PCNRITEM) WinSendMsg(hwnd,
1879 CM_QUERYRECORD,
1880 MPVOID,
1881 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
1882 if (pci && (INT) pci != -1) {
1883 RemoveCnrItems(hwnd, NULL, 0, CMA_FREE | CMA_INVALIDATE);
1884 dcd->ullTotalBytes = dcd->selectedbytes = dcd->selectedfiles =
1885 dcd->totalfiles = 0;
1886 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1887 }
1888 }
1889 break;
1890
1891 case DID_CANCEL:
1892 if (dcd->amextracted)
1893 dcd->stopflag = 1; // Request cancel
1894 break;
1895
1896 case IDM_COLLECTOR:
1897 if (mp2) {
1898 LISTINFO *li;
1899# ifdef FORTIFY
1900 Fortify_EnterScope();
1901# endif
1902 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1903 if (li) {
1904 li->list = mp2;
1905 if (!li->list || !li->list[0])
1906 FreeListInfo(li);
1907 else {
1908 li->type = IDM_COLLECT;
1909 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1910 FreeListInfo(li);
1911 }
1912 }
1913 else
1914 FreeList(mp2);
1915# ifdef FORTIFY
1916 DosSleep(1); // Let receiver take ownership
1917 Fortify_LeaveScope();
1918# endif
1919 }
1920 break;
1921
1922 case IDM_UNDELETE:
1923 {
1924 PCNRITEM pci;
1925 CHAR path[CCHMAXPATH];
1926 HOBJECT hObject;
1927 HWND hwndDesktop;
1928
1929 hObject = WinQueryObject("<XWP_TRASHCAN>");
1930 if (hObject != NULLHANDLE && fTrashCan) {
1931 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
1932 WinSetFocus(HWND_DESKTOP, hwndDesktop);
1933 WinOpenObject(hObject, 0, TRUE);
1934 }
1935 else {
1936 pci = (PCNRITEM) CurrentRecord(hwnd);
1937 if (pci && (INT) pci != -1) {
1938 strcpy(path, pci->pszFileName);
1939 MakeValidDir(path);
1940 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
1941 UNDEL_FRAME, MPFROMP(path));
1942 }
1943 }
1944 }
1945 break;
1946
1947 case IDM_GREP:
1948 case UM_GREP:
1949 if (dcd->amextracted) {
1950 saymsg(MB_OK | MB_ICONASTERISK,
1951 hwnd,
1952 GetPString(IDS_WARNINGTEXT),
1953 "Collector busy - please try again later");
1954 }
1955 else {
1956 GREPINFO *GrepInfo;
1957
1958 GrepInfo = xmallocz(sizeof(GREPINFO), pszSrcFile, __LINE__);
1959 if (GrepInfo) {
1960 GrepInfo->hwnd = &hwnd;
1961 if (msg == UM_GREP && mp2)
1962 GrepInfo->szGrepPath = mp2;
1963 if (WinDlgBox(HWND_DESKTOP, hwnd, GrepDlgProc,
1964 FM3ModHandle, GREP_FRAME, (PVOID) GrepInfo)) {
1965 free(GrepInfo);
1966 dcd->amextracted = TRUE; // Say busy scanning
1967 disable_menuitem(WinWindowFromID
1968 (WinQueryWindow(hwndMain, QW_PARENT), FID_MENU),
1969 IDM_GREP, TRUE);
1970 disable_menuitem(TreeMenu, IDM_GREP, TRUE);
1971 disable_menuitem(DirMenu, IDM_GREP, TRUE);
1972 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1973 }
1974 else
1975 free(GrepInfo);
1976 }
1977 }
1978 break;
1979
1980 case IDM_RESORT:
1981 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1982 break;
1983
1984 case IDM_FILTER:
1985 {
1986 BOOL empty = FALSE;
1987 PCNRITEM pci;
1988 CHAR *p;
1989
1990 if (!*dcd->mask.szMask) {
1991 empty = TRUE;
1992 pci = (PCNRITEM) CurrentRecord(hwnd);
1993 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
1994 p = strrchr(pci->pszFileName, '\\');
1995 if (p) {
1996 p++;
1997 strcpy(dcd->mask.szMask, p);
1998 }
1999 }
2000 }
2001 *(dcd->mask.prompt) = 0;
2002
2003 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2004 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
2005 size = sizeof(MASK);
2006 PrfWriteProfileData(fmprof, appname, "CollectorFilter",
2007 &dcd->mask, size);
2008 dcd->suspendview = 1;
2009 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2010 dcd->suspendview = 0;
2011 if (fAutoView && hwndMain) {
2012 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
2013 MPFROMLONG(CMA_FIRST),
2014 MPFROMSHORT(CRA_CURSORED));
2015 if (pci && (INT) pci != -1 &&
2016 (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
2017 DRIVE_SLOW)))
2018 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName),
2019 MPVOID);
2020 else
2021 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2022 }
2023 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2024 }
2025 else if (empty)
2026 *dcd->mask.szMask = 0;
2027 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2028 DIR_FILTER), &dcd->mask, FALSE);
2029 }
2030 break;
2031
2032 case IDM_UNHIDEALL:
2033 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2034 break;
2035
2036 case IDM_HIDEALL:
2037 if (fAutoView && hwndMain)
2038 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2039 dcd->suspendview = 1;
2040 HideAll(hwnd);
2041 dcd->suspendview = 0;
2042 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2043 break;
2044
2045 case IDM_SELECTLIST:
2046 case IDM_SELECTALL:
2047 case IDM_DESELECTALL:
2048 case IDM_SELECTALLFILES:
2049 case IDM_DESELECTALLFILES:
2050 case IDM_SELECTALLDIRS:
2051 case IDM_DESELECTALLDIRS:
2052 case IDM_SELECTMASK:
2053 case IDM_DESELECTMASK:
2054 case IDM_INVERT:
2055 case IDM_SELECTCLIP:
2056 case IDM_DESELECTCLIP:
2057 {
2058 PCNRITEM pci;
2059
2060 pci = (PCNRITEM) CurrentRecord(hwnd);
2061 if ((INT) pci == -1)
2062 pci = NULL;
2063 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2064 if (pci) {
2065 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2066 pci->rc.flRecordAttr |= CRA_FILTERED;
2067 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2068 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2069 break;
2070 }
2071 }
2072 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2073 }
2074 break;
2075
2076 case IDM_RESCAN:
2077 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
2078 break;
2079
2080 case IDM_SHOWLNAMES:
2081 case IDM_SHOWSUBJECT:
2082 case IDM_SHOWEAS:
2083 case IDM_SHOWSIZE:
2084 case IDM_SHOWICON:
2085 case IDM_SHOWLWDATE:
2086 case IDM_SHOWLWTIME:
2087 case IDM_SHOWLADATE:
2088 case IDM_SHOWLATIME:
2089 case IDM_SHOWCRDATE:
2090 case IDM_SHOWCRTIME:
2091 case IDM_SHOWATTR:
2092 AdjustDetailsSwitches(hwnd, dcd->hwndLastMenu,
2093 SHORT1FROMMP(mp1), NULL,
2094 PCSZ_COLLECTOR, &dcd->ds, FALSE);
2095 break;
2096
2097 case IDM_ICON:
2098 case IDM_TEXT:
2099 case IDM_DETAILS:
2100 case IDM_NAME:
2101 case IDM_MINIICONS:
2102 case IDM_DETAILSTITLES:
2103 {
2104 CNRINFO cnri;
2105
2106 memset(&cnri, 0, sizeof(CNRINFO));
2107 cnri.cb = sizeof(CNRINFO);
2108 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2109 MPFROMLONG(sizeof(CNRINFO)));
2110 switch (SHORT1FROMMP(mp1)) {
2111 case IDM_ICON:
2112 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2113 CV_DETAIL | CV_NAME));
2114 cnri.flWindowAttr |= CV_ICON;
2115 break;
2116 case IDM_NAME:
2117 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2118 CV_DETAIL | CV_NAME));
2119 cnri.flWindowAttr |= CV_NAME;
2120 break;
2121 case IDM_TEXT:
2122 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2123 CV_DETAIL | CV_NAME));
2124 cnri.flWindowAttr |= CV_TEXT;
2125 break;
2126 case IDM_DETAILS:
2127 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2128 CV_DETAIL | CV_NAME));
2129 cnri.flWindowAttr |= CV_DETAIL;
2130 break;
2131 case IDM_MINIICONS:
2132 if (cnri.flWindowAttr & CV_MINI)
2133 cnri.flWindowAttr &= (~CV_MINI);
2134 else
2135 cnri.flWindowAttr |= CV_MINI;
2136 break;
2137 case IDM_DETAILSTITLES:
2138 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2139 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2140 else
2141 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2142 break;
2143 }
2144 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2145 cnri.flWindowAttr |= CV_FLOW;
2146 dcd->flWindowAttr = cnri.flWindowAttr;
2147 PrfWriteProfileData(fmprof, appname, "CollectorflWindowAttr",
2148 &cnri.flWindowAttr, sizeof(ULONG));
2149 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2150 MPFROMLONG(CMA_FLWINDOWATTR));
2151 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2152 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2153 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2154 DIR_VIEW), dcd->flWindowAttr);
2155 }
2156 break;
2157
2158 case IDM_SAVETOLIST:
2159 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2160 SAV_FRAME, MPFROMP(&hwnd));
2161 break;
2162
2163 case IDM_SIZES:
2164 {
2165 PCNRITEM pci;
2166
2167 pci = (PCNRITEM) CurrentRecord(hwnd);
2168 if (pci && (INT) pci != -1)
2169 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DirSizeProc, FM3ModHandle,
2170 DSZ_FRAME, pci->pszFileName);
2171 }
2172 break;
2173
2174 case IDM_MKDIR:
2175 {
2176 PCNRITEM pci;
2177
2178 pci = (PCNRITEM) CurrentRecord(hwnd);
2179 PMMkDir(dcd->hwndParent, (pci && (INT) pci != -1) ?
2180 pci->pszFileName : NULL, FALSE);
2181 }
2182 break;
2183
2184 case IDM_DOITYOURSELF:
2185 case IDM_UPDATE:
2186 case IDM_COLLECTFROMFILE:
2187 case IDM_OPENWINDOW:
2188 case IDM_OPENSETTINGS:
2189 case IDM_OPENDEFAULT:
2190 case IDM_OPENICON:
2191 case IDM_OPENDETAILS:
2192 case IDM_OPENTREE:
2193 case IDM_OBJECT:
2194 case IDM_SHADOW:
2195 case IDM_SHADOW2:
2196 case IDM_DELETE:
2197 case IDM_PERMDELETE:
2198 case IDM_PRINT:
2199 case IDM_ATTRS:
2200 case IDM_INFO:
2201 case IDM_COPY:
2202 case IDM_MOVE:
2203 case IDM_WPSCOPY:
2204 case IDM_WPSMOVE:
2205 case IDM_COPYPRESERVE:
2206 case IDM_MOVEPRESERVE:
2207 case IDM_WILDCOPY:
2208 case IDM_WILDMOVE:
2209 case IDM_RENAME:
2210 case IDM_COMPARE:
2211 case IDM_EAS:
2212 case IDM_SUBJECT:
2213 case IDM_VIEW:
2214 case IDM_VIEWTEXT:
2215 case IDM_VIEWBINARY:
2216 case IDM_VIEWARCHIVE:
2217 case IDM_EDIT:
2218 case IDM_EDITTEXT:
2219 case IDM_EDITBINARY:
2220 case IDM_SAVETOCLIP:
2221 case IDM_SAVETOCLIPFILENAME:
2222 case IDM_APPENDTOCLIP:
2223 case IDM_APPENDTOCLIPFILENAME:
2224 case IDM_ARCHIVE:
2225 case IDM_ARCHIVEM:
2226 case IDM_EXTRACT:
2227 case IDM_MCIPLAY:
2228 case IDM_UUDECODE:
2229 case IDM_MERGE:
2230 {
2231 LISTINFO *li;
2232 ULONG action = UM_ACTION;
2233# ifdef FORTIFY
2234 Fortify_EnterScope();
2235# endif
2236 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2237 if (li) {
2238 li->type = SHORT1FROMMP(mp1);
2239 li->hwnd = hwnd;
2240 li->list = BuildList(hwnd);
2241 if (li->list) {
2242 switch (SHORT1FROMMP(mp1)) {
2243 case IDM_DOITYOURSELF:
2244 case IDM_APPENDTOCLIP:
2245 case IDM_APPENDTOCLIPFILENAME:
2246 case IDM_SAVETOCLIP:
2247 case IDM_SAVETOCLIPFILENAME:
2248 case IDM_ARCHIVE:
2249 case IDM_ARCHIVEM:
2250 case IDM_DELETE:
2251 case IDM_PERMDELETE:
2252 case IDM_ATTRS:
2253 case IDM_PRINT:
2254 case IDM_SHADOW:
2255 case IDM_SHADOW2:
2256 case IDM_OBJECT:
2257 case IDM_VIEW:
2258 case IDM_VIEWTEXT:
2259 case IDM_VIEWBINARY:
2260 case IDM_EDIT:
2261 case IDM_EDITTEXT:
2262 case IDM_EDITBINARY:
2263 case IDM_MCIPLAY:
2264 case IDM_UPDATE:
2265 case IDM_INFO:
2266 case IDM_EAS:
2267 action = UM_MASSACTION;
2268 break;
2269 }
2270 if (li->type == IDM_SHADOW || li->type == IDM_OBJECT ||
2271 li->type == IDM_SHADOW2)
2272 *li->targetpath = 0;
2273 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2274 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
2275 FreeListInfo(li);
2276 }
2277 else if (fUnHilite)
2278 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2279 }
2280 else
2281 free(li);
2282 }
2283# ifdef FORTIFY
2284 Fortify_LeaveScope();
2285# endif
2286 }
2287 break;
2288
2289 default:
2290 if (!cmdloaded)
2291 load_commands();
2292 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2293 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2294 INT x;
2295
2296 x = SHORT1FROMMP(mp1);// - IDM_COMMANDSTART;
2297 if (x >= 0) {
2298 //x++;
2299 RunCommand(hwnd, x);
2300 if (fUnHilite)
2301 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2302 }
2303 }
2304 break;
2305 }
2306 }
2307 return 0;
2308
2309 case UM_FIXCNRMLE:
2310 case UM_FIXEDITNAME:
2311 return CommonCnrProc(hwnd, msg, mp1, mp2);
2312
2313 case UM_FILESMENU:
2314 {
2315 PCNRITEM pci;
2316 HWND menuHwnd = (HWND) 0;
2317
2318 pci = (PCNRITEM) CurrentRecord(hwnd);
2319 if (pci && (INT) pci != -1) {
2320 if (pci->attrFile & FILE_DIRECTORY)
2321 menuHwnd = CheckMenu(hwnd, &CollectorDirMenu, COLLECTORDIR_POPUP);
2322 else
2323 menuHwnd = CheckMenu(hwnd, &CollectorFileMenu, COLLECTORFILE_POPUP);
2324 }
2325 return MRFROMLONG(menuHwnd);
2326 }
2327
2328 case WM_CONTROL:
2329 DosError(FERR_DISABLEHARDERR);
2330 if (dcd) {
2331 switch (SHORT2FROMMP(mp1)) {
2332 case CN_CONTEXTMENU:
2333 {
2334 PCNRITEM pci = (PCNRITEM) mp2;
2335
2336 if (pci) {
2337 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
2338 MPFROM2SHORT(TRUE, CRA_CURSORED));
2339 MarkAll(hwnd, FALSE, FALSE, TRUE);
2340 if (pci->attrFile & FILE_DIRECTORY)
2341 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorDirMenu,
2342 COLLECTORDIR_POPUP);
2343 else
2344 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorFileMenu,
2345 COLLECTORFILE_POPUP);
2346 }
2347 else {
2348 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorCnrMenu,
2349 COLLECTORCNR_POPUP);
2350 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2351 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2352 MPFROM2SHORT(TRUE, CRA_SOURCE));
2353 dcd->cnremphasized = TRUE;
2354 }
2355 }
2356 if (dcd->hwndLastMenu) {
2357 if (dcd->hwndLastMenu == CollectorCnrMenu) {
2358 SetViewMenu(dcd->hwndLastMenu, dcd->flWindowAttr);
2359 SetDetailsSwitches(dcd->hwndLastMenu, &dcd->ds);
2360 CopyPresParams(dcd->hwndLastMenu, hwnd);
2361 if (dcd->flWindowAttr & CV_MINI)
2362 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2363 disable_menuitem(dcd->hwndLastMenu, DID_CANCEL,
2364 !dcd->amextracted);
2365 disable_menuitem(dcd->hwndLastMenu, IDM_GREP, dcd->amextracted);
2366 }
2367 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2368 if (dcd->cnremphasized) {
2369 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2370 MPFROM2SHORT(FALSE, CRA_SOURCE));
2371 dcd->cnremphasized = TRUE;
2372 }
2373 MarkAll(hwnd, TRUE, FALSE, TRUE);
2374 }
2375 }
2376 }
2377 break;
2378
2379 case CN_DROPHELP:
2380 if (mp2) {
2381 PDRAGINFO pDInfo;
2382 PCNRITEM pci;
2383 ULONG numitems;
2384 USHORT usOperation;
2385
2386 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2387 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2388 if (!DrgAccessDraginfo(pDInfo)) {
2389 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2390 PCSZ_DRGACCESSDRAGINFO);
2391 return 0;
2392 }
2393 numitems = DrgQueryDragitemCount(pDInfo);
2394 usOperation = pDInfo->usOperation;
2395 if (usOperation == DO_DEFAULT)
2396 usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
2397 FreeDragInfoData(hwnd, pDInfo);
2398 saymsg(MB_ENTER | MB_ICONASTERISK,
2399 hwnd,
2400 GetPString(IDS_DROPHELPHDRTEXT),
2401 GetPString(IDS_DROPHELPTEXT),
2402 numitems,
2403 &"s"[numitems == 1],
2404 (pci) ? NullStr : GetPString(IDS_NOTEXT),
2405 (pci) ? NullStr : " ",
2406 (pci) ? pci->pszFileName : NullStr,
2407 (pci) ? " " : NullStr,
2408 GetPString((usOperation == DO_COPY) ?
2409 IDS_COPYTEXT :
2410 (usOperation == DO_LINK) ?
2411 IDS_LINKTEXT : IDS_MOVETEXT));
2412 }
2413 return 0;
2414
2415 case CN_DRAGLEAVE:
2416 if (mp2) {
2417 PDRAGINFO pDInfo;
2418
2419 // fixme to know why needed
2420 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2421 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
2422 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2423 }
2424 return 0;
2425
2426 case CN_DRAGAFTER:
2427 case CN_DRAGOVER:
2428 if (mp2) {
2429 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2430 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2431 PCNRITEM pci;
2432 USHORT uso;
2433
2434 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2435 // if(SHORT1FROMMP(mp1) == CN_DRAGAFTER)
2436 // pci = NULL;
2437 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2438 if (!DrgAccessDraginfo(pDInfo)) {
2439 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2440 PCSZ_DRGACCESSDRAGINFO);
2441 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2442 }
2443 if (pci) {
2444 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2445 DrgFreeDraginfo(pDInfo);
2446 return (MRFROM2SHORT(DOR_NODROP, 0));
2447 }
2448 uso = pDInfo->usOperation;
2449 if (uso == DO_DEFAULT)
2450 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
2451 if (!(pci->attrFile & FILE_DIRECTORY)) {
2452 if (uso != DO_LINK && uso != DO_MOVE && uso != DO_COPY) {
2453 DrgFreeDraginfo(pDInfo);
2454 return MRFROM2SHORT(DOR_NODROP, 0);
2455 }
2456 if (uso != DO_LINK &&
2457 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2458 DRIVE_NOTWRITEABLE)) {
2459 ARC_TYPE *info = NULL;
2460
2461 if (!fQuickArcFind &&
2462 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2463 DRIVE_SLOW))
2464 info = find_type(pci->pszFileName, NULL);
2465 else
2466 info = quick_find_type(pci->pszFileName, NULL);
2467 if (!info || ((uso == DO_MOVE && !info->move) ||
2468 (uso == DO_COPY && !info->create))) {
2469 DrgFreeDraginfo(pDInfo);
2470 return MRFROM2SHORT(DOR_NODROP, 0);
2471 }
2472 }
2473 }
2474 }
2475 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
2476 0); /* Index to DRAGITEM */
2477 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
2478 (CHAR *) DRM_OS2FILE, /* mechanisms and data */
2479 NULL)) {
2480 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2481 if (pci) {
2482 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
2483 DRIVE_NOTWRITEABLE)
2484 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2485 if (toupper(*pci->pszFileName) < 'C')
2486 return MRFROM2SHORT(DOR_DROP, DO_COPY);
2487 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2488 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2489 }
2490 else
2491 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2492 DO_COPY);
2493 }
2494 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2495 }
2496 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2497
2498 case CN_INITDRAG:
2499 if (mp2) {
2500 BOOL wasemphasized = FALSE;
2501 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2502 PCNRITEM pci;
2503
2504 if (pcd) {
2505 pci = (PCNRITEM) pcd->pRecord;
2506 if (pci) {
2507 if (pci->rc.flRecordAttr & CRA_SELECTED)
2508 wasemphasized = TRUE;
2509 if (IsRoot(pci->pszFileName))
2510 break;
2511 if (hwndStatus2)
2512 WinSetWindowText(hwndStatus2,
2513 (CHAR *) GetPString(IDS_DRAGFILEOBJTEXT));
2514 if (DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE)) {
2515 if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
2516 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2517 }
2518 if (hwndStatus2)
2519 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2520 }
2521 }
2522 }
2523 return 0;
2524
2525 case CN_DROP:
2526 if (mp2) {
2527 LISTINFO *li;
2528 ULONG action = UM_ACTION;
2529
2530 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
2531 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
2532 if (li) {
2533 if (!*li->targetpath) {
2534 li->type = IDM_COLLECT;
2535 action = UM_COLLECT;
2536 }
2537 else {
2538 if (li->list && li->list[0] && IsRoot(li->list[0]))
2539 li->type = DO_LINK;
2540 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2541 CHECKLIST cl;
2542
2543 memset(&cl, 0, sizeof(cl));
2544 cl.size = sizeof(cl);
2545 cl.flags = li->type;
2546 cl.list = li->list;
2547 cl.cmd = li->type;
2548 cl.prompt = li->targetpath;
2549 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2550 DropListProc, FM3ModHandle,
2551 DND_FRAME, MPFROMP(&cl));
2552 if (li->type == DID_ERROR)
2553 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2554 GetPString(IDS_DRAGDROPDIALOGTEXT));
2555 if (!li->type) {
2556 FreeListInfo(li);
2557 return 0;
2558 }
2559 li->list = cl.list;
2560 if (!li->list || !li->list[0]) {
2561 FreeListInfo(li);
2562 return 0;
2563 }
2564 }
2565 switch (li->type) {
2566 case DND_LAUNCH:
2567 strcat(li->targetpath, " %a");
2568 ExecOnList(dcd->hwndParent, li->targetpath,
2569 PROMPT | WINDOWED, NULL, NULL, li->list, NULL,
2570 pszSrcFile, __LINE__);
2571 FreeList(li->list);
2572 li->list = NULL;
2573 break;
2574 case DO_LINK:
2575 if (fLinkSetsIcon) {
2576 li->type = IDM_SETICON;
2577 action = UM_MASSACTION;
2578 }
2579 else
2580 li->type = IDM_COMPARE;
2581 break;
2582 case DND_EXTRACT:
2583 if (*li->targetpath && !IsFile(li->targetpath))
2584 li->type = IDM_EXTRACT;
2585 break;
2586 case DND_MOVE:
2587 li->type = IDM_MOVE;
2588 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2589 action = UM_MASSACTION;
2590 li->type = IDM_ARCHIVEM;
2591 }
2592 break;
2593 case DND_WILDMOVE:
2594 li->type = IDM_WILDMOVE;
2595 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2596 action = UM_MASSACTION;
2597 li->type = IDM_ARCHIVEM;
2598 }
2599 break;
2600 case DND_OBJECT:
2601 li->type = IDM_OBJECT;
2602 action = UM_MASSACTION;
2603 break;
2604 case DND_SHADOW:
2605 li->type = IDM_SHADOW;
2606 action = UM_MASSACTION;
2607 break;
2608 case DND_COMPARE:
2609 li->type = IDM_COMPARE;
2610 break;
2611 case DND_SETICON:
2612 action = UM_MASSACTION;
2613 li->type = IDM_SETICON;
2614 break;
2615 case DND_WILDCOPY:
2616 li->type = IDM_WILDCOPY;
2617 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2618 action = UM_MASSACTION;
2619 li->type = IDM_ARCHIVE;
2620 }
2621 break;
2622 case DND_COPY:
2623 li->type = IDM_COPY;
2624 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2625 action = UM_MASSACTION;
2626 li->type = IDM_ARCHIVE;
2627 }
2628 break;
2629 default:
2630 if (*li->arcname && li->info) {
2631 action = UM_MASSACTION;
2632 li->type =
2633 (li->type ==
2634 DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
2635 }
2636 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2637 action = UM_MASSACTION;
2638 li->type =
2639 (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2640 }
2641 else
2642 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2643 break;
2644 }
2645 }
2646 if (!li->list || !li->list[0])
2647 FreeListInfo(li);
2648 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
2649 FreeListInfo(li);
2650 else {
2651 USHORT usop = 0;
2652
2653 switch (li->type) {
2654 case IDM_COPY:
2655 case IDM_WILDCOPY:
2656 usop = DO_COPY;
2657 break;
2658 case IDM_MOVE:
2659 case IDM_WILDMOVE:
2660 case IDM_ARCHIVEM:
2661 usop = DO_MOVE;
2662 break;
2663 }
2664 if (usop)
2665 return MRFROM2SHORT(DOR_DROP, usop);
2666 }
2667 }
2668 }
2669 return 0;
2670
2671 case CN_BEGINEDIT:
2672 case CN_REALLOCPSZ:
2673 case CN_ENDEDIT:
2674 {
2675 MRESULT mre;
2676
2677 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
2678 if (mre != (MRESULT) - 1)
2679 return mre;
2680 }
2681 break;
2682
2683 case CN_EMPHASIS:
2684 if (mp2) {
2685 PNOTIFYRECORDEMPHASIS pre = mp2;
2686 PCNRITEM pci;
2687 CHAR s[CCHMAXPATH + 91], tb[81], tf[81], szDate[DATE_BUF_BYTES], *p;
2688
2689 pci = (PCNRITEM) ((pre) ? pre->pRecord : NULL);
2690 if (!pci) {
2691 if (hwndStatus2)
2692 WinSetWindowText(hwndStatus2, NullStr);
2693 if (fMoreButtons) {
2694 WinSetWindowText(hwndName, NullStr);
2695 WinSetWindowText(hwndDate, NullStr);
2696 WinSetWindowText(hwndAttr, NullStr);
2697 }
2698 if (hwndMain)
2699 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2700 break;
2701 }
2702 if (pre->fEmphasisMask & CRA_SELECTED) {
2703 if (pci->rc.flRecordAttr & CRA_SELECTED) {
2704 dcd->selectedbytes += (pci->cbFile + pci->easize);
2705 dcd->selectedfiles++;
2706 }
2707 else if (dcd->selectedfiles) {
2708 dcd->selectedbytes -= (pci->cbFile + pci->easize);
2709 dcd->selectedfiles--;
2710 }
2711 if (!dcd->suspendview) {
2712 commafmt(tf, sizeof(tf), dcd->selectedfiles);
2713 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
2714 sprintf(s, "%s / %s", tf, tb);
2715 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
2716 }
2717 }
2718 if (!dcd->suspendview &&
2719 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
2720 if (pre->fEmphasisMask & CRA_CURSORED) {
2721 if (pci->rc.flRecordAttr & CRA_CURSORED) {
2722 if (fSplitStatus && hwndStatus2) {
2723 if (pci->attrFile & FILE_DIRECTORY)
2724 p = pci->pszFileName;
2725 else {
2726 p = strrchr(pci->pszFileName, '\\');
2727 if (p) {
2728 if (*(p + 1))
2729 p++;
2730 else
2731 p = pci->pszFileName;
2732 }
2733 else
2734 p = pci->pszFileName;
2735 }
2736 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
2737 if (!fMoreButtons) {
2738 DateFormat(szDate, pci->date);
2739 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
2740 tb, szDate, pci->time.hours, TimeSeparator,
2741 pci->time.minutes, TimeSeparator, pci->time.seconds,
2742 pci->pszDispAttr, p);
2743 }
2744 else {
2745 if (pci->cbFile + pci->easize > 1024)
2746 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize,
2747 ' ');
2748 else
2749 *tf = 0;
2750 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
2751 tb,
2752 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
2753 }
2754 WinSetWindowText(hwndStatus2, s);
2755 }
2756 if (fMoreButtons) {
2757 WinSetWindowText(hwndName, pci->pszFileName);
2758 DateFormat(szDate, pci->date);
2759 sprintf(s, "%s %02u%s%02u%s%02u",
2760 szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
2761 TimeSeparator, pci->time.seconds);
2762 WinSetWindowText(hwndDate, s);
2763 WinSetWindowText(hwndAttr, pci->pszDispAttr);
2764 }
2765 }
2766 }
2767 }
2768 if (!dcd->suspendview && hwndMain &&
2769 (pre->fEmphasisMask & CRA_CURSORED) &&
2770 (pci->rc.flRecordAttr & CRA_CURSORED) &&
2771 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame)
2772 WinSendMsg(hwndMain, UM_LOADFILE,
2773 MPFROMP(((fComments
2774 || (pci->attrFile & FILE_DIRECTORY) ==
2775 0) ? pci->pszFileName : NULL)), MPVOID);
2776 }
2777 break;
2778
2779 case CN_ENTER:
2780 if (mp2) {
2781 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
2782 FILEFINDBUF3 ffb;
2783 HDIR hDir = HDIR_CREATE;
2784 ULONG nm = 1;
2785 APIRET status = 0;
2786
2787 SetShiftState();
2788 if (pci) {
2789 if (pci->rc.flRecordAttr & CRA_INUSE)
2790 break;
2791 DosError(FERR_DISABLEHARDERR);
2792 status = DosFindFirst(pci->pszFileName, &hDir,
2793 FILE_NORMAL | FILE_DIRECTORY |
2794 FILE_ARCHIVED | FILE_READONLY |
2795 FILE_HIDDEN | FILE_SYSTEM,
2796 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
2797 priority_bumped();
2798 if (!status) {
2799 DosFindClose(hDir);
2800 if (ffb.attrFile & FILE_DIRECTORY) {
2801 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
2802 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0),
2803 MPVOID);
2804 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
2805 (KC_CTRL | KC_SHIFT))
2806 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
2807 else if (shiftstate & KC_CTRL)
2808 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
2809 else
2810 OpenDirCnr(HWND_DESKTOP,
2811 hwndMain,
2812 dcd->hwndFrame, FALSE, pci->pszFileName);
2813 }
2814 else {
2815 SWP swp;
2816
2817 WinSendMsg(hwnd,
2818 CM_SETRECORDEMPHASIS,
2819 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
2820 WinQueryWindowPos(dcd->hwndFrame, &swp);
2821 DefaultViewKeys(hwnd,
2822 dcd->hwndFrame,
2823 dcd->hwndParent, &swp, pci->pszFileName);
2824 WinSendMsg(hwnd,
2825 CM_SETRECORDEMPHASIS,
2826 MPFROMP(pci),
2827 MPFROM2SHORT(FALSE, CRA_INUSE |
2828 ((fUnHilite) ? CRA_SELECTED : 0)));
2829 }
2830 }
2831 else
2832 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
2833 }
2834 }
2835 break;
2836 }
2837 }
2838 return 0;
2839
2840 case UM_LOADFILE:
2841 if (dcd && mp2) {
2842
2843 HWND hwnd;
2844
2845 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
2846 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
2847 (CHAR *)mp2, dcd->hwndFrame);
2848 else
2849 hwnd = StartMLEEditor(dcd->hwndParent,
2850 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
2851 free((CHAR *)mp2);
2852 return MRFROMLONG(hwnd);
2853 }
2854 return 0;
2855
2856 case UM_CLOSE:
2857 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
2858 QW_PARENT));
2859 return 0;
2860
2861 case UM_FOLDUP:
2862 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
2863 DosExit(EXIT_PROCESS, 1);
2864 return 0;
2865
2866 case WM_CLOSE:
2867 if (dcd) {
2868 dcd->namecanchange = TRUE;
2869 dcd->stopflag = 1;
2870 if (dcd->amextracted)
2871 return 0; // Can not close yet
2872 }
2873 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
2874 if (dcd) {
2875 if (!dcd->dontclose && ParentIsDesktop(hwnd, dcd->hwndParent))
2876 PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
2877 if (dcd->hwndObject) {
2878 DosSleep(32); // Allow UM_FOLDUP to process
2879 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
2880 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
2881 }
2882 }
2883 else
2884 WinSendMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
2885 return 0;
2886
2887 case WM_DESTROY:
2888 if (CollectorDirMenu)
2889 WinDestroyWindow(CollectorDirMenu);
2890 if (CollectorFileMenu)
2891 WinDestroyWindow(CollectorFileMenu);
2892 if (CollectorCnrMenu)
2893 WinDestroyWindow(CollectorCnrMenu);
2894 CollectorCnrMenu = CollectorFileMenu = CollectorDirMenu = (HWND) 0;
2895 Collector = (HWND) 0;
2896 EmptyCnr(hwnd);
2897 break;
2898 }
2899 if (dcd && dcd->oldproc){
2900 return dcd->oldproc(hwnd, msg, mp1, mp2);
2901 }
2902 else
2903 return PFNWPCnr(hwnd, msg, mp1, mp2);
2904}
2905
2906MRESULT EXPENTRY CollectorMenuProc(HWND hwnd, ULONG msg, MPARAM mp1,
2907 MPARAM mp2)
2908{
2909 PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
2910 static short sLastMenuitem;
2911
2912 switch (msg) {
2913 case WM_MOUSEMOVE: {
2914 if (fOtherHelp) {
2915 RECTL rectl;
2916 SHORT i, sCurrentMenuitem;
2917 SHORT MenuItems = 5;
2918 SHORT asMenuIDs[5] = {IDM_GREP,
2919 IDM_SEEALL,
2920 IDM_CLEARCNR,
2921 IDM_REMOVE,
2922 0};
2923 PCSZ szHelpString = NULL;
2924
2925
2926 for (i=0; i<MenuItems; i++) {
2927 sCurrentMenuitem = asMenuIDs[i];
2928 oldMenuProc(hwnd,MM_QUERYITEMRECT,
2929 MPFROM2SHORT(asMenuIDs[i], FALSE),
2930 &rectl);
2931
2932 if (MOUSEMSG(&msg)->x > rectl.xLeft &&
2933 MOUSEMSG(&msg)->x < rectl.xRight &&
2934 MOUSEMSG(&msg)->y > rectl.yBottom &&
2935 MOUSEMSG(&msg)->y < rectl.yTop)
2936 break;
2937 } // for
2938
2939
2940 switch (sCurrentMenuitem) {
2941 case 0:
2942 break;
2943 case IDM_GREP:
2944 szHelpString = GetPString(IDS_COLMENUSEEKSCANHELP);
2945 break;
2946 case IDM_SEEALL:
2947 szHelpString = GetPString(IDS_COLMENUSEEALLHELP);
2948 break;
2949 case IDM_CLEARCNR:
2950 szHelpString = GetPString(IDS_COLMENUCLEARCNRHELP);
2951 break;
2952 case IDM_REMOVE:
2953 szHelpString = GetPString(IDS_COLMENUREMOVECNRHELP);
2954 break;
2955 default:
2956 break;
2957 }
2958
2959 if (sLastMenuitem != sCurrentMenuitem && szHelpString) {
2960 sLastMenuitem = sCurrentMenuitem;
2961 MakeBubble(hwnd, TRUE, szHelpString);
2962 }
2963 else if (hwndBubble && !sCurrentMenuitem){
2964 sLastMenuitem = sCurrentMenuitem;
2965 WinDestroyWindow(hwndBubble);
2966 }
2967 }
2968 }
2969 }
2970 return oldMenuProc(hwnd, msg, mp1, mp2);
2971}
2972
2973HWND StartCollector(HWND hwndParent, INT flags)
2974{
2975 HWND hwndFrame = (HWND) 0;
2976 HWND hwndClient;
2977 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
2978 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
2979 USHORT id;
2980 DIRCNRDATA *dcd;
2981
2982 static USHORT idinc = 0;
2983
2984 if (ParentIsDesktop(hwndParent, hwndParent))
2985 FrameFlags |= (FCF_TASKLIST | FCF_SHELLPOSITION | FCF_MENU);
2986 if (Collector) {
2987 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
2988 QW_PARENT),
2989 QW_PARENT),
2990 HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE);
2991 return WinQueryWindow(WinQueryWindow(Collector, QW_PARENT), QW_PARENT);
2992 }
2993 hwndFrame = WinCreateStdWindow(hwndParent,
2994 WS_VISIBLE,
2995 &FrameFlags,
2996 (CHAR *) WC_COLLECTOR,
2997 NULL,
2998 WS_VISIBLE | fwsAnimate,
2999 FM3ModHandle, COLLECTOR_FRAME, &hwndClient);
3000 if (hwndFrame && hwndClient) {
3001 id = COLLECTOR_FRAME + idinc++;
3002 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3003# ifdef FORTIFY
3004 Fortify_EnterScope();
3005# endif
3006 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3007 if (!dcd) {
3008 Runtime_Error(pszSrcFile, __LINE__, NULL);
3009 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3010 hwndFrame = (HWND) 0;
3011 }
3012 else {
3013 dcd->size = sizeof(DIRCNRDATA);
3014 dcd->id = id;
3015 dcd->type = COLLECTOR_FRAME;
3016 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3017 dcd->hwndFrame = hwndFrame;
3018 dcd->hwndClient = hwndClient;
3019 if (flags & 4)
3020 dcd->dontclose = TRUE;
3021 {
3022 PFNWP oldproc;
3023
3024 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) CollectorFrameWndProc);
3025 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3026 }
3027 dcd->hwndCnr = WinCreateWindow(hwndClient,
3028 WC_CONTAINER,
3029 NULL,
3030 CCS_AUTOPOSITION | CCS_MINIICONS |
3031 CCS_MINIRECORDCORE | ulCnrType |
3032 WS_VISIBLE,
3033 0,
3034 0,
3035 0,
3036 0,
3037 hwndClient,
3038 HWND_TOP,
3039 (ULONG) COLLECTOR_CNR, NULL, NULL);
3040 if (!dcd->hwndCnr) {
3041 Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
3042 PCSZ_WINCREATEWINDOW);
3043 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3044 free(dcd);
3045 hwndFrame = (HWND) 0;
3046 }
3047 else {
3048 Collector = dcd->hwndCnr;
3049 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3050 WinSetWindowText(hwndFrame, (CHAR *) GetPString(IDS_COLLECTORTITLETEXT));
3051 if (FrameFlags & FCF_MENU) {
3052 PFNWP oldmenuproc;
3053 HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
3054
3055 oldmenuproc = WinSubclassWindow(hwndMenu, (PFNWP) CollectorMenuProc);
3056 WinSetWindowPtr(hwndMenu, QWL_USER, (PVOID) oldmenuproc);
3057 if (!fToolbar) {
3058 if (hwndMenu) {
3059
3060 WinSendMsg(hwndMenu,
3061 MM_DELETEITEM,
3062 MPFROM2SHORT(IDM_SEEALL, FALSE), MPVOID);
3063 WinSendMsg(hwndMenu,
3064 MM_DELETEITEM,
3065 MPFROM2SHORT(IDM_GREP, FALSE), MPVOID);
3066 WinSendMsg(hwndMenu,
3067 MM_DELETEITEM,
3068 MPFROM2SHORT(IDM_CLEARCNR, FALSE), MPVOID);
3069 WinSendMsg(hwndMenu,
3070 MM_DELETEITEM,
3071 MPFROM2SHORT(IDM_REMOVE, FALSE), MPVOID);
3072 }
3073 }
3074 }
3075 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3076 (PFNWP) CollectorCnrWndProc);
3077 {
3078 USHORT ids[] = { DIR_TOTALS,
3079 DIR_SELECTED,
3080 DIR_VIEW,
3081 DIR_SORT,
3082 DIR_FILTER,
3083 0
3084 };
3085
3086 CommonCreateTextChildren(dcd->hwndClient,
3087 WC_COLSTATUS, ids);
3088 }
3089 if (FrameFlags & FCF_SHELLPOSITION)
3090 PostMsg(hwndClient, UM_SIZE, MPVOID, MPVOID);
3091 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3092 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3093 }
3094 }
3095# ifdef FORTIFY
3096 DosSleep(1); // Let receiver take ownership
3097 Fortify_LeaveScope();
3098# endif
3099 }
3100 return hwndFrame;
3101}
3102
3103#pragma alloc_text(COLLECTOR,CollectorCnrWndProc,CollectorObjWndProc)
3104#pragma alloc_text(COLLECTOR,CollectorClientWndProc,CollectorTextProc)
3105#pragma alloc_text(COLLECTOR,CollectorFrameWndProc)
3106#pragma alloc_text(STARTUP,StartCollector)
Note: See TracBrowser for help on using the repository browser.