source: trunk/dll/collect.c@ 1497

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

Update ExecOnList to pass environment

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