source: trunk/dll/collect.c@ 1211

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

Ticket 187: Move datadevlarations/definitions out of fm3dll.h

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