source: trunk/dll/collect.c@ 1561

Last change on this file since 1561 was 1561, checked in by Gregg Young, 14 years ago

Fixed trap on find dups when number of files exceeded the sizeof a USHORT (ticket 446). Increased vcollect stack size; comments.

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