source: trunk/dll/collect.c@ 1736

Last change on this file since 1736 was 1702, checked in by Steven Levine, 12 years ago

CollectorCnrWndProc IDM_FILTER: avoid exception on missing fileName

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