source: trunk/dll/collect.c@ 956

Last change on this file since 956 was 956, checked in by Gregg Young, 18 years ago

Fix attempt to free container items that were never inserted. Fix "collect" so it updates recollected files and unhides them if needed. (Ticket 220)

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