source: trunk/dll/collect.c@ 1335

Last change on this file since 1335 was 1335, checked in by Steven Levine, 17 years ago

Ticket 26: Add exception handlers to all threads using xbeginthread

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