source: trunk/dll/collect.c@ 1442

Last change on this file since 1442 was 1442, checked in by Gregg Young, 16 years ago

Fixed 2 memory management problems; changes to get FORTIFY build to work again.

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