source: trunk/dll/collect.c@ 1546

Last change on this file since 1546 was 1546, checked in by Gregg Young, 15 years ago

Add menu item to allow opening of directory container from the collector based on the path of the selected item. (Ticket 362) Add open file button to EAs dialog to allow opening of a new file's eas (Ticket 439). Initial work on populating the help table (It provides F1 help a few more places) (Ticket 95). Some minor code cleanup and help file updates.

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