source: trunk/dll/collect.c@ 1405

Last change on this file since 1405 was 1402, checked in by Gregg Young, 17 years ago

Remove variable aurgs from docopy & unlinkf (not used); Move more strings to PCSZs and string table; Move PCSZs to compile time initialization; Fix hang on startup caused by a drive scan and a dircnr scan trying to update a drive in the tree at the same time (related to the "treeswitch options); Code cleanup mainly removal of old printfs, SayMsgs, DbgMsg and unneeded %s.

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