source: trunk/dll/collect.c@ 1561

Last change on this file since 1561 was 1561, checked in by Gregg Young, 14 years ago

Fixed trap on find dups when number of files exceeded the sizeof a USHORT (ticket 446). Increased vcollect stack size; comments.

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