source: trunk/dll/collect.c@ 1387

Last change on this file since 1387 was 1375, checked in by Gregg Young, 17 years ago

Updated history; comments minor code cleanup for recent changes

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