source: trunk/dll/collect.c@ 1562

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

Code clean up for collector trap on find dups

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