source: trunk/dll/collect.c@ 1194

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

Ticket 187: Draft 2: Move remaining function declarations

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