source: trunk/dll/collect.c@ 1178

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

Ticket 187: Draft 1: Functions only

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