source: trunk/dll/collect.c@ 942

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

Impliment bubble help for bitmap menu items in the collector and arc container. (Ticket #7)

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