source: trunk/dll/collect.c@ 1078

Last change on this file since 1078 was 1078, checked in by Steven Levine, 17 years ago

More Fortify infrastructure enhancements
Rework Fortify_SetOwner
Add Fortify_BecomeOwner
Avoid more spurious leak reports

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