source: trunk/dll/collect.c@ 1398

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

Move embeded strings to PCSZ variables or string table; Eliminate Error2 functions Runtime_Error with NULL format string returns "No data" error. Change declares from PSZ to PCSZ in functions where the variable isn't changed. Added btm as an executable file type in several additional places. Use fProtectOnly to prevent attempt to execute Dos and Win programs on "Protect only" installs in several additional places.

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