source: trunk/dll/collect.c@ 1330

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

Ticket 187: Moved typedef's and some #define's from fm3dll.h

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