source: trunk/dll/collect.c@ 1010

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

Add xfree xstrdup Fortify support
Add MT capable Fortify scope logic

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