source: trunk/dll/collect.c@ 1400

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

Remainder of changes to rename commafmt.h/c (Ticket 28, 82); Additional strings moved to PCSZs in init.c (Ticket 6); Added WriteDetailsSwitches used it and LoadDetailsSwitches to consolidate inline code (Ticket 343, 344)

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