source: trunk/dll/collect.c@ 1612

Last change on this file since 1612 was 1612, checked in by Steven Levine, 14 years ago

Rework UM_COLLECT to avoid freeing wrong CNRITEM
Corrects ticket #461
This revision corrects bad commit comment for @1611

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