source: trunk/dll/collect.c@ 1365

Last change on this file since 1365 was 1357, checked in by Gregg Young, 17 years ago

Fixed DROPHELP issues Tickets 320 & 324

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