source: trunk/dll/collect.c@ 1803

Last change on this file since 1803 was 1803, checked in by Gregg Young, 10 years ago

Changes to allow a JAVA executable object to be created using "Real object" menu item on a jar file. (Ticket [37]) Eliminate redundant prompts and error messages when telling FM/2 not to delete a R/O file. (Ticket [548]) Limit attempts to unlock files to exes and dlls. (Ticket [549])

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