source: trunk/dll/collect.c@ 1018

Last change on this file since 1018 was 1018, checked in by Gregg Young, 17 years ago

Additional fortify scopes mostly for "lists"

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