source: trunk/dll/collect.c@ 1335

Last change on this file since 1335 was 1335, checked in by Steven Levine, 17 years ago

Ticket 26: Add exception handlers to all threads using xbeginthread

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