source: trunk/dll/collect.c@ 1036

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

Fixed early memory free; Added free_... functions to make fortify checking easier; Added fortify scopes; Delete now moves to trash can on systems with the xworkplace trash can installed.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 76.9 KB
RevLine 
[96]1
2/***********************************************************************
3
4 $Id: collect.c 1029 2008-06-23 01:30:16Z 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__);
[1029]787# ifdef FORTIFY
788 Fortify_LeaveScope();
789# endif
[194]790 return 0;
[2]791
[194]792 case UM_SELECT:
793 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
[444]794 if (dcd) {
795 switch (SHORT1FROMMP(mp1)) {
[194]796 case IDM_SELECTLIST:
797 {
798 CHAR filename[CCHMAXPATH], *p, *pp;
[2]799
[194]800 strcpy(filename, "*.LST");
801 size = CCHMAXPATH;
[551]802 PrfQueryProfileData(fmprof, appname, "SaveToListName", filename,
803 &size);
[194]804 pp = strrchr(filename, '\\');
805 if (!pp)
806 pp = filename;
807 p = strrchr(pp, '.');
[444]808 if (p && *(p + 1) && p > pp + 1) {
[194]809 if (pp > filename)
810 pp++;
811 *pp = '*';
812 pp++;
813 if (p > pp)
814 memmove(pp, p, strlen(p) + 1);
815 }
816 if (insert_filename(hwnd, filename, FALSE, FALSE))
[551]817 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
818 NULL);
[194]819 }
820 break;
821 case IDM_SELECTALL:
[551]822 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
[194]823 break;
824 case IDM_DESELECTALL:
[551]825 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
[194]826 break;
827 case IDM_SELECTALLFILES:
[551]828 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
[194]829 break;
830 case IDM_DESELECTALLFILES:
[551]831 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
[194]832 break;
833 case IDM_SELECTALLDIRS:
[551]834 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
[194]835 break;
836 case IDM_DESELECTALLDIRS:
[551]837 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
[194]838 break;
839 case IDM_DESELECTMASK:
840 case IDM_SELECTMASK:
841 {
842 MASK mask;
843 PCNRITEM pci = (PCNRITEM) mp2;
[2]844
[194]845 memset(&mask, 0, sizeof(MASK));
846 mask.fNoAttribs = TRUE;
847 mask.fNoDirs = TRUE;
848 mask.fText = TRUE;
849 strcpy(mask.prompt,
850 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
[551]851 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
[194]852 if (pci && (INT) pci != -1)
[730]853 strcpy(mask.szMask, pci->pszFileName);
[551]854 if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
855 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
[194]856 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
[551]857 SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
[194]858 FALSE);
859 else
[551]860 DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
[194]861 FALSE);
862 }
863 }
[2]864
[194]865 case IDM_DESELECTCLIP:
866 case IDM_SELECTCLIP:
867 {
868 CHAR **list;
[2]869
[194]870 list = ListFromClipboard(hwnd);
[444]871 if (list) {
[551]872 SelectList(dcd->hwndCnr, TRUE, FALSE,
[194]873 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
874 NULL, NULL, list);
875 FreeList(list);
876 }
877 }
878 break;
[2]879
[194]880 case IDM_INVERT:
[551]881 InvertAll(dcd->hwndCnr);
[194]882 break;
[2]883 }
[194]884 }
885 return 0;
[2]886
[194]887 case UM_MASSACTION:
[444]888 if (mp1) {
[194]889 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
[444]890 if (dcd) {
[194]891 WORKER *wk;
[1017]892# ifdef FORTIFY
893 Fortify_EnterScope();
894# endif
[551]895 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
[444]896 if (!wk)
[352]897 FreeListInfo((LISTINFO *) mp1);
898 else {
[551]899 wk->size = sizeof(WORKER);
900 wk->hwndCnr = dcd->hwndCnr;
901 wk->hwndParent = dcd->hwndParent;
902 wk->hwndFrame = dcd->hwndFrame;
903 wk->hwndClient = dcd->hwndClient;
904 wk->li = (LISTINFO *) mp1;
905 strcpy(wk->directory, dcd->directory);
[444]906 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
[551]907 Runtime_Error(pszSrcFile, __LINE__,
908 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[1017]909 xfree(wk, pszSrcFile, __LINE__);
910# ifdef FORTIFY
911 Fortify_LeaveScope();
912# endif
[194]913 FreeListInfo((LISTINFO *) mp1);
914 }
915 }
[2]916 }
[194]917 }
918 return 0;
[2]919
[194]920 case UM_ACTION:
[444]921 if (mp1) {
[194]922 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
[444]923 if (dcd) {
[194]924 WORKER *wk;
[1017]925# ifdef FORTIFY
926 Fortify_EnterScope();
927# endif
[551]928 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
[352]929 if (!wk)
930 FreeListInfo((LISTINFO *) mp1);
931 else {
[551]932 wk->size = sizeof(WORKER);
933 wk->hwndCnr = dcd->hwndCnr;
934 wk->hwndParent = dcd->hwndParent;
935 wk->hwndFrame = dcd->hwndFrame;
936 wk->hwndClient = dcd->hwndClient;
937 wk->li = (LISTINFO *) mp1;
938 strcpy(wk->directory, dcd->directory);
[444]939 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
[551]940 Runtime_Error(pszSrcFile, __LINE__,
941 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[1017]942 xfree(wk, pszSrcFile, __LINE__);
943# ifdef FORTIFY
944 Fortify_LeaveScope();
945# endif
[194]946 FreeListInfo((LISTINFO *) mp1);
947 }
948 }
[2]949 }
[194]950 }
951 return 0;
[2]952
[194]953 case WM_CLOSE:
954 WinDestroyWindow(hwnd);
955 break;
[2]956
[194]957 case WM_DESTROY:
958 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
[444]959 if (dcd) {
960 INT x;
[551]961
962 dcd->stopflag = 1;
[942]963 // Allow other threads to honor stop request
964 for (x = 0; x < 100 && dcd->amextracted; x++)
965 DosSleep(10);
966 if (dcd->amextracted)
967 Runtime_Error(pszSrcFile, __LINE__, "still busy");
[551]968 WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
969 FreeList(dcd->lastselection);
[1009]970 xfree(dcd, pszSrcFile, __LINE__);
[1017]971# ifdef FORTIFY
972 Fortify_LeaveScope();
973# endif
974 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
[194]975 }
976 DosPostEventSem(CompactSem);
[551]977 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
978 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
[194]979 break;
[2]980 }
[194]981 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]982}
983
[551]984MRESULT EXPENTRY CollectorCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
985 MPARAM mp2)
[155]986{
[672]987 DIRCNRDATA *dcd = INSTDATA(hwnd);
[197]988 ULONG size;
[2]989
[197]990 static INT savedSortFlags;
991
[444]992 switch (msg) {
[194]993 case DM_PRINTOBJECT:
994 return MRFROMLONG(DRR_TARGET);
995
996 case DM_DISCARDOBJECT:
997 if (dcd)
[551]998 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
[194]999 else
[2]1000 return MRFROMLONG(DRR_TARGET);
1001
[194]1002 case WM_CHAR:
1003 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1004 if (SHORT1FROMMP(mp1) & KC_KEYUP)
1005 return (MRESULT) TRUE;
[444]1006 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1007 switch (SHORT2FROMMP(mp2)) {
[194]1008 case VK_DELETE:
1009 if ((shiftstate & KC_CTRL) == KC_CTRL)
1010 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
1011 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
1012 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
1013 else
1014 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
1015 break;
[2]1016 }
[194]1017 }
1018 if (shiftstate || fNoSearch)
1019 break;
[444]1020 if (SHORT1FROMMP(mp1) & KC_CHAR) {
[194]1021 ULONG thistime, len;
1022 SEARCHSTRING srch;
1023 PCNRITEM pci;
[2]1024
[194]1025 if (!dcd)
1026 break;
[444]1027 switch (SHORT1FROMMP(mp2)) {
[194]1028 case '\x1b':
1029 case '\r':
1030 case '\n':
[551]1031 dcd->lasttime = 0;
1032 *dcd->szCommonName = 0;
[194]1033 break;
1034 default:
1035 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
[551]1036 if (thistime > dcd->lasttime + 1250)
1037 *dcd->szCommonName = 0;
1038 dcd->lasttime = thistime;
1039 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
[194]1040 break;
1041 KbdRetry:
[551]1042 len = strlen(dcd->szCommonName);
[444]1043 if (len >= CCHMAXPATH - 1) {
[551]1044 *dcd->szCommonName = 0;
[194]1045 len = 0;
1046 }
[551]1047 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1048 dcd->szCommonName[len + 1] = 0;
[194]1049 memset(&srch, 0, sizeof(SEARCHSTRING));
[197]1050 srch.cb = sizeof(SEARCHSTRING);
[551]1051 srch.pszSearch = dcd->szCommonName;
[194]1052 srch.fsPrefix = TRUE;
1053 srch.fsCaseSensitive = FALSE;
1054 srch.usView = CV_ICON;
1055 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
1056 MPFROMLONG(CMA_FIRST));
[444]1057 if (pci && (INT) pci != -1) {
[194]1058 USHORT attrib = CRA_CURSORED;
[2]1059
[194]1060 /* make found item current item */
[551]1061 if (!stricmp(pci->pszFileName, dcd->szCommonName))
[194]1062 attrib |= CRA_SELECTED;
1063 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1064 MPFROM2SHORT(TRUE, attrib));
1065 /* make sure that record shows in viewport */
1066 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1067 return (MRESULT) TRUE;
1068 }
[444]1069 else {
1070 if (SHORT1FROMMP(mp2) == ' ') {
[551]1071 dcd->szCommonName[len] = 0;
[194]1072 break;
1073 }
[551]1074 *dcd->szCommonName = 0;
1075 dcd->lasttime = 0;
[194]1076 if (len) // retry as first letter if no match
[2]1077
[194]1078 goto KbdRetry;
1079 }
1080 break;
[2]1081 }
[194]1082 }
1083 break;
[2]1084
[194]1085 case WM_MOUSEMOVE:
1086 case WM_BUTTON1UP:
1087 case WM_BUTTON2UP:
1088 case WM_BUTTON3UP:
1089 case WM_CHORD:
1090 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1091 break;
[2]1092
[194]1093 case WM_BUTTON1MOTIONEND:
1094 {
1095 CNRINFO cnri;
1096
1097 memset(&cnri, 0, sizeof(CNRINFO));
1098 cnri.cb = sizeof(CNRINFO);
1099 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
[551]1100 MPFROMLONG(sizeof(CNRINFO)))) {
[194]1101 if (cnri.flWindowAttr & CV_DETAIL)
1102 PrfWriteProfileData(fmprof, appname, "CollectorCnrSplitBar",
1103 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
[2]1104 }
[194]1105 }
1106 break;
[2]1107
[194]1108 case WM_PRESPARAMCHANGED:
1109 PresParamChanged(hwnd, "Collector", mp1, mp2);
1110 break;
[2]1111
[194]1112 case UM_COMPARE:
[444]1113 if (dcd && mp1 && mp2) {
[194]1114 COMPARE *cmp;
[1009]1115 CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
[2]1116
[444]1117 if (!IsFile(leftdir) && !IsFile(rightdir)) {
[551]1118 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
[444]1119 if (cmp) {
[551]1120 cmp->size = sizeof(COMPARE);
1121 strcpy(cmp->leftdir, leftdir);
1122 strcpy(cmp->rightdir, rightdir);
1123 cmp->hwndParent = dcd->hwndParent;
1124 cmp->dcd.hwndParent = dcd->hwndParent;
[194]1125 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, CompareDlgProc,
1126 FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1127 }
[2]1128 }
[194]1129 }
1130 return 0;
[2]1131
[194]1132 case UM_UPDATERECORDLIST:
1133 if (dcd && mp1)
[551]1134 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
[194]1135 return 0;
[2]1136
[194]1137 case UM_UPDATERECORD:
[444]1138 if (dcd && mp1) {
[194]1139 CHAR *filename;
[2]1140
[194]1141 filename = mp1;
1142 if (filename)
1143 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1144 }
1145 return 0;
[2]1146
[194]1147 case WM_SETFOCUS:
1148 /*
1149 * put name of our window on status line
1150 */
[444]1151 if (dcd && hwndStatus && mp2) {
[194]1152 PCNRITEM pci = NULL;
[2]1153
[444]1154 if (fAutoView && hwndMain) {
[194]1155 pci = WinSendMsg(hwnd,
1156 CM_QUERYRECORDEMPHASIS,
[551]1157 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
[194]1158 if (pci && (INT) pci != -1 &&
[730]1159 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1160 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
[194]1161 else
[551]1162 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
[2]1163 }
[551]1164 if (dcd->amextracted)
1165 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1166 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
[194]1167 }
1168 break;
[2]1169
[194]1170 case UM_RESCAN:
[444]1171 if (dcd) {
[194]1172 CNRINFO cnri;
1173 CHAR s[CCHMAXPATH + 69], tb[81], tf[81], *p;
1174 PCNRITEM pci = NULL;
[2]1175
[194]1176 memset(&cnri, 0, sizeof(CNRINFO));
1177 cnri.cb = sizeof(CNRINFO);
1178 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1179 MPFROMLONG(sizeof(CNRINFO)));
[551]1180 dcd->totalfiles = cnri.cRecords;
1181 commafmt(tf, sizeof(tf), dcd->totalfiles);
1182 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
[194]1183 sprintf(s, "%s / %s", tf, tb);
[551]1184 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
[2]1185
[551]1186 commafmt(tf, sizeof(tf), dcd->selectedfiles);
1187 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
[194]1188 sprintf(s, "%s / %s", tf, tb);
[551]1189 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
[155]1190
[194]1191 if (hwndStatus &&
[551]1192 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
[444]1193 if (hwndMain) {
[194]1194 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
[551]1195 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
[194]1196 if (pci && (INT) pci != -1)
[730]1197 PostMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
[194]1198 else
1199 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1200 }
[948]1201 if (!dcd->amextracted) {
1202 if (!fMoreButtons) {
1203 sprintf(s, " %s%s%s%s",
[942]1204 GetPString(IDS_COLLECTORTEXT),
[948]1205 *dcd->mask.szMask || dcd->mask.antiattr ||
1206 dcd->mask.attrFile != ALLATTRS ? " (" : NullStr,
1207 *dcd->mask.szMask ?
1208 dcd->mask.szMask :
1209 dcd->mask.antiattr ||
1210 dcd->mask.attrFile != ALLATTRS ?
1211 GetPString(IDS_ATTRTEXT) : NullStr,
1212 *dcd->mask.szMask || dcd->mask.antiattr ||
1213 dcd->mask.attrFile != ALLATTRS ?
1214 ")" : NullStr);
1215 }
1216 else
1217 strcpy(s, GetPString(IDS_COLLECTORTEXT));
1218 WinSetWindowText(hwndStatus, s);
[942]1219 }
[194]1220 if (!pci)
1221 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
[551]1222 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
[444]1223 if (pci && (INT) pci != -1) {
[280]1224 BOOL fStatus2Used = FALSE;
[551]1225
[444]1226 if (fSplitStatus && hwndStatus2) {
[551]1227 if (pci->attrFile & FILE_DIRECTORY)
1228 p = pci->pszFileName;
[444]1229 else {
[730]1230 p = strrchr(pci->pszFileName, '\\');
[444]1231 if (p) {
[194]1232 if (*(p + 1))
1233 p++;
1234 else
[551]1235 p = pci->pszFileName;
[155]1236 }
[194]1237 else
[551]1238 p = pci->pszFileName;
[194]1239 }
[551]1240 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
[444]1241 if (!fMoreButtons) {
[194]1242 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
[551]1243 tb, pci->date.year, pci->date.month,
1244 pci->date.day, pci->time.hours, pci->time.minutes,
1245 pci->time.seconds, pci->pszDispAttr, p);
[194]1246 }
[444]1247 else {
[551]1248 if (pci->cbFile + pci->easize > 1024)
1249 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
[194]1250 else
1251 *tf = 0;
1252 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
[551]1253 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
[194]1254 }
1255 WinSetWindowText(hwndStatus2, s);
[280]1256 fStatus2Used = TRUE;
[194]1257 }
[444]1258 if (fMoreButtons) {
[551]1259 WinSetWindowText(hwndName, pci->pszFileName);
[194]1260 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
[551]1261 pci->date.year, pci->date.month,
1262 pci->date.day, pci->time.hours, pci->time.minutes,
1263 pci->time.seconds);
[194]1264 WinSetWindowText(hwndDate, s);
[551]1265 WinSetWindowText(hwndAttr, pci->pszDispAttr);
[194]1266 }
[551]1267 if (dcd->amextracted && hwndStatus2 && !fStatus2Used)
[280]1268 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
[194]1269 }
[444]1270 else {
[948]1271 if (hwndStatus2) {
1272 if (dcd->amextracted)
1273 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1274 else
1275 WinSetWindowText(hwndStatus2, NullStr);
1276 }
[444]1277 if (fMoreButtons) {
[194]1278 WinSetWindowText(hwndName, NullStr);
1279 WinSetWindowText(hwndDate, NullStr);
1280 WinSetWindowText(hwndAttr, NullStr);
1281 }
1282 }
[2]1283 }
[194]1284 }
1285 return 0;
[2]1286
[194]1287 case UM_CONTAINER_FILLED:
[551]1288 DosBeep(1000, 50); // Wake up user?
[194]1289 WinSendMsg(hwnd,
1290 CM_INVALIDATERECORD,
[551]1291 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
[471]1292 disable_menuitem(WinWindowFromID(WinQueryWindow(hwndMain, QW_PARENT),
[551]1293 FID_MENU), IDM_GREP, FALSE);
1294 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
[444]1295 if (dcd) {
[551]1296 dcd->stopflag = 0;
1297 dcd->amextracted = FALSE; // Say not busy
1298 if (dcd->namecanchange) {
1299 if (!PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID))
1300 WinSendMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
[2]1301 }
[194]1302 else
1303 WinSetWindowPos(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
1304 QW_PARENT),
1305 HWND_TOP,
[551]1306 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ZORDER);
[194]1307 }
1308 return 0;
[2]1309
[194]1310 case UM_SETUP:
[444]1311 if (dcd) {
[551]1312 if (!dcd->hwndObject) {
[471]1313 /* first time through -- set things up */
[2]1314
[194]1315 CNRINFO cnri;
[2]1316
[194]1317 RestorePresParams(hwnd, "Collector");
1318 LoadDetailsSwitches("Collector", dcd);
[471]1319
[551]1320 dcd->amextracted = FALSE; // Say not busy
1321 dcd->stopflag = 0;
[194]1322 memset(&cnri, 0, sizeof(CNRINFO));
1323 cnri.cb = sizeof(CNRINFO);
1324 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1325 MPFROMLONG(sizeof(CNRINFO)));
1326 cnri.cyLineSpacing = 0;
[750]1327 cnri.cxTreeIndent = 12;
[2]1328
[551]1329 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_DETAIL));
[194]1330 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES |
1331 CV_MINI | CV_FLOW);
1332 cnri.pSortRecord = (PVOID) SortCollectorCnr;
[2]1333
[444]1334 size = sizeof(ULONG);
1335 PrfQueryProfileData(fmprof, appname, "CollectorflWindowAttr",
1336 (PVOID) & cnri.flWindowAttr, &size);
1337 size = sizeof(MASK);
1338 if (PrfQueryProfileSize(fmprof, appname, "CollectorFilter", &size) &&
[551]1339 size) {
1340 PrfQueryProfileData(fmprof, appname, "CollectorFilter", &dcd->mask,
[444]1341 &size);
[551]1342 SetMask(NULL, &dcd->mask);
[194]1343 }
[444]1344 else {
[551]1345 dcd->mask.attrFile = (FILE_NORMAL | FILE_READONLY |
1346 FILE_DIRECTORY | FILE_HIDDEN |
1347 FILE_SYSTEM | FILE_ARCHIVED);
1348 dcd->mask.antiattr = 0;
[444]1349 }
1350
[551]1351 *(dcd->mask.prompt) = 0;
[444]1352
[194]1353 cnri.flWindowAttr |= CV_FLOW;
1354 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
[551]1355 dcd->flWindowAttr = cnri.flWindowAttr;
[194]1356 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1357 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1358 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1359 SetCnrCols(hwnd, FALSE);
1360 AdjustCnrColsForPref(hwnd, NULL, dcd, FALSE);
[2]1361
[197]1362 /* fix splitbar for collector container */
1363 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1364 size = sizeof(LONG);
1365 PrfQueryProfileData(fmprof, appname, "CollectorCnrSplitBar",
1366 &cnri.xVertSplitbar, &size);
1367 if (cnri.xVertSplitbar <= 0)
[194]1368 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
[197]1369 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1370 MPFROMLONG(CMA_XVERTSPLITBAR));
1371
[942]1372 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID)dcd) == -1) {
[551]1373 Runtime_Error(pszSrcFile, __LINE__,
1374 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[194]1375 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1376 return 0;
1377 }
1378 else
[942]1379 DosSleep(32); // Let object window get started
[2]1380 }
[194]1381 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]1382 DIR_FILTER), &dcd->mask, FALSE);
[194]1383 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1384 DIR_SORT), CollectorsortFlags, FALSE);
1385 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]1386 DIR_VIEW), dcd->flWindowAttr);
[194]1387 }
[444]1388 else {
[194]1389 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
[2]1390 return 0;
[194]1391 }
1392 return 0;
[2]1393
[194]1394 case WM_MENUEND:
[444]1395 if (dcd) {
[551]1396 HWND hwndMenu = (HWND) mp2;
[2]1397
[194]1398 if (hwndMenu == CollectorCnrMenu || hwndMenu == CollectorFileMenu ||
[551]1399 hwndMenu == CollectorDirMenu) {
[194]1400 MarkAll(hwnd, TRUE, FALSE, TRUE);
[551]1401 if (dcd->cnremphasized) {
[194]1402 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1403 MPFROM2SHORT(FALSE, CRA_SOURCE));
[551]1404 dcd->cnremphasized = FALSE;
[194]1405 }
[2]1406 }
[194]1407 }
1408 break;
[2]1409
[194]1410 case UM_OPENWINDOWFORME:
[444]1411 if (dcd) {
[1009]1412 if (mp1 && !IsFile((CHAR *)mp1))
[551]1413 OpenDirCnr(HWND_DESKTOP, hwndMain, dcd->hwndFrame, FALSE, (PSZ) mp1);
[471]1414 else if (mp1 && IsFile(mp1) == 1)
[194]1415 StartArcCnr(HWND_DESKTOP,
[1009]1416 dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
[194]1417 }
1418 return 0;
[2]1419
[194]1420 case MM_PORTHOLEINIT:
[444]1421 if (dcd) {
1422 switch (SHORT1FROMMP(mp1)) {
[194]1423 case 0:
1424 case 1:
1425 {
1426 ULONG wmsg;
[2]1427
[194]1428 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
[551]1429 PortholeInit((HWND) WinSendMsg(dcd->hwndClient, wmsg, MPVOID,
[194]1430 MPVOID), mp1, mp2);
1431 }
1432 break;
[2]1433 }
[194]1434 }
1435 break;
[2]1436
[194]1437 case UM_INITMENU:
1438 case WM_INITMENU:
[444]1439 if (dcd) {
1440 switch (SHORT1FROMMP(mp1)) {
[194]1441 case IDM_VIEWSMENU:
[551]1442 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1443 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
[907]1444 (dcd->lastselection != NULL));
1445 CopyPresParams((HWND) mp2, hwnd);
[194]1446 break;
[2]1447
[194]1448 case IDM_DETAILSSETUP:
[551]1449 SetDetailsSwitches((HWND) mp2, dcd);
[194]1450 break;
[2]1451
[194]1452 case IDM_COMMANDSMENU:
[551]1453 SetupCommandMenu((HWND) mp2, hwnd);
[194]1454 break;
[2]1455
[194]1456 case IDM_SORTSUBMENU:
[551]1457 SetSortChecks((HWND) mp2, CollectorsortFlags);
[194]1458 break;
[2]1459 }
[551]1460 dcd->hwndLastMenu = (HWND) mp2;
[194]1461 }
1462 if (msg == WM_INITMENU)
1463 break;
1464 return 0;
[2]1465
[194]1466 case UM_COLLECTFROMFILE:
[444]1467 if (mp1) {
1468 if (!dcd) {
[1029]1469 xfree(mp1, pszSrcFile, __LINE__);
1470# ifdef FORTIFY
1471 Fortify_LeaveScope();
1472# endif
[444]1473 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1474 }
1475 else {
[551]1476 if (!PostMsg(dcd->hwndObject, UM_COLLECTFROMFILE, mp1, mp2)) {
[444]1477 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
[1009]1478 xfree(mp1, pszSrcFile, __LINE__);
[1029]1479# ifdef FORTIFY
1480 Fortify_LeaveScope();
1481# endif
[194]1482 }
[2]1483 }
[194]1484 }
1485 return 0;
[2]1486
[194]1487 case UM_COMMAND:
[444]1488 if (mp1) {
1489 if (dcd) {
[551]1490 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
[444]1491 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
[194]1492 FreeListInfo((LISTINFO *) mp1);
1493 }
1494 else
1495 return (MRESULT) TRUE;
[2]1496 }
[194]1497 else
1498 FreeListInfo((LISTINFO *) mp1);
1499 }
1500 return 0;
[2]1501
[194]1502 case UM_NOTIFY:
1503 if (mp2)
[1009]1504 AddNote((CHAR *)mp2);
[194]1505 return 0;
[2]1506
[194]1507 case WM_COMMAND:
1508 DosError(FERR_DISABLEHARDERR);
[444]1509 if (dcd) {
1510 switch (SHORT1FROMMP(mp1)) {
[194]1511 case IDM_SETTARGET:
1512 SetTargetDir(hwnd, FALSE);
1513 break;
[2]1514
[194]1515 case IDM_CONTEXTMENU:
1516 {
1517 PCNRITEM pci;
[2]1518
[194]1519 pci = (PCNRITEM) CurrentRecord(hwnd);
1520 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(COLLECTOR_CNR,
[551]1521 CN_CONTEXTMENU),
1522 MPFROMP(pci));
[194]1523 }
1524 break;
[2]1525
[194]1526 case IDM_SHOWALLFILES:
1527 {
1528 PCNRITEM pci;
[2]1529
[471]1530 pci = WinSendMsg(hwnd,
1531 CM_QUERYRECORDEMPHASIS,
[551]1532 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
[444]1533 if (pci && (INT) pci != -1) {
[194]1534 static CHAR dirname[CCHMAXPATH];
[2]1535
[730]1536 strcpy(dirname, pci->pszFileName);
[194]1537 MakeValidDir(dirname);
1538 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1539 }
1540 }
1541 break;
[2]1542
[194]1543 case IDM_BEGINEDIT:
1544 OpenEdit(hwnd);
1545 break;
[2]1546
[194]1547 case IDM_ENDEDIT:
1548 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1549 break;
[2]1550
[194]1551 case IDM_SHOWSELECT:
[551]1552 QuickPopup(hwnd, dcd,
[872]1553 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
[194]1554 IDM_SELECTSUBMENU);
1555 break;
[2]1556
[194]1557 case IDM_SHOWSORT:
[551]1558 QuickPopup(hwnd, dcd,
[872]1559 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
[194]1560 IDM_SORTSUBMENU);
1561 break;
[2]1562
[194]1563 case IDM_VIEWORARC:
1564 {
1565 SWP swp;
1566 PCNRITEM pci;
[2]1567
[194]1568 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1569 MPFROMLONG(CMA_FIRST),
1570 MPFROMSHORT(CRA_CURSORED));
[444]1571 if (pci && (INT) pci != -1) {
[551]1572 WinQueryWindowPos(dcd->hwndFrame, &swp);
1573 DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp,
[730]1574 pci->pszFileName);
[194]1575 }
1576 }
1577 break;
[2]1578
[194]1579 case IDM_SEEALL:
[551]1580 StartSeeAll(HWND_DESKTOP, FALSE, NULL);
[194]1581 break;
[2]1582
[194]1583 case IDM_COLLECTSELECT:
1584 {
1585 CHAR filename[CCHMAXPATH], *p, *pp;
[2]1586
[194]1587 strcpy(filename, "*.LST");
1588 size = CCHMAXPATH;
1589 PrfQueryProfileData(fmprof, appname, "SaveToListName",
1590 filename, &size);
1591 pp = strrchr(filename, '\\');
1592 if (!pp)
1593 pp = filename;
1594 p = strrchr(pp, '.');
[444]1595 if (p && *(p + 1) && p > pp + 1) {
[194]1596 if (pp > filename)
1597 pp++;
1598 *pp = '*';
1599 pp++;
1600 if (p > pp)
1601 memmove(pp, p, strlen(p) + 1);
1602 }
[444]1603 if (insert_filename(hwnd, filename, FALSE, FALSE)) {
[551]1604 p = xstrdup(filename, pszSrcFile, __LINE__);
[444]1605 if (p) {
[194]1606 if (!PostMsg(hwnd, UM_COLLECTFROMFILE, MPFROMP(p), MPVOID))
[1029]1607 xfree(p, pszSrcFile, __LINE__);
1608# ifdef FORTIFY
1609 Fortify_LeaveScope();
1610# endif
[194]1611 }
1612 }
1613 }
1614 break;
[2]1615
[953]1616 case IDM_COLLECTORVIEWSETTINGS:
[551]1617 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
[953]1618 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_COLLECTORVIEWSETTINGS), mp2);
[917]1619 else {
1620 WinDlgBox(HWND_DESKTOP,
1621 hwnd,
1622 CfgDlgProc,
1623 FM3ModHandle,
1624 CFG_FRAME,
[953]1625 MPFROMLONG(IDM_COLLECTORVIEWSETTINGS));
[917]1626 }
[194]1627 break;
[2]1628
[194]1629 case IDM_RESELECT:
[551]1630 SelectList(hwnd, FALSE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
[194]1631 break;
[2]1632
[194]1633 case IDM_HELP:
1634 if (hwndHelp)
1635 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
1636 MPFROM2SHORT(HELP_COLLECT, 0),
1637 MPFROMSHORT(HM_RESOURCEID));
1638 break;
[2]1639
[194]1640 case IDM_SORTNONE:
1641 case IDM_SORTSMARTNAME:
1642 case IDM_SORTNAME:
1643 case IDM_SORTFILENAME:
1644 case IDM_SORTSIZE:
1645 case IDM_SORTEASIZE:
1646 case IDM_SORTFIRST:
1647 case IDM_SORTLAST:
1648 case IDM_SORTLWDATE:
1649 case IDM_SORTLADATE:
1650 case IDM_SORTCRDATE:
1651 case IDM_SORTSUBJECT:
[197]1652 savedSortFlags = CollectorsortFlags;
[194]1653 CollectorsortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1654 case IDM_SORTDIRSFIRST:
1655 case IDM_SORTDIRSLAST:
1656 case IDM_SORTREVERSE:
[444]1657 switch (SHORT1FROMMP(mp1)) {
[194]1658 case IDM_SORTSUBJECT:
1659 CollectorsortFlags |= SORT_SUBJECT;
1660 break;
1661 case IDM_SORTNONE:
1662 CollectorsortFlags |= SORT_NOSORT;
1663 break;
1664 case IDM_SORTSMARTNAME:
[197]1665 if (~savedSortFlags & SORT_FILENAME)
[194]1666 CollectorsortFlags |= SORT_FILENAME;
1667 break;
1668 case IDM_SORTFILENAME:
1669 CollectorsortFlags |= SORT_FILENAME;
1670 break;
1671 case IDM_SORTSIZE:
1672 CollectorsortFlags |= SORT_SIZE;
1673 break;
1674 case IDM_SORTEASIZE:
1675 CollectorsortFlags |= SORT_EASIZE;
1676 break;
1677 case IDM_SORTFIRST:
1678 CollectorsortFlags |= SORT_FIRSTEXTENSION;
1679 break;
1680 case IDM_SORTLAST:
1681 CollectorsortFlags |= SORT_LASTEXTENSION;
1682 break;
1683 case IDM_SORTLWDATE:
1684 CollectorsortFlags |= SORT_LWDATE;
1685 break;
1686 case IDM_SORTLADATE:
1687 CollectorsortFlags |= SORT_LADATE;
1688 break;
1689 case IDM_SORTCRDATE:
1690 CollectorsortFlags |= SORT_CRDATE;
1691 break;
1692 case IDM_SORTDIRSFIRST:
1693 if (CollectorsortFlags & SORT_DIRSFIRST)
1694 CollectorsortFlags &= (~SORT_DIRSFIRST);
[444]1695 else {
[194]1696 CollectorsortFlags |= SORT_DIRSFIRST;
1697 CollectorsortFlags &= (~SORT_DIRSLAST);
1698 }
1699 break;
1700 case IDM_SORTDIRSLAST:
1701 if (CollectorsortFlags & SORT_DIRSLAST)
1702 CollectorsortFlags &= (~SORT_DIRSLAST);
[444]1703 else {
[194]1704 CollectorsortFlags |= SORT_DIRSLAST;
1705 CollectorsortFlags &= (~SORT_DIRSFIRST);
1706 }
1707 break;
1708 case IDM_SORTREVERSE:
1709 if (CollectorsortFlags & SORT_REVERSE)
1710 CollectorsortFlags &= (~SORT_REVERSE);
1711 else
1712 CollectorsortFlags |= SORT_REVERSE;
1713 break;
1714 }
1715 PrfWriteProfileData(fmprof, appname, "CollectorSort",
1716 &CollectorsortFlags, sizeof(INT));
1717 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1718 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1719 DIR_SORT), CollectorsortFlags, FALSE);
1720 break;
[2]1721
[194]1722 case IDM_COLLECTFROMCLIP:
1723 {
1724 LISTINFO *li;
[1018]1725# ifdef FORTIFY
1726 Fortify_EnterScope();
1727# endif
[551]1728 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
[444]1729 if (li) {
[551]1730 li->list = ListFromClipboard(hwnd);
1731 if (!li->list || !li->list[0])
[194]1732 FreeListInfo(li);
[444]1733 else {
[551]1734 li->type = IDM_COLLECT;
1735 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
[194]1736 FreeListInfo(li);
1737 }
1738 }
1739 }
1740 break;
[2]1741
[194]1742 case IDM_REMOVE:
[551]1743 if (fAutoView && hwndMain)
1744 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1745 dcd->suspendview = 1;
1746 RemoveAll(hwnd, &dcd->ullTotalBytes, &dcd->totalfiles);
1747 dcd->suspendview = 0;
1748 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
[194]1749 break;
[2]1750
[194]1751 case IDM_CLEARCNR:
1752 {
1753 PCNRITEM pci;
[2]1754
[194]1755 pci = (PCNRITEM) WinSendMsg(hwnd,
1756 CM_QUERYRECORD,
1757 MPVOID,
[551]1758 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
[444]1759 if (pci && (INT) pci != -1) {
[751]1760 RemoveCnrItems(hwnd, NULL, 0, CMA_FREE | CMA_INVALIDATE);
[551]1761 dcd->ullTotalBytes = dcd->selectedbytes = dcd->selectedfiles =
[750]1762 dcd->totalfiles = 0;
[551]1763 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
[194]1764 }
1765 }
1766 break;
[2]1767
[194]1768 case DID_CANCEL:
[551]1769 if (dcd->amextracted)
1770 dcd->stopflag = 1; // Request cancel
[194]1771 break;
[2]1772
[194]1773 case IDM_COLLECTOR:
[444]1774 if (mp2) {
[194]1775 LISTINFO *li;
[1018]1776# ifdef FORTIFY
1777 Fortify_EnterScope();
1778# endif
[551]1779 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
[444]1780 if (li) {
[551]1781 li->list = mp2;
1782 if (!li->list || !li->list[0])
[194]1783 FreeListInfo(li);
[444]1784 else {
[551]1785 li->type = IDM_COLLECT;
1786 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
[194]1787 FreeListInfo(li);
1788 }
1789 }
1790 else
1791 FreeList(mp2);
1792 }
1793 break;
[2]1794
[194]1795 case IDM_UNDELETE:
1796 {
1797 PCNRITEM pci;
1798 CHAR path[CCHMAXPATH];
[2]1799
[194]1800 pci = (PCNRITEM) CurrentRecord(hwnd);
[444]1801 if (pci) {
[730]1802 strcpy(path, pci->pszFileName);
[194]1803 MakeValidDir(path);
1804 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
1805 UNDEL_FRAME, MPFROMP(path));
1806 }
1807 }
1808 break;
[2]1809
[194]1810 case IDM_GREP:
[724]1811 if (dcd->amextracted) {
1812 saymsg(MB_OK | MB_ICONASTERISK,
1813 hwnd,
1814 GetPString(IDS_WARNINGTEXT),
1815 "Collector busy - please try again later");
1816 }
[444]1817 else {
[194]1818 if (WinDlgBox(HWND_DESKTOP, hwnd, GrepDlgProc,
[551]1819 FM3ModHandle, GREP_FRAME, (PVOID) & hwnd)) {
1820 dcd->amextracted = TRUE; // Say busy scanning
1821 disable_menuitem(WinWindowFromID
1822 (WinQueryWindow(hwndMain, QW_PARENT), FID_MENU),
1823 IDM_GREP, TRUE);
[194]1824 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1825 }
1826 }
1827 break;
[2]1828
[194]1829 case IDM_RESORT:
1830 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1831 break;
[2]1832
[194]1833 case IDM_FILTER:
1834 {
1835 BOOL empty = FALSE;
1836 PCNRITEM pci;
1837 CHAR *p;
[2]1838
[551]1839 if (!*dcd->mask.szMask) {
[194]1840 empty = TRUE;
1841 pci = (PCNRITEM) CurrentRecord(hwnd);
[551]1842 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
[730]1843 p = strrchr(pci->pszFileName, '\\');
[444]1844 if (p) {
[194]1845 p++;
[551]1846 strcpy(dcd->mask.szMask, p);
[194]1847 }
1848 }
1849 }
[551]1850 *(dcd->mask.prompt) = 0;
[2]1851
[194]1852 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
[551]1853 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
[197]1854 size = sizeof(MASK);
1855 PrfWriteProfileData(fmprof, appname, "CollectorFilter",
[551]1856 &dcd->mask, size);
1857 dcd->suspendview = 1;
1858 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1859 dcd->suspendview = 0;
[444]1860 if (fAutoView && hwndMain) {
[194]1861 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1862 MPFROMLONG(CMA_FIRST),
1863 MPFROMSHORT(CRA_CURSORED));
1864 if (pci && (INT) pci != -1 &&
[730]1865 (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
[551]1866 DRIVE_SLOW)))
[730]1867 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName),
[194]1868 MPVOID);
1869 else
1870 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1871 }
1872 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1873 }
1874 else if (empty)
[551]1875 *dcd->mask.szMask = 0;
[194]1876 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]1877 DIR_FILTER), &dcd->mask, FALSE);
[194]1878 }
[958]1879 break;
[2]1880
[958]1881 case IDM_UNHIDEALL:
1882 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1883 break;
1884
[194]1885 case IDM_HIDEALL:
1886 if (fAutoView && hwndMain)
1887 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
[551]1888 dcd->suspendview = 1;
[194]1889 HideAll(hwnd);
[551]1890 dcd->suspendview = 0;
[194]1891 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1892 break;
[2]1893
[194]1894 case IDM_SELECTLIST:
1895 case IDM_SELECTALL:
1896 case IDM_DESELECTALL:
1897 case IDM_SELECTALLFILES:
1898 case IDM_DESELECTALLFILES:
1899 case IDM_SELECTALLDIRS:
1900 case IDM_DESELECTALLDIRS:
1901 case IDM_SELECTMASK:
1902 case IDM_DESELECTMASK:
1903 case IDM_INVERT:
1904 case IDM_SELECTCLIP:
1905 case IDM_DESELECTCLIP:
1906 {
1907 PCNRITEM pci;
[2]1908
[194]1909 pci = (PCNRITEM) CurrentRecord(hwnd);
1910 if ((INT) pci == -1)
1911 pci = NULL;
[444]1912 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
1913 if (pci) {
[551]1914 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
1915 pci->rc.flRecordAttr |= CRA_FILTERED;
[194]1916 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
1917 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
1918 break;
1919 }
1920 }
[551]1921 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
[194]1922 }
1923 break;
[2]1924
[194]1925 case IDM_RESCAN:
[551]1926 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
[194]1927 break;
[2]1928
[194]1929 case IDM_SHOWLNAMES:
1930 case IDM_SHOWSUBJECT:
1931 case IDM_SHOWEAS:
1932 case IDM_SHOWSIZE:
1933 case IDM_SHOWICON:
1934 case IDM_SHOWLWDATE:
1935 case IDM_SHOWLWTIME:
1936 case IDM_SHOWLADATE:
1937 case IDM_SHOWLATIME:
1938 case IDM_SHOWCRDATE:
1939 case IDM_SHOWCRTIME:
1940 case IDM_SHOWATTR:
[551]1941 AdjustDetailsSwitches(hwnd, dcd->hwndLastMenu,
[194]1942 SHORT1FROMMP(mp1), NULL,
1943 "Collector", dcd, FALSE);
1944 break;
[2]1945
[194]1946 case IDM_ICON:
1947 case IDM_TEXT:
1948 case IDM_DETAILS:
1949 case IDM_NAME:
1950 case IDM_MINIICONS:
1951 case IDM_DETAILSTITLES:
1952 {
1953 CNRINFO cnri;
[2]1954
[194]1955 memset(&cnri, 0, sizeof(CNRINFO));
1956 cnri.cb = sizeof(CNRINFO);
1957 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1958 MPFROMLONG(sizeof(CNRINFO)));
[444]1959 switch (SHORT1FROMMP(mp1)) {
[194]1960 case IDM_ICON:
1961 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1962 CV_DETAIL | CV_NAME));
1963 cnri.flWindowAttr |= CV_ICON;
1964 break;
1965 case IDM_NAME:
1966 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1967 CV_DETAIL | CV_NAME));
1968 cnri.flWindowAttr |= CV_NAME;
1969 break;
1970 case IDM_TEXT:
1971 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1972 CV_DETAIL | CV_NAME));
1973 cnri.flWindowAttr |= CV_TEXT;
1974 break;
1975 case IDM_DETAILS:
1976 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1977 CV_DETAIL | CV_NAME));
1978 cnri.flWindowAttr |= CV_DETAIL;
1979 break;
1980 case IDM_MINIICONS:
1981 if (cnri.flWindowAttr & CV_MINI)
1982 cnri.flWindowAttr &= (~CV_MINI);
1983 else
1984 cnri.flWindowAttr |= CV_MINI;
1985 break;
1986 case IDM_DETAILSTITLES:
1987 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
1988 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
1989 else
1990 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
1991 break;
1992 }
[551]1993 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
[194]1994 cnri.flWindowAttr |= CV_FLOW;
[551]1995 dcd->flWindowAttr = cnri.flWindowAttr;
[194]1996 PrfWriteProfileData(fmprof, appname, "CollectorflWindowAttr",
1997 &cnri.flWindowAttr, sizeof(ULONG));
1998 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1999 MPFROMLONG(CMA_FLWINDOWATTR));
2000 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2001 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2002 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]2003 DIR_VIEW), dcd->flWindowAttr);
[194]2004 }
2005 break;
[2]2006
[194]2007 case IDM_SAVETOLIST:
2008 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2009 SAV_FRAME, MPFROMP(&hwnd));
2010 break;
[2]2011
[194]2012 case IDM_SIZES:
2013 {
2014 PCNRITEM pci;
[2]2015
[194]2016 pci = (PCNRITEM) CurrentRecord(hwnd);
2017 if (pci && (INT) pci != -1)
2018 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DirSizeProc, FM3ModHandle,
[730]2019 DSZ_FRAME, pci->pszFileName);
[194]2020 }
2021 break;
[2]2022
[194]2023 case IDM_MKDIR:
2024 {
2025 PCNRITEM pci;
[2]2026
[194]2027 pci = (PCNRITEM) CurrentRecord(hwnd);
[551]2028 PMMkDir(dcd->hwndParent, (pci && (INT) pci != -1) ?
[730]2029 pci->pszFileName : NULL, FALSE);
[194]2030 }
2031 break;
[2]2032
[194]2033 case IDM_DOITYOURSELF:
2034 case IDM_UPDATE:
2035 case IDM_COLLECTFROMFILE:
2036 case IDM_OPENWINDOW:
2037 case IDM_OPENSETTINGS:
2038 case IDM_OPENDEFAULT:
2039 case IDM_OPENICON:
2040 case IDM_OPENDETAILS:
2041 case IDM_OPENTREE:
2042 case IDM_OBJECT:
2043 case IDM_SHADOW:
2044 case IDM_SHADOW2:
2045 case IDM_DELETE:
2046 case IDM_PERMDELETE:
2047 case IDM_PRINT:
2048 case IDM_ATTRS:
2049 case IDM_INFO:
2050 case IDM_COPY:
2051 case IDM_MOVE:
2052 case IDM_WPSCOPY:
2053 case IDM_WPSMOVE:
2054 case IDM_COPYPRESERVE:
2055 case IDM_MOVEPRESERVE:
2056 case IDM_WILDCOPY:
2057 case IDM_WILDMOVE:
2058 case IDM_RENAME:
2059 case IDM_COMPARE:
2060 case IDM_EAS:
2061 case IDM_SUBJECT:
2062 case IDM_VIEW:
2063 case IDM_VIEWTEXT:
2064 case IDM_VIEWBINARY:
2065 case IDM_VIEWARCHIVE:
2066 case IDM_EDIT:
2067 case IDM_EDITTEXT:
2068 case IDM_EDITBINARY:
2069 case IDM_SAVETOCLIP:
2070 case IDM_APPENDTOCLIP:
2071 case IDM_ARCHIVE:
2072 case IDM_ARCHIVEM:
2073 case IDM_EXTRACT:
2074 case IDM_MCIPLAY:
2075 case IDM_UUDECODE:
2076 case IDM_MERGE:
2077 {
2078 LISTINFO *li;
2079 ULONG action = UM_ACTION;
[1018]2080# ifdef FORTIFY
2081 Fortify_EnterScope();
2082# endif
[551]2083 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
[444]2084 if (li) {
[551]2085 li->type = SHORT1FROMMP(mp1);
2086 li->hwnd = hwnd;
2087 li->list = BuildList(hwnd);
2088 if (li->list) {
[444]2089 switch (SHORT1FROMMP(mp1)) {
[194]2090 case IDM_DOITYOURSELF:
2091 case IDM_APPENDTOCLIP:
2092 case IDM_SAVETOCLIP:
2093 case IDM_ARCHIVE:
2094 case IDM_ARCHIVEM:
2095 case IDM_DELETE:
2096 case IDM_PERMDELETE:
2097 case IDM_ATTRS:
2098 case IDM_PRINT:
2099 case IDM_SHADOW:
2100 case IDM_SHADOW2:
2101 case IDM_OBJECT:
2102 case IDM_VIEW:
2103 case IDM_VIEWTEXT:
2104 case IDM_VIEWBINARY:
2105 case IDM_EDIT:
2106 case IDM_EDITTEXT:
2107 case IDM_EDITBINARY:
2108 case IDM_MCIPLAY:
2109 case IDM_UPDATE:
2110 case IDM_INFO:
2111 case IDM_EAS:
2112 action = UM_MASSACTION;
2113 break;
2114 }
[551]2115 if (li->type == IDM_SHADOW || li->type == IDM_OBJECT ||
2116 li->type == IDM_SHADOW2)
2117 *li->targetpath = 0;
2118 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
[444]2119 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
[194]2120 FreeListInfo(li);
2121 }
2122 else if (fUnHilite)
[672]2123 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
[194]2124 }
[1018]2125 else
2126 xfree(li, pszSrcFile, __LINE__);
2127# ifdef FORTIFY
2128 Fortify_LeaveScope();
2129# endif
[194]2130 }
2131 }
2132 break;
[2]2133
[194]2134 default:
2135 if (!cmdloaded)
2136 load_commands();
2137 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
[551]2138 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
[194]2139 INT x;
[2]2140
[194]2141 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
[444]2142 if (x >= 0) {
[194]2143 x++;
2144 RunCommand(hwnd, x);
2145 if (fUnHilite)
[672]2146 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
[194]2147 }
2148 }
2149 break;
2150 }
2151 }
2152 return 0;
[2]2153
[194]2154 case UM_FIXCNRMLE:
2155 case UM_FIXEDITNAME:
2156 return CommonCnrProc(hwnd, msg, mp1, mp2);
[2]2157
[194]2158 case UM_FILESMENU:
2159 {
2160 PCNRITEM pci;
[551]2161 HWND menuHwnd = (HWND) 0;
[2]2162
[194]2163 pci = (PCNRITEM) CurrentRecord(hwnd);
[444]2164 if (pci && (INT) pci != -1) {
[551]2165 if (pci->attrFile & FILE_DIRECTORY)
[872]2166 menuHwnd = CheckMenu(hwnd, &CollectorDirMenu, COLLECTORDIR_POPUP);
[194]2167 else
[872]2168 menuHwnd = CheckMenu(hwnd, &CollectorFileMenu, COLLECTORFILE_POPUP);
[2]2169 }
[194]2170 return MRFROMLONG(menuHwnd);
2171 }
[2]2172
[194]2173 case WM_CONTROL:
2174 DosError(FERR_DISABLEHARDERR);
[444]2175 if (dcd) {
2176 switch (SHORT2FROMMP(mp1)) {
[194]2177 case CN_CONTEXTMENU:
2178 {
2179 PCNRITEM pci = (PCNRITEM) mp2;
[2]2180
[444]2181 if (pci) {
[194]2182 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
2183 MPFROM2SHORT(TRUE, CRA_CURSORED));
2184 MarkAll(hwnd, FALSE, FALSE, TRUE);
[551]2185 if (pci->attrFile & FILE_DIRECTORY)
[872]2186 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorDirMenu,
[551]2187 COLLECTORDIR_POPUP);
[194]2188 else
[872]2189 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorFileMenu,
[551]2190 COLLECTORFILE_POPUP);
[194]2191 }
[444]2192 else {
[872]2193 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorCnrMenu,
[551]2194 COLLECTORCNR_POPUP);
2195 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
[194]2196 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2197 MPFROM2SHORT(TRUE, CRA_SOURCE));
[551]2198 dcd->cnremphasized = TRUE;
[194]2199 }
2200 }
[551]2201 if (dcd->hwndLastMenu) {
2202 if (dcd->hwndLastMenu == CollectorCnrMenu) {
2203 SetViewMenu(dcd->hwndLastMenu, dcd->flWindowAttr);
[907]2204 SetDetailsSwitches(dcd->hwndLastMenu, dcd);
2205 CopyPresParams(dcd->hwndLastMenu, hwnd);
[551]2206 if (dcd->flWindowAttr & CV_MINI)
2207 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2208 disable_menuitem(dcd->hwndLastMenu, DID_CANCEL,
2209 !dcd->amextracted);
2210 disable_menuitem(dcd->hwndLastMenu, IDM_GREP, dcd->amextracted);
[194]2211 }
[551]2212 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2213 if (dcd->cnremphasized) {
[194]2214 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2215 MPFROM2SHORT(FALSE, CRA_SOURCE));
[551]2216 dcd->cnremphasized = TRUE;
[194]2217 }
2218 MarkAll(hwnd, TRUE, FALSE, TRUE);
2219 }
2220 }
2221 }
2222 break;
[2]2223
[194]2224 case CN_DROPHELP:
[444]2225 if (mp2) {
[194]2226 PDRAGINFO pDInfo;
2227 PCNRITEM pci;
2228 ULONG numitems;
2229 USHORT usOperation;
[2]2230
[551]2231 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2232 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
[444]2233 if (!DrgAccessDraginfo(pDInfo)) {
[352]2234 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
[618]2235 "DrgAccessDraginfo");
2236 return 0;
[194]2237 }
2238 numitems = DrgQueryDragitemCount(pDInfo);
[551]2239 usOperation = pDInfo->usOperation;
[618]2240 FreeDragInfoData(hwnd, pDInfo);
[194]2241 saymsg(MB_ENTER | MB_ICONASTERISK,
2242 hwnd,
2243 GetPString(IDS_DROPHELPHDRTEXT),
2244 GetPString(IDS_DROPHELPTEXT),
2245 numitems,
[750]2246 &"s"[numitems == 1],
[194]2247 (pci) ? NullStr : GetPString(IDS_NOTEXT),
2248 (pci) ? NullStr : " ",
[730]2249 (pci) ? pci->pszFileName : NullStr,
[194]2250 (pci) ? " " : NullStr,
2251 GetPString((usOperation == DO_COPY) ?
2252 IDS_COPYTEXT :
2253 (usOperation == DO_LINK) ?
2254 IDS_LINKTEXT : IDS_MOVETEXT));
2255 }
2256 return 0;
[2]2257
[194]2258 case CN_DRAGLEAVE:
[444]2259 if (mp2) {
[194]2260 PDRAGINFO pDInfo;
[2]2261
[618]2262 // fixme to know why needed
[551]2263 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
[618]2264 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
2265 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
[194]2266 }
2267 return 0;
[2]2268
[194]2269 case CN_DRAGAFTER:
2270 case CN_DRAGOVER:
[444]2271 if (mp2) {
[618]2272 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2273 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
[194]2274 PCNRITEM pci;
2275 USHORT uso;
[2]2276
[551]2277 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
[618]2278 // if(SHORT1FROMMP(mp1) == CN_DRAGAFTER)
2279 // pci = NULL;
[551]2280 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
[618]2281 if (!DrgAccessDraginfo(pDInfo)) {
2282 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2283 "DrgAccessDraginfo");
2284 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2285 }
[444]2286 if (pci) {
[551]2287 if (pci->rc.flRecordAttr & CRA_SOURCE) {
[194]2288 DrgFreeDraginfo(pDInfo);
2289 return (MRFROM2SHORT(DOR_NODROP, 0));
2290 }
[551]2291 uso = pDInfo->usOperation;
[194]2292 if (uso == DO_DEFAULT)
2293 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
[551]2294 if (!(pci->attrFile & FILE_DIRECTORY)) {
2295 if (uso != DO_LINK && uso != DO_MOVE && uso != DO_COPY) {
[194]2296 DrgFreeDraginfo(pDInfo);
2297 return MRFROM2SHORT(DOR_NODROP, 0);
2298 }
2299 if (uso != DO_LINK &&
[730]2300 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
[551]2301 DRIVE_NOTWRITEABLE)) {
[194]2302 ARC_TYPE *info = NULL;
[2]2303
[194]2304 if (!fQuickArcFind &&
[730]2305 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
[194]2306 DRIVE_SLOW))
[730]2307 info = find_type(pci->pszFileName, NULL);
[194]2308 else
[730]2309 info = quick_find_type(pci->pszFileName, NULL);
[551]2310 if (!info || ((uso == DO_MOVE && !info->move) ||
2311 (uso == DO_COPY && !info->create))) {
[194]2312 DrgFreeDraginfo(pDInfo);
2313 return MRFROM2SHORT(DOR_NODROP, 0);
2314 }
2315 }
2316 }
2317 }
[618]2318 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
2319 0); /* Index to DRAGITEM */
[194]2320 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
[618]2321 DRM_OS2FILE, /* mechanisms and data */
[551]2322 NULL)) {
[618]2323 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
[444]2324 if (pci) {
[730]2325 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
[194]2326 DRIVE_NOTWRITEABLE)
2327 return MRFROM2SHORT(DOR_DROP, DO_LINK);
[730]2328 if (toupper(*pci->pszFileName) < 'C')
[194]2329 return MRFROM2SHORT(DOR_DROP, DO_COPY);
[618]2330 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
[551]2331 ((fCopyDefault) ? DO_COPY : DO_MOVE));
[194]2332 }
2333 else
[618]2334 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
[194]2335 DO_COPY);
2336 }
[618]2337 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
[194]2338 }
[618]2339 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
[2]2340
[194]2341 case CN_INITDRAG:
[444]2342 if (mp2) {
[194]2343 BOOL wasemphasized = FALSE;
2344 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2345 PCNRITEM pci;
[2]2346
[444]2347 if (pcd) {
[551]2348 pci = (PCNRITEM) pcd->pRecord;
[444]2349 if (pci) {
[551]2350 if (pci->rc.flRecordAttr & CRA_SELECTED)
[194]2351 wasemphasized = TRUE;
[730]2352 if (IsRoot(pci->pszFileName))
[194]2353 break;
2354 if (hwndStatus2)
[551]2355 WinSetWindowText(hwndStatus2,
2356 GetPString(IDS_DRAGFILEOBJTEXT));
2357 if (DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE)) {
[672]2358 if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
2359 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
[194]2360 }
2361 if (hwndStatus2)
2362 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2363 }
2364 }
2365 }
2366 return 0;
[2]2367
[194]2368 case CN_DROP:
[444]2369 if (mp2) {
[194]2370 LISTINFO *li;
2371 ULONG action = UM_ACTION;
[2]2372
[724]2373 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
2374 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
[444]2375 if (li) {
[551]2376 if (!*li->targetpath) {
2377 li->type = IDM_COLLECT;
[194]2378 action = UM_COLLECT;
2379 }
[444]2380 else {
[551]2381 if (li->list && li->list[0] && IsRoot(li->list[0]))
2382 li->type = DO_LINK;
2383 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
[194]2384 CHECKLIST cl;
[2]2385
[194]2386 memset(&cl, 0, sizeof(cl));
2387 cl.size = sizeof(cl);
[551]2388 cl.flags = li->type;
2389 cl.list = li->list;
2390 cl.cmd = li->type;
2391 cl.prompt = li->targetpath;
2392 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2393 DropListProc, FM3ModHandle,
[618]2394 DND_FRAME, MPFROMP(&cl));
2395 if (li->type == DID_ERROR)
2396 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2397 "Drag & Drop Dialog");
2398 if (!li->type) {
[194]2399 FreeListInfo(li);
2400 return 0;
2401 }
[551]2402 li->list = cl.list;
[618]2403 if (!li->list || !li->list[0]) {
[194]2404 FreeListInfo(li);
2405 return 0;
2406 }
2407 }
[551]2408 switch (li->type) {
[194]2409 case DND_LAUNCH:
[551]2410 strcat(li->targetpath, " %a");
2411 ExecOnList(dcd->hwndParent, li->targetpath,
[907]2412 PROMPT | WINDOWED, NULL, li->list, NULL,
2413 pszSrcFile, __LINE__);
[551]2414 FreeList(li->list);
2415 li->list = NULL;
[194]2416 break;
2417 case DO_LINK:
[444]2418 if (fLinkSetsIcon) {
[551]2419 li->type = IDM_SETICON;
[194]2420 action = UM_MASSACTION;
2421 }
2422 else
[551]2423 li->type = IDM_COMPARE;
[194]2424 break;
2425 case DND_EXTRACT:
[551]2426 if (*li->targetpath && !IsFile(li->targetpath))
2427 li->type = IDM_EXTRACT;
[194]2428 break;
2429 case DND_MOVE:
[551]2430 li->type = IDM_MOVE;
2431 if (*li->targetpath && IsFile(li->targetpath) == 1) {
[194]2432 action = UM_MASSACTION;
[551]2433 li->type = IDM_ARCHIVEM;
[194]2434 }
2435 break;
2436 case DND_WILDMOVE:
[551]2437 li->type = IDM_WILDMOVE;
2438 if (*li->targetpath && IsFile(li->targetpath) == 1) {
[194]2439 action = UM_MASSACTION;
[551]2440 li->type = IDM_ARCHIVEM;
[194]2441 }
2442 break;
2443 case DND_OBJECT:
[551]2444 li->type = IDM_OBJECT;
[194]2445 action = UM_MASSACTION;
2446 break;
2447 case DND_SHADOW:
[551]2448 li->type = IDM_SHADOW;
[194]2449 action = UM_MASSACTION;
2450 break;
2451 case DND_COMPARE:
[551]2452 li->type = IDM_COMPARE;
[194]2453 break;
2454 case DND_SETICON:
2455 action = UM_MASSACTION;
[551]2456 li->type = IDM_SETICON;
[194]2457 break;
2458 case DND_WILDCOPY:
[551]2459 li->type = IDM_WILDCOPY;
2460 if (*li->targetpath && IsFile(li->targetpath) == 1) {
[194]2461 action = UM_MASSACTION;
[551]2462 li->type = IDM_ARCHIVE;
[194]2463 }
2464 break;
2465 case DND_COPY:
[551]2466 li->type = IDM_COPY;
2467 if (*li->targetpath && IsFile(li->targetpath) == 1) {
[194]2468 action = UM_MASSACTION;
[551]2469 li->type = IDM_ARCHIVE;
[194]2470 }
2471 break;
2472 default:
[551]2473 if (*li->arcname && li->info) {
[194]2474 action = UM_MASSACTION;
[551]2475 li->type =
2476 (li->type ==
2477 DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
[194]2478 }
[551]2479 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
[194]2480 action = UM_MASSACTION;
[551]2481 li->type =
2482 (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
[194]2483 }
2484 else
[551]2485 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
[194]2486 break;
2487 }
2488 }
[551]2489 if (!li->list || !li->list[0])
[194]2490 FreeListInfo(li);
[551]2491 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
[194]2492 FreeListInfo(li);
[444]2493 else {
[194]2494 USHORT usop = 0;
[2]2495
[551]2496 switch (li->type) {
[194]2497 case IDM_COPY:
2498 case IDM_WILDCOPY:
2499 usop = DO_COPY;
2500 break;
2501 case IDM_MOVE:
2502 case IDM_WILDMOVE:
2503 case IDM_ARCHIVEM:
2504 usop = DO_MOVE;
2505 break;
2506 }
2507 if (usop)
2508 return MRFROM2SHORT(DOR_DROP, usop);
2509 }
2510 }
2511 }
2512 return 0;
[2]2513
[194]2514 case CN_BEGINEDIT:
2515 case CN_REALLOCPSZ:
2516 case CN_ENDEDIT:
2517 {
2518 MRESULT mre;
[2]2519
[194]2520 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
2521 if (mre != (MRESULT) - 1)
2522 return mre;
2523 }
2524 break;
[2]2525
[194]2526 case CN_EMPHASIS:
[444]2527 if (mp2) {
[194]2528 PNOTIFYRECORDEMPHASIS pre = mp2;
2529 PCNRITEM pci;
2530 CHAR s[CCHMAXPATH + 91], tb[81], tf[81], *p;
[2]2531
[551]2532 pci = (PCNRITEM) ((pre) ? pre->pRecord : NULL);
[444]2533 if (!pci) {
[194]2534 if (hwndStatus2)
2535 WinSetWindowText(hwndStatus2, NullStr);
[444]2536 if (fMoreButtons) {
[194]2537 WinSetWindowText(hwndName, NullStr);
2538 WinSetWindowText(hwndDate, NullStr);
2539 WinSetWindowText(hwndAttr, NullStr);
2540 }
2541 if (hwndMain)
2542 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2543 break;
2544 }
[551]2545 if (pre->fEmphasisMask & CRA_SELECTED) {
2546 if (pci->rc.flRecordAttr & CRA_SELECTED) {
2547 dcd->selectedbytes += (pci->cbFile + pci->easize);
2548 dcd->selectedfiles++;
[194]2549 }
[551]2550 else if (dcd->selectedfiles) {
2551 dcd->selectedbytes -= (pci->cbFile + pci->easize);
2552 dcd->selectedfiles--;
[194]2553 }
[551]2554 if (!dcd->suspendview) {
2555 commafmt(tf, sizeof(tf), dcd->selectedfiles);
2556 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
[194]2557 sprintf(s, "%s / %s", tf, tb);
[551]2558 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
[194]2559 }
2560 }
[551]2561 if (!dcd->suspendview &&
2562 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
2563 if (pre->fEmphasisMask & CRA_CURSORED) {
2564 if (pci->rc.flRecordAttr & CRA_CURSORED) {
[444]2565 if (fSplitStatus && hwndStatus2) {
[551]2566 if (pci->attrFile & FILE_DIRECTORY)
2567 p = pci->pszFileName;
[444]2568 else {
[730]2569 p = strrchr(pci->pszFileName, '\\');
[444]2570 if (p) {
[194]2571 if (*(p + 1))
2572 p++;
2573 else
[551]2574 p = pci->pszFileName;
[194]2575 }
2576 else
[551]2577 p = pci->pszFileName;
[194]2578 }
[551]2579 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
[194]2580 if (!fMoreButtons)
2581 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
[551]2582 tb, pci->date.year,
2583 pci->date.month, pci->date.day, pci->time.hours,
2584 pci->time.minutes, pci->time.seconds,
2585 pci->pszDispAttr, p);
[444]2586 else {
[551]2587 if (pci->cbFile + pci->easize > 1024)
2588 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize,
2589 ' ');
[194]2590 else
2591 *tf = 0;
2592 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
2593 tb,
[551]2594 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
[194]2595 }
2596 WinSetWindowText(hwndStatus2, s);
2597 }
[444]2598 if (fMoreButtons) {
[551]2599 WinSetWindowText(hwndName, pci->pszFileName);
[194]2600 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
[551]2601 pci->date.year, pci->date.month,
2602 pci->date.day, pci->time.hours, pci->time.minutes,
2603 pci->time.seconds);
[194]2604 WinSetWindowText(hwndDate, s);
[551]2605 WinSetWindowText(hwndAttr, pci->pszDispAttr);
[194]2606 }
2607 }
2608 }
2609 }
[551]2610 if (!dcd->suspendview && hwndMain &&
2611 (pre->fEmphasisMask & CRA_CURSORED) &&
2612 (pci->rc.flRecordAttr & CRA_CURSORED) &&
2613 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame)
[194]2614 WinSendMsg(hwndMain, UM_LOADFILE,
[551]2615 MPFROMP(((fComments
2616 || (pci->attrFile & FILE_DIRECTORY) ==
[730]2617 0) ? pci->pszFileName : NULL)), MPVOID);
[194]2618 }
2619 break;
[2]2620
[194]2621 case CN_ENTER:
[444]2622 if (mp2) {
[551]2623 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
[847]2624 FILEFINDBUF3 ffb;
[194]2625 HDIR hDir = HDIR_CREATE;
[750]2626 ULONG nm = 1;
[194]2627 APIRET status = 0;
[2]2628
[194]2629 SetShiftState();
[444]2630 if (pci) {
[551]2631 if (pci->rc.flRecordAttr & CRA_INUSE)
[194]2632 break;
2633 DosError(FERR_DISABLEHARDERR);
[847]2634 status = DosFindFirst(pci->pszFileName, &hDir,
[907]2635 FILE_NORMAL | FILE_DIRECTORY |
[838]2636 FILE_ARCHIVED | FILE_READONLY |
2637 FILE_HIDDEN | FILE_SYSTEM,
[847]2638 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
[194]2639 priority_bumped();
[444]2640 if (!status) {
[194]2641 DosFindClose(hDir);
[444]2642 if (ffb.attrFile & FILE_DIRECTORY) {
[551]2643 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
[194]2644 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0),
2645 MPVOID);
2646 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
2647 (KC_CTRL | KC_SHIFT))
[730]2648 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
[194]2649 else if (shiftstate & KC_CTRL)
[730]2650 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
[194]2651 else
[280]2652 OpenDirCnr(HWND_DESKTOP,
[194]2653 hwndMain,
[730]2654 dcd->hwndFrame, FALSE, pci->pszFileName);
[194]2655 }
[444]2656 else {
[194]2657 SWP swp;
[2]2658
[194]2659 WinSendMsg(hwnd,
2660 CM_SETRECORDEMPHASIS,
[551]2661 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
2662 WinQueryWindowPos(dcd->hwndFrame, &swp);
[194]2663 DefaultViewKeys(hwnd,
[551]2664 dcd->hwndFrame,
[730]2665 dcd->hwndParent, &swp, pci->pszFileName);
[194]2666 WinSendMsg(hwnd,
2667 CM_SETRECORDEMPHASIS,
2668 MPFROMP(pci),
2669 MPFROM2SHORT(FALSE, CRA_INUSE |
2670 ((fUnHilite) ? CRA_SELECTED : 0)));
2671 }
2672 }
2673 else
[751]2674 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
[194]2675 }
2676 }
2677 break;
[2]2678 }
[194]2679 }
2680 return 0;
[2]2681
[194]2682 case UM_LOADFILE:
[444]2683 if (dcd && mp2) {
[194]2684 HWND ret;
[2]2685
[551]2686 ret = StartMLEEditor(dcd->hwndParent,
[1009]2687 (INT) mp1, (CHAR *)mp2, dcd->hwndFrame);
2688 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
[1029]2689# ifdef FORTIFY
2690 Fortify_LeaveScope();
2691# endif
[194]2692 return MRFROMLONG(ret);
2693 }
2694 return 0;
[2]2695
[194]2696 case UM_CLOSE:
2697 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
2698 QW_PARENT));
2699 return 0;
[2]2700
[194]2701 case UM_FOLDUP:
[551]2702 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
[194]2703 DosExit(EXIT_PROCESS, 1);
2704 return 0;
[2]2705
[194]2706 case WM_CLOSE:
[444]2707 if (dcd) {
[551]2708 dcd->namecanchange = TRUE;
2709 dcd->stopflag = 1;
2710 if (dcd->amextracted)
2711 return 0; // Can not close yet
[194]2712 }
2713 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
[444]2714 if (dcd) {
[551]2715 if (!dcd->dontclose && ParentIsDesktop(hwnd, dcd->hwndParent))
[194]2716 PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
[551]2717 if (dcd->hwndObject) {
[942]2718 DosSleep(32); // Allow UM_FOLDUP to process
[551]2719 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
2720 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
[2]2721 }
[194]2722 }
2723 else
2724 WinSendMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
2725 return 0;
[2]2726
[194]2727 case WM_DESTROY:
2728 if (CollectorDirMenu)
2729 WinDestroyWindow(CollectorDirMenu);
2730 if (CollectorFileMenu)
2731 WinDestroyWindow(CollectorFileMenu);
2732 if (CollectorCnrMenu)
2733 WinDestroyWindow(CollectorCnrMenu);
[551]2734 CollectorCnrMenu = CollectorFileMenu = CollectorDirMenu = (HWND) 0;
2735 Collector = (HWND) 0;
[194]2736 EmptyCnr(hwnd);
2737 break;
[2]2738 }
[705]2739 if (dcd && dcd->oldproc){
2740 return dcd->oldproc(hwnd, msg, mp1, mp2);
2741 }
2742 else
2743 return PFNWPCnr(hwnd, msg, mp1, mp2);
[2]2744}
2745
[942]2746MRESULT EXPENTRY CollectorMenuProc(HWND hwnd, ULONG msg, MPARAM mp1,
2747 MPARAM mp2)
2748{
2749 PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
2750 static short sLastMenuitem;
2751
2752 switch (msg) {
2753 case WM_MOUSEMOVE: {
2754 if (fOtherHelp) {
[948]2755 RECTL rectl;
2756 SHORT i, sCurrentMenuitem;
2757 SHORT MenuItems = 5;
2758 SHORT asMenuIDs[5] = {IDM_GREP,
2759 IDM_SEEALL,
2760 IDM_CLEARCNR,
2761 IDM_REMOVE,
2762 0};
2763 char *szHelpString = NULL;
[942]2764
2765
[948]2766 for (i=0; i<MenuItems; i++) {
2767 sCurrentMenuitem = asMenuIDs[i];
2768 oldMenuProc(hwnd,MM_QUERYITEMRECT,
2769 MPFROM2SHORT(asMenuIDs[i], FALSE),
2770 &rectl);
[942]2771
[948]2772 if (MOUSEMSG(&msg)->x > rectl.xLeft &&
2773 MOUSEMSG(&msg)->x < rectl.xRight &&
2774 MOUSEMSG(&msg)->y > rectl.yBottom &&
2775 MOUSEMSG(&msg)->y < rectl.yTop)
2776 break;
2777 } // for
[942]2778
2779
[948]2780 switch (sCurrentMenuitem) {
2781 case 0:
2782 break;
2783 case IDM_GREP:
2784 szHelpString = GetPString(IDS_COLMENUSEEKSCANHELP);
2785 break;
2786 case IDM_SEEALL:
2787 szHelpString = GetPString(IDS_COLMENUSEEALLHELP);
2788 break;
2789 case IDM_CLEARCNR:
2790 szHelpString = GetPString(IDS_COLMENUCLEARCNRHELP);
2791 break;
2792 case IDM_REMOVE:
2793 szHelpString = GetPString(IDS_COLMENUREMOVECNRHELP);
2794 break;
2795 default:
2796 break;
2797 }
[942]2798
[948]2799 if (sLastMenuitem != sCurrentMenuitem && szHelpString) {
2800 sLastMenuitem = sCurrentMenuitem;
2801 MakeBubble(hwnd, TRUE, szHelpString);
2802 }
2803 else if (hwndBubble && !sCurrentMenuitem){
2804 sLastMenuitem = sCurrentMenuitem;
2805 WinDestroyWindow(hwndBubble);
2806 }
[942]2807 }
2808 }
2809 }
2810 return oldMenuProc(hwnd, msg, mp1, mp2);
2811}
2812
[194]2813HWND StartCollector(HWND hwndParent, INT flags)
[155]2814{
[551]2815 HWND hwndFrame = (HWND) 0;
[197]2816 HWND hwndClient;
[194]2817 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]2818 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
[194]2819 USHORT id;
2820 DIRCNRDATA *dcd;
[2]2821
[197]2822 static USHORT idinc = 0;
2823
[194]2824 if (ParentIsDesktop(hwndParent, hwndParent))
[2]2825 FrameFlags |= (FCF_TASKLIST | FCF_SHELLPOSITION | FCF_MENU);
[444]2826 if (Collector) {
[2]2827 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
[194]2828 QW_PARENT),
2829 QW_PARENT),
[551]2830 HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE);
2831 return WinQueryWindow(WinQueryWindow(Collector, QW_PARENT), QW_PARENT);
[2]2832 }
2833 hwndFrame = WinCreateStdWindow(hwndParent,
[194]2834 WS_VISIBLE,
2835 &FrameFlags,
[593]2836 WC_COLLECTOR,
[194]2837 NULL,
2838 WS_VISIBLE | fwsAnimate,
[551]2839 FM3ModHandle, COLLECTOR_FRAME, &hwndClient);
[444]2840 if (hwndFrame && hwndClient) {
[2]2841 id = COLLECTOR_FRAME + idinc++;
[194]2842 WinSetWindowUShort(hwndFrame, QWS_ID, id);
[1017]2843# ifdef FORTIFY
2844 Fortify_EnterScope();
2845# endif
[551]2846 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
[377]2847 if (!dcd) {
2848 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[551]2849 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
2850 hwndFrame = (HWND) 0;
[377]2851 }
2852 else {
[551]2853 dcd->size = sizeof(DIRCNRDATA);
2854 dcd->id = id;
2855 dcd->type = COLLECTOR_FRAME;
2856 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
2857 dcd->hwndFrame = hwndFrame;
2858 dcd->hwndClient = hwndClient;
[194]2859 if (flags & 4)
[551]2860 dcd->dontclose = TRUE;
[2]2861 {
[194]2862 PFNWP oldproc;
[2]2863
[551]2864 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) CollectorFrameWndProc);
2865 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
[2]2866 }
[551]2867 dcd->hwndCnr = WinCreateWindow(hwndClient,
2868 WC_CONTAINER,
2869 NULL,
2870 CCS_AUTOPOSITION | CCS_MINIICONS |
2871 CCS_MINIRECORDCORE | ulCnrType |
2872 WS_VISIBLE,
2873 0,
2874 0,
2875 0,
2876 0,
2877 hwndClient,
2878 HWND_TOP,
2879 (ULONG) COLLECTOR_CNR, NULL, NULL);
2880 if (!dcd->hwndCnr) {
2881 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
2882 IDS_WINCREATEWINDOW);
2883 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
[1017]2884 xfree(dcd, pszSrcFile, __LINE__);
2885# ifdef FORTIFY
2886 Fortify_LeaveScope();
2887# endif
[551]2888 hwndFrame = (HWND) 0;
[377]2889 }
2890 else {
[551]2891 Collector = dcd->hwndCnr;
2892 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
2893 WinSetWindowText(hwndFrame, GetPString(IDS_COLLECTORTITLETEXT));
[948]2894 if (FrameFlags & FCF_MENU) {
2895 PFNWP oldmenuproc;
2896 HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
[942]2897
2898 oldmenuproc = WinSubclassWindow(hwndMenu, (PFNWP) CollectorMenuProc);
2899 WinSetWindowPtr(hwndMenu, QWL_USER, (PVOID) oldmenuproc);
[444]2900 if (!fToolbar) {
[948]2901 if (hwndMenu) {
[2]2902
[194]2903 WinSendMsg(hwndMenu,
2904 MM_DELETEITEM,
[551]2905 MPFROM2SHORT(IDM_SEEALL, FALSE), MPVOID);
[194]2906 WinSendMsg(hwndMenu,
2907 MM_DELETEITEM,
[551]2908 MPFROM2SHORT(IDM_GREP, FALSE), MPVOID);
[194]2909 WinSendMsg(hwndMenu,
2910 MM_DELETEITEM,
[551]2911 MPFROM2SHORT(IDM_CLEARCNR, FALSE), MPVOID);
[194]2912 WinSendMsg(hwndMenu,
2913 MM_DELETEITEM,
[551]2914 MPFROM2SHORT(IDM_REMOVE, FALSE), MPVOID);
[194]2915 }
2916 }
2917 }
[551]2918 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
2919 (PFNWP) CollectorCnrWndProc);
[194]2920 {
[942]2921 USHORT ids[] = { DIR_TOTALS,
2922 DIR_SELECTED,
2923 DIR_VIEW,
2924 DIR_SORT,
2925 DIR_FILTER,
2926 0
[551]2927 };
[2]2928
[551]2929 CommonCreateTextChildren(dcd->hwndClient,
[593]2930 WC_COLSTATUS, ids);
[194]2931 }
2932 if (FrameFlags & FCF_SHELLPOSITION)
[551]2933 PostMsg(hwndClient, UM_SIZE, MPVOID, MPVOID);
2934 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
2935 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
[2]2936 }
2937 }
2938 }
2939 return hwndFrame;
2940}
[793]2941
2942#pragma alloc_text(COLLECTOR,CollectorCnrWndProc,CollectorObjWndProc)
2943#pragma alloc_text(COLLECTOR,CollectorClientWndProc,CollectorTextProc)
2944#pragma alloc_text(COLLECTOR,CollectorFrameWndProc)
2945#pragma alloc_text(STARTUP,StartCollector)
Note: See TracBrowser for help on using the repository browser.