source: trunk/dll/collect.c@ 1194

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

Ticket 187: Draft 2: Move remaining function declarations

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