source: trunk/dll/collect.c@ 1120

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

Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if less than 10 KiB (It hangs and can't be closed) (Ticket 214) Also some cleanup of the error messages for CheckDriveSpaceAvail.

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