source: trunk/dll/collect.c@ 1547

Last change on this file since 1547 was 1547, checked in by Gregg Young, 15 years ago

Improvements to collector opening directory container from the path of the selected item. More completely matches the change requested (Ticket 362).

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