source: trunk/dll/collect.c@ 1395

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

Allow user to turn off alert and/or error beeps in settings notebook. Ticket 341 Move repeated strings to PCSZs. Ticket 6 Add *DateFormat functions to format dates based on locale Ticket 28 Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error Ticket 6

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