source: trunk/dll/collect.c@ 1430

Last change on this file since 1430 was 1430, checked in by Gregg Young, 16 years ago

Additional comments

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