source: trunk/dll/collect.c@ 1211

Last change on this file since 1211 was 1205, checked in by John Small, 17 years ago

Ticket 187: Move datadevlarations/definitions out of fm3dll.h

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