source: trunk/dll/collect.c@ 1065

Last change on this file since 1065 was 1065, checked in by John Small, 17 years ago

Ticket 230: Simplified code and eliminated some local variables by incorporating
all the details view settings (both the global variables and those in the
DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.

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