source: trunk/dll/collect.c@ 1430

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

Additional comments

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