source: trunk/dll/collect.c@ 1424

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

Show either file system type or drive label beside dirve letter in tree. (tickets 47 & 339)

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