source: trunk/dll/collect.c@ 1358

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

Fixed DROPHELP issues Tickets 320 & 324

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