source: trunk/dll/collect.c@ 1439

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

Changes to allow high mem loading of dll; Refactor .LONGNAME and .SUBJECT EA fetch to FetchCommonEAs. Add szFSType to FillInRecordFromFSA use to bypass EA scan and size formatting for tree container; Fix labels/FS type to work on scan on NOPRESCAN Drives; Fixed dbl directory names on restore of dir cnrs; (Tickets 47, 339, 363, 368, 369, 370)

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