source: trunk/dll/collect.c@ 1331

Last change on this file since 1331 was 1221, checked in by John Small, 17 years ago

Ticket 187: Moved typedef's and some #define's from fm3dll.h

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