source: trunk/dll/collect.c@ 986

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

Update sizes dialog (ticket 44); Make max command line length user settable (ticket 199); use xfree for free in most cases (ticket 212); initial code to check for valid ini file (ticket 102); Some additional refactoring and structure rework; Some documentation updates;

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