source: trunk/dll/collect.c@ 1844

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

Fix trap in collector if a pci-pszFileName = NullStr and fix heap corruption problem and its related traps. This code reverts John double free fix. Ticket [551][555]

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