source: trunk/dll/collect.c@ 1102

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

Added ability to save/append either the full path name (already present) or just the filename to the clipboard. Changed the menu text to make these easier to find. Removed the final return/newline from the list. Ticket 137

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