source: trunk/dll/collect.c@ 1041

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

Adds optional support for delete being move to X/Eworkplace trashcan (ticket 43)

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