source: trunk/dll/collect.c@ 946

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

Minor code cleanup and documentation for some changes. (Tickets 3, 7, 184)

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