source: trunk/dll/collect.c@ 953

Last change on this file since 953 was 953, checked in by Steven Levine, 18 years ago

Rework code and resources to support settings menu conditional cascade
Optimize last settings menu save/restore

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