source: trunk/dll/collect.c@ 1442

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

Fixed 2 memory management problems; changes to get FORTIFY build to work again.

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