source: trunk/dll/collect.c@ 1878

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

Remove some dead code and comments source files starting with A-D

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