source: trunk/dll/collect.c@ 1077

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

Enhance Fortify infrastructure
Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope
Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT support
Add more fm/2 Fortify tooling and rework existing tooling for correct nesting
Still lots to do for cross-thread allocations
Add misc.h
Add walkem.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 78.1 KB
Line 
1
2/***********************************************************************
3
4 $Id: collect.c 1077 2008-07-18 18:11:54Z stevenhl $
5
6 Collector
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2003, 2008 Steven H. Levine
10
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
15 24 May 05 SHL Rework Win_Error usage
16 25 May 05 SHL Use ULONGLONG and CommaFmtULL
17 25 May 05 SHL Rework for FillInRecordFromFFB
18 05 Jun 05 SHL Use QWL_USER
19 06 Jun 05 SHL Indent -i2
20 06 Jun 05 SHL Make savedSortFlags static to avoid referencing garbage
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
24 14 Jul 06 SHL Use Runtime_Error
25 27 Jul 06 SHL Avoid shutdown hang - pre3 typo
26 29 Jul 06 SHL Use xfgets_bstripcr
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
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
32 30 Mar 07 GKY Remove GetPString for window class names
33 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
34 06 Apr 07 GKY Add some error checking in drag/drop
35 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checks.
36 12 May 07 SHL Use dcd->ulItemsToUnHilite
37 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
38 05 Jul 07 SHL CollectorCnrWndProc: just warn if busy
39 02 Aug 07 SHL Sync with CNRITEM mods
40 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
41 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
42 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
43 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
44 10 Jan 08 SHL Sync with CfgDlgProc mods
45 10 Feb 08 GKY Implement bubble help for bitmap menu items
46 15 Feb 08 SHL Sync with settings menu rework
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
49 29 Feb 08 GKY Use xfree where appropriate
50 06 Jul 08 GKY Update delete/undelete to include move to and open XWP trashcan
51 11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
52 all the details view settings (both the global variables and those in the
53 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
54
55***********************************************************************/
56
57#include <stdlib.h>
58#include <string.h>
59#include <ctype.h>
60#include <share.h>
61#include <limits.h>
62#include <process.h> // _beginthread
63
64#define INCL_DOS // QSV_MS_COUNT
65#define INCL_WIN
66#define INCL_DOSERRORS
67#define INCL_LONGLONG
68
69#include "fm3dlg.h"
70#include "fm3str.h"
71#include "mle.h"
72#include "grep.h"
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
78#include "tmrsvcs.h" // ITIMER_DESC
79#include "notebook.h" // CfgDlgProc
80#include "command.h" // RunCommand
81#include "fm3dll.h"
82
83#include "fortify.h"
84
85#pragma data_seg(DATA1)
86
87static PSZ pszSrcFile = __FILE__;
88
89MRESULT EXPENTRY CollectorFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
90 MPARAM mp2)
91{
92 return CommonFrameWndProc(COLLECTOR_CNR, hwnd, msg, mp1, mp2);
93}
94
95MRESULT EXPENTRY CollectorTextProc(HWND hwnd, ULONG msg, MPARAM mp1,
96 MPARAM mp2)
97{
98 DIRCNRDATA *dcd;
99
100 static BOOL emphasized = FALSE;
101 static HWND hwndButtonPopup = (HWND) 0;
102 static ULONG timestamp = ULONG_MAX;
103 static USHORT lastid = 0;
104
105 switch (msg) {
106 case WM_CREATE:
107 return CommonTextProc(hwnd, msg, mp1, mp2);
108
109 case UM_CONTEXTMENU:
110 case WM_CONTEXTMENU:
111 {
112 USHORT id;
113
114 id = WinQueryWindowUShort(hwnd, QWS_ID);
115 switch (id) {
116 case DIR_SELECTED:
117 case DIR_VIEW:
118 case DIR_SORT:
119 {
120 POINTL ptl = { 0, 0 };
121 SWP swp;
122
123 if (hwndButtonPopup)
124 WinDestroyWindow(hwndButtonPopup);
125 if (id == lastid) {
126 ULONG check;
127
128 DosQuerySysInfo(QSV_MS_COUNT,
129 QSV_MS_COUNT, &check, sizeof(check));
130 if (check < timestamp + 500) {
131 lastid = 0;
132 goto MenuAbort;
133 }
134 }
135 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
136 if (hwndButtonPopup) {
137 WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
138 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
139 QW_PARENT),
140 COLLECTOR_CNR), QWL_USER);
141 if (id == DIR_VIEW) {
142 if (dcd) {
143 SetViewMenu(hwndButtonPopup, dcd->flWindowAttr);
144 SetDetailsSwitches(hwndButtonPopup, &dcd->ds);
145 CopyPresParams(hwndButtonPopup, hwnd);
146 }
147
148 /* don't have tree view in collector */
149 WinSendMsg(hwndButtonPopup,
150 MM_DELETEITEM,
151 MPFROM2SHORT(IDM_TREEVIEW, FALSE), MPVOID);
152
153 }
154 else if (id == DIR_SORT) {
155 if (dcd)
156 SetSortChecks(hwndButtonPopup, dcd->sortFlags);
157 }
158 ptl.x = 0;
159 if (WinPopupMenu(HWND_OBJECT,
160 HWND_OBJECT,
161 hwndButtonPopup, -32767, -32767, 0, 0)) {
162 WinQueryWindowPos(hwndButtonPopup, &swp);
163 ptl.y = -(swp.cy + 2);
164 }
165 else {
166 WinQueryWindowPos(hwnd, &swp);
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 |
176 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
177 CenterOverWindow(hwndButtonPopup);
178 PaintRecessedWindow(hwnd, NULLHANDLE, FALSE, FALSE);
179 }
180 }
181 }
182 break;
183 default:
184 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
185 COLLECTOR_CNR),
186 WM_CONTROL,
187 MPFROM2SHORT(COLLECTOR_CNR, CN_CONTEXTMENU), MPVOID);
188 break;
189 }
190 }
191 MenuAbort:
192 if (msg == UM_CONTEXTMENU)
193 return 0;
194 break;
195
196 case WM_MENUEND:
197 if (hwndButtonPopup == (HWND) mp2) {
198 lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
199 WinDestroyWindow(hwndButtonPopup);
200 hwndButtonPopup = (HWND) 0;
201 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &timestamp,
202 sizeof(timestamp));
203 switch (lastid) {
204 case DIR_SELECTED:
205 case DIR_VIEW:
206 case DIR_SORT:
207 PaintRecessedWindow(hwnd, NULLHANDLE, TRUE, FALSE);
208 break;
209 }
210 }
211 break;
212
213 case WM_COMMAND:
214 {
215 DIRCNRDATA *dcd;
216 MRESULT mr;
217
218 mr = WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,
219 QW_PARENT),
220 COLLECTOR_CNR), msg, mp1, mp2);
221 if (hwndButtonPopup &&
222 SHORT1FROMMP(mp1) > IDM_DETAILSTITLES &&
223 SHORT1FROMMP(mp1) < IDM_DETAILSSETUP) {
224 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
225 QW_PARENT),
226 COLLECTOR_CNR), QWL_USER);
227 if (dcd)
228 SetDetailsSwitches(hwndButtonPopup, &dcd->ds);
229 }
230 return mr;
231 }
232
233 case WM_MOUSEMOVE:
234 {
235 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
236 char *s = NULL;
237
238 if (fOtherHelp) {
239 if ((!hwndBubble ||
240 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
241 !WinQueryCapture(HWND_DESKTOP)) {
242 switch (id) {
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:
256 s = GetPString(IDS_DIRCNRFILTERHELP);
257 break;
258 default:
259 break;
260 }
261 if (s)
262 MakeBubble(hwnd, TRUE, s);
263 else if (hwndBubble)
264 WinDestroyWindow(hwndBubble);
265 }
266 }
267 switch (id) {
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;
276
277 case WM_BUTTON3UP:
278 case WM_BUTTON1UP:
279 case WM_BUTTON3DOWN:
280 case WM_BUTTON1DOWN:
281 {
282 USHORT id;
283
284 id = WinQueryWindowUShort(hwnd, QWS_ID);
285 switch (id) {
286 case DIR_FILTER:
287 case DIR_SORT:
288 case DIR_VIEW:
289 case DIR_SELECTED:
290 return CommonTextButton(hwnd, msg, mp1, mp2);
291 }
292 }
293 break;
294
295 case UM_CLICKED:
296 case UM_CLICKED3:
297 {
298 USHORT id, cmd = 0;
299
300 id = WinQueryWindowUShort(hwnd, QWS_ID);
301 switch (id) {
302 case DIR_VIEW:
303 case DIR_SORT:
304 case DIR_SELECTED:
305 PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
306 break;
307 case DIR_FILTER:
308 cmd = IDM_FILTER;
309 break;
310 default:
311 break;
312 }
313 if (cmd)
314 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
315 COLLECTOR_CNR),
316 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
317 }
318 return 0;
319
320 case DM_DROP:
321 case DM_DRAGOVER:
322 case DM_DRAGLEAVE:
323 case DM_DROPHELP:
324 if (msg == DM_DRAGOVER) {
325 if (!emphasized) {
326 emphasized = TRUE;
327 DrawTargetEmphasis(hwnd, emphasized);
328 }
329 }
330 else {
331 if (emphasized) {
332 emphasized = FALSE;
333 DrawTargetEmphasis(hwnd, emphasized);
334 }
335 }
336 {
337 CNRDRAGINFO cnd;
338 USHORT dcmd;
339
340 switch (msg) {
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;
353 }
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 }
360 }
361 return PFNWPStatic(hwnd, msg, mp1, mp2);
362}
363
364MRESULT EXPENTRY CollectorClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
365 MPARAM mp2)
366{
367 switch (msg) {
368 case UM_CONTAINERHWND:
369 return MRFROMLONG(WinWindowFromID(hwnd, COLLECTOR_CNR));
370
371 case UM_VIEWSMENU:
372 return MRFROMLONG(CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP));
373
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);
382
383 case WM_PSETFOCUS:
384 case WM_SETFOCUS:
385 if (mp2)
386 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
387 break;
388
389 case UM_FOCUSME:
390 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, COLLECTOR_CNR));
391 break;
392
393 case WM_PAINT:
394 {
395 HPS hps;
396 RECTL rcl;
397
398 hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
399 if (hps) {
400 WinQueryWindowRect(hwnd, &rcl);
401 WinFillRect(hps, &rcl, CLR_PALEGRAY);
402 CommonTextPaint(hwnd, hps);
403 WinEndPaint(hps);
404 }
405 }
406 break;
407
408 case UM_SIZE:
409 case WM_SIZE:
410 if (msg == UM_SIZE) {
411 SWP swp;
412
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;
419
420 cx = SHORT1FROMMP(mp2);
421 cy = SHORT2FROMMP(mp2);
422 WinSetWindowPos(WinWindowFromID(hwnd, COLLECTOR_CNR), HWND_TOP,
423 0, 0, cx, cy - 24, SWP_SHOW | SWP_MOVE | SWP_SIZE);
424 WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
425 2,
426 cy - 22,
427 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
428 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
429 2 + (cx / 3) + 2,
430 cy - 22,
431 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
432 bx = (cx - (2 + (((cx / 3) + 2) * 2))) / 3;
433 WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
434 2 + (((cx / 3) + 2) * 2),
435 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
436 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
437 2 + (((cx / 3) + 2) * 2) + bx,
438 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
439 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
440 2 + (((cx / 3) + 2) * 2) + (bx * 2),
441 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
442 }
443 CommonTextPaint(hwnd, NULLHANDLE);
444 if (msg == UM_SIZE) {
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;
450
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);
456 }
457 return WinDefWindowProc(hwnd, msg, mp1, mp2);
458}
459
460MRESULT EXPENTRY CollectorObjWndProc(HWND hwnd, ULONG msg,
461 MPARAM mp1, MPARAM mp2)
462{
463 ULONG size;
464 DIRCNRDATA *dcd;
465
466 switch (msg) {
467 case WM_CREATE:
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
470 break;
471
472 case DM_PRINTOBJECT:
473 return MRFROMLONG(DRR_TARGET);
474
475 case DM_DISCARDOBJECT:
476 dcd = INSTDATA(hwnd);
477 if (fFM2Deletes && dcd) {
478 LISTINFO *li;
479 CNRDRAGINFO cni;
480
481 cni.pRecord = NULL;
482 cni.pDragInfo = (PDRAGINFO) mp1;
483 li = DoFileDrop(dcd->hwndCnr, NULL, FALSE, MPVOID, MPFROMP(&cni));
484 CheckPmDrgLimit(cni.pDragInfo);
485 if (li) {
486 li->type = fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE;
487 if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
488 FreeListInfo(li);
489 else
490 return MRFROMLONG(DRR_SOURCE);
491 }
492 }
493 return MRFROMLONG(DRR_TARGET);
494
495 case UM_UPDATERECORDLIST:
496 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
497 if (dcd && mp1) {
498 INT numentries = 0;
499 CHAR **list = (CHAR **) mp1;
500
501 while (list[numentries])
502 numentries++;
503 if (numentries)
504 UpdateCnrList(dcd->hwndCnr, list, numentries, FALSE, dcd);
505 }
506 return 0;
507
508 case UM_SETUP:
509# ifdef FORTIFY
510 Fortify_EnterScope();
511# endif
512 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
513 if (dcd) {
514# ifdef FORTIFY
515 Fortify_ChangeOwner(dcd);
516# endif
517 /* set unique id */
518 WinSetWindowUShort(hwnd,
519 QWS_ID,
520 COLLECTOROBJ_FRAME + (COLLECTOR_FRAME - dcd->id));
521 dcd->hwndObject = hwnd;
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
525 }
526 else
527 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
528 return 0;
529
530 case UM_COMMAND:
531 if (mp1) {
532 LISTINFO *li = (LISTINFO *) mp1;
533
534 switch (li->type) {
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;
564 }
565 }
566 return 0;
567
568 case UM_COLLECT:
569 DosError(FERR_DISABLEHARDERR);
570 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
571 if (dcd) {
572 LISTINFO *li = (LISTINFO *) mp1;
573 INT x;
574 FILEFINDBUF4L fb4;
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];
582
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
592 for (ulMaxFiles = 0; li->list[ulMaxFiles]; ulMaxFiles++) ; // Count
593
594 if (ulMaxFiles) {
595 pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD,
596 MPFROMLONG(EXTRA_RECORD_BYTES),
597 MPFROMLONG(ulMaxFiles));
598 if (!pci) {
599 Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
600 ulMaxFiles);
601 break;
602 }
603 else {
604 ITIMER_DESC itdSleep = { 0 }; // 06 Feb 08 SHL
605 InitITimer(&itdSleep, 500); // Sleep every 500 mSec
606 pciFirst = pci;
607 // 04 Jan 08 SHL fixme like comp.c if CM_ALLOCRECORD returns unexpected record count
608 for (x = 0; li->list[x]; x++) {
609 nm = 1;
610 hdir = HDIR_CREATE;
611 DosError(FERR_DISABLEHARDERR);
612 if (FindCnrRecord(dcd->hwndCnr,
613 li->list[x],
614 NULL,
615 FALSE,
616 FALSE,
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;
625 if (pciP)
626 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
627 else
628 pciFirst = pci;
629 }
630 else if (*li->list[x] &&
631 !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
632 fullname, sizeof(fullname)) &&
633 !IsRoot(fullname) &&
634 !xDosFindFirst(fullname,
635 &hdir,
636 FILE_NORMAL | FILE_DIRECTORY |
637 FILE_ARCHIVED | FILE_SYSTEM |
638 FILE_HIDDEN | FILE_READONLY,
639 &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL)) {
640 DosFindClose(hdir);
641 priority_normal();
642 *fb4.achName = 0;
643 ullTotalBytes = FillInRecordFromFFB(dcd->hwndCnr,
644 pci,
645 fullname, &fb4, FALSE, dcd);
646 dcd->ullTotalBytes += ullTotalBytes;
647 pciP = pci;
648 pci = (PCNRITEM) pci->rc.preccNextRecord;
649 }
650 else {
651 // Oops - fixme to complain?
652 pciT = pci;
653 pci = (PCNRITEM) pci->rc.preccNextRecord;
654 if (pciP)
655 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
656 else
657 pciFirst = pci;
658 if (pciT)
659 FreeCnrItemData(pciT); // FreeCnrItem(hwnd, pciT);
660 ulMaxFiles--; // Remember gone
661 }
662 SleepIfNeeded(&itdSleep, 1); // 09 Feb 08 SHL
663 // DosSleep(0); //26 Aug 07 GKY 1 // 09 Feb 08 SHL
664 } // for
665 if (ulMaxFiles) {
666 // Some files OK
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;
674 WinSendMsg(dcd->hwndCnr,
675 CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
676 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
677 }
678 }
679 }
680 }
681 if (dcd->flWindowAttr & CV_DETAIL)
682 WinSendDlgItemMsg(hwnd,
683 COLLECTOR_CNR,
684 CM_INVALIDATERECORD,
685 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
686 return 0;
687
688 case UM_COLLECTFROMFILE:
689 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
690# ifdef FORTIFY
691 Fortify_EnterScope();
692# endif
693
694 if (dcd && mp1) {
695 FILESTATUS4L fs4;
696 PCNRITEM pci;
697 RECORDINSERT ri;
698 CHAR fullname[1024], *p;
699 FILE *fp;
700 ULONG errs = 0;
701 BOOL first = FALSE;
702 size_t c;
703
704# ifdef FORTIFY
705 Fortify_ChangeOwner(mp1);
706# endif
707
708 fp = _fsopen((CHAR *)mp1, "r", SH_DENYNO);
709 if (fp) {
710 while (!feof(fp)) {
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");
715 break;
716 }
717
718 c = strlen(fullname);
719 if (c + 1 >= sizeof(fullname))
720 errs++;
721 else if (!c || (fullname[c - 1] != '\n' && fullname[c - 1] != '\r'))
722 errs++;
723 else {
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 */
740 DosError(FERR_DISABLEHARDERR);
741 if (FindCnrRecord(dcd->hwndCnr,
742 fullname,
743 NULL,
744 FALSE,
745 FALSE,
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;
754 if (pciP)
755 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
756 else
757 pciFirst = pci;*/
758 }
759 else if (IsFullName(fullname) &&
760 !IsRoot(fullname) &&
761 !DosQueryPathInfo(fullname,
762 FIL_QUERYEASIZEL,
763 &fs4,
764 sizeof(fs4))) {
765 /* collect it */
766 pci = WinSendMsg(dcd->hwndCnr,
767 CM_ALLOCRECORD,
768 MPFROMLONG(EXTRA_RECORD_BYTES),
769 MPFROMLONG(1));
770 if (pci) {
771 dcd->ullTotalBytes += FillInRecordFromFSA(dcd->hwndCnr, pci,
772 fullname,
773 &fs4, FALSE, dcd);
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;
779 ri.cRecordsInsert = 1;
780 ri.fInvalidateRecord = TRUE;
781 WinSendMsg(dcd->hwndCnr, CM_INSERTRECORD,
782 MPFROMP(pci), MPFROMP(&ri));
783 }
784 }
785 else
786 errs++;
787 }
788 if (errs > (first ? 0 : 50)) {
789 /* prevent runaway on bad file */
790 APIRET ret = saymsg(MB_YESNO, dcd->hwndCnr,
791 GetPString(IDS_COLLECTNOLISTHDRTEXT),
792 GetPString(IDS_COLLECTNOLISTTEXT),
793 (CHAR *)mp1);
794
795 if (ret == MBID_NO)
796 break;
797 if (!first)
798 errs = 0;
799 else
800 first = FALSE;
801 }
802 } // while not eof
803 fclose(fp);
804 }
805 }
806 xfree(mp1, pszSrcFile, __LINE__);
807# ifdef FORTIFY
808 Fortify_LeaveScope();
809# endif
810 return 0;
811
812 case UM_SELECT:
813 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
814 if (dcd) {
815 switch (SHORT1FROMMP(mp1)) {
816 case IDM_SELECTLIST:
817 {
818 CHAR filename[CCHMAXPATH], *p, *pp;
819
820 strcpy(filename, "*.LST");
821 size = CCHMAXPATH;
822 PrfQueryProfileData(fmprof, appname, "SaveToListName", filename,
823 &size);
824 pp = strrchr(filename, '\\');
825 if (!pp)
826 pp = filename;
827 p = strrchr(pp, '.');
828 if (p && *(p + 1) && p > pp + 1) {
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))
837 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
838 NULL);
839 }
840 break;
841 case IDM_SELECTALL:
842 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
843 break;
844 case IDM_DESELECTALL:
845 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
846 break;
847 case IDM_SELECTALLFILES:
848 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
849 break;
850 case IDM_DESELECTALLFILES:
851 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
852 break;
853 case IDM_SELECTALLDIRS:
854 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
855 break;
856 case IDM_DESELECTALLDIRS:
857 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
858 break;
859 case IDM_DESELECTMASK:
860 case IDM_SELECTMASK:
861 {
862 MASK mask;
863 PCNRITEM pci = (PCNRITEM) mp2;
864
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) ?
871 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
872 if (pci && (INT) pci != -1)
873 strcpy(mask.szMask, pci->pszFileName);
874 if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
875 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
876 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
877 SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
878 FALSE);
879 else
880 DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
881 FALSE);
882 }
883 }
884
885 case IDM_DESELECTCLIP:
886 case IDM_SELECTCLIP:
887 {
888 CHAR **list;
889
890 list = ListFromClipboard(hwnd);
891 if (list) {
892 SelectList(dcd->hwndCnr, TRUE, FALSE,
893 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
894 NULL, NULL, list);
895 FreeList(list);
896 }
897 }
898 break;
899
900 case IDM_INVERT:
901 InvertAll(dcd->hwndCnr);
902 break;
903 }
904 }
905 return 0;
906
907 case UM_MASSACTION:
908# ifdef FORTIFY
909 Fortify_EnterScope();
910# endif
911 if (mp1) {
912# ifdef FORTIFY
913 Fortify_ChangeOwner(mp1);
914# endif
915 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
916 if (dcd) {
917 WORKER *wk;
918 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
919 if (!wk)
920 FreeListInfo((LISTINFO *) mp1);
921 else {
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);
929 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
930 Runtime_Error(pszSrcFile, __LINE__,
931 GetPString(IDS_COULDNTSTARTTHREADTEXT));
932 free(wk);
933 FreeListInfo((LISTINFO *) mp1);
934 }
935 }
936 }
937 }
938# ifdef FORTIFY
939 DosSleep(1); // Let receiver take ownership
940 Fortify_LeaveScope();
941# endif
942 return 0;
943
944 case UM_ACTION:
945# ifdef FORTIFY
946 Fortify_EnterScope();
947# endif
948 if (mp1) {
949# ifdef FORTIFY
950 Fortify_ChangeOwner(mp1);
951# endif
952 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
953 if (dcd) {
954 WORKER *wk;
955 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
956 if (!wk)
957 FreeListInfo((LISTINFO *) mp1);
958 else {
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);
966 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
967 Runtime_Error(pszSrcFile, __LINE__,
968 GetPString(IDS_COULDNTSTARTTHREADTEXT));
969 free(wk);
970 FreeListInfo((LISTINFO *) mp1);
971 }
972 }
973 }
974 }
975# ifdef FORTIFY
976 DosSleep(1); // Let receiver take ownership
977 Fortify_LeaveScope();
978# endif
979 return 0;
980
981 case WM_CLOSE:
982 WinDestroyWindow(hwnd);
983 break;
984
985 case WM_DESTROY:
986 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
987 if (dcd) {
988 INT x;
989
990 dcd->stopflag = 1;
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");
996 WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
997 FreeList(dcd->lastselection);
998 free(dcd);
999# ifdef FORTIFY
1000 Fortify_LeaveScope();
1001# endif
1002 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
1003 }
1004 DosPostEventSem(CompactSem);
1005 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1006 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1007 break;
1008 }
1009 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1010}
1011
1012MRESULT EXPENTRY CollectorCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
1013 MPARAM mp2)
1014{
1015 DIRCNRDATA *dcd = INSTDATA(hwnd);
1016 ULONG size;
1017
1018 static INT savedSortFlags;
1019
1020 switch (msg) {
1021 case DM_PRINTOBJECT:
1022 return MRFROMLONG(DRR_TARGET);
1023
1024 case DM_DISCARDOBJECT:
1025 if (dcd)
1026 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1027 else
1028 return MRFROMLONG(DRR_TARGET);
1029
1030 case WM_CHAR:
1031 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1032 if (SHORT1FROMMP(mp1) & KC_KEYUP)
1033 return (MRESULT) TRUE;
1034 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1035 switch (SHORT2FROMMP(mp2)) {
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;
1044 }
1045 }
1046 if (shiftstate || fNoSearch)
1047 break;
1048 if (SHORT1FROMMP(mp1) & KC_CHAR) {
1049 ULONG thistime, len;
1050 SEARCHSTRING srch;
1051 PCNRITEM pci;
1052
1053 if (!dcd)
1054 break;
1055 switch (SHORT1FROMMP(mp2)) {
1056 case '\x1b':
1057 case '\r':
1058 case '\n':
1059 dcd->lasttime = 0;
1060 *dcd->szCommonName = 0;
1061 break;
1062 default:
1063 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1064 if (thistime > dcd->lasttime + 1250)
1065 *dcd->szCommonName = 0;
1066 dcd->lasttime = thistime;
1067 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
1068 break;
1069 KbdRetry:
1070 len = strlen(dcd->szCommonName);
1071 if (len >= CCHMAXPATH - 1) {
1072 *dcd->szCommonName = 0;
1073 len = 0;
1074 }
1075 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1076 dcd->szCommonName[len + 1] = 0;
1077 memset(&srch, 0, sizeof(SEARCHSTRING));
1078 srch.cb = sizeof(SEARCHSTRING);
1079 srch.pszSearch = dcd->szCommonName;
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));
1085 if (pci && (INT) pci != -1) {
1086 USHORT attrib = CRA_CURSORED;
1087
1088 /* make found item current item */
1089 if (!stricmp(pci->pszFileName, dcd->szCommonName))
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 }
1097 else {
1098 if (SHORT1FROMMP(mp2) == ' ') {
1099 dcd->szCommonName[len] = 0;
1100 break;
1101 }
1102 *dcd->szCommonName = 0;
1103 dcd->lasttime = 0;
1104 if (len) // retry as first letter if no match
1105
1106 goto KbdRetry;
1107 }
1108 break;
1109 }
1110 }
1111 break;
1112
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;
1120
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),
1128 MPFROMLONG(sizeof(CNRINFO)))) {
1129 if (cnri.flWindowAttr & CV_DETAIL)
1130 PrfWriteProfileData(fmprof, appname, "CollectorCnrSplitBar",
1131 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
1132 }
1133 }
1134 break;
1135
1136 case WM_PRESPARAMCHANGED:
1137 PresParamChanged(hwnd, "Collector", mp1, mp2);
1138 break;
1139
1140 case UM_COMPARE:
1141 if (dcd && mp1 && mp2) {
1142 COMPARE *cmp;
1143 CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
1144
1145 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1146 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1147 if (cmp) {
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;
1153 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, CompareDlgProc,
1154 FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1155 }
1156 }
1157 }
1158 return 0;
1159
1160 case UM_UPDATERECORDLIST:
1161 if (dcd && mp1)
1162 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1163 return 0;
1164
1165 case UM_UPDATERECORD:
1166 if (dcd && mp1) {
1167 CHAR *filename;
1168
1169 filename = mp1;
1170 if (filename)
1171 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1172 }
1173 return 0;
1174
1175 case WM_SETFOCUS:
1176 /*
1177 * put name of our window on status line
1178 */
1179 if (dcd && hwndStatus && mp2) {
1180 PCNRITEM pci = NULL;
1181
1182 if (fAutoView && hwndMain) {
1183 pci = WinSendMsg(hwnd,
1184 CM_QUERYRECORDEMPHASIS,
1185 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1186 if (pci && (INT) pci != -1 &&
1187 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1188 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1189 else
1190 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1191 }
1192 if (dcd->amextracted)
1193 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1194 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1195 }
1196 break;
1197
1198 case UM_RESCAN:
1199 if (dcd) {
1200 CNRINFO cnri;
1201 CHAR s[CCHMAXPATH + 69], tb[81], tf[81], *p;
1202 PCNRITEM pci = NULL;
1203
1204 memset(&cnri, 0, sizeof(CNRINFO));
1205 cnri.cb = sizeof(CNRINFO);
1206 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1207 MPFROMLONG(sizeof(CNRINFO)));
1208 dcd->totalfiles = cnri.cRecords;
1209 commafmt(tf, sizeof(tf), dcd->totalfiles);
1210 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
1211 sprintf(s, "%s / %s", tf, tb);
1212 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1213
1214 commafmt(tf, sizeof(tf), dcd->selectedfiles);
1215 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
1216 sprintf(s, "%s / %s", tf, tb);
1217 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1218
1219 if (hwndStatus &&
1220 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1221 if (hwndMain) {
1222 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1223 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1224 if (pci && (INT) pci != -1)
1225 PostMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1226 else
1227 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1228 }
1229 if (!dcd->amextracted) {
1230 if (!fMoreButtons) {
1231 sprintf(s, " %s%s%s%s",
1232 GetPString(IDS_COLLECTORTEXT),
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);
1247 }
1248 if (!pci)
1249 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1250 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1251 if (pci && (INT) pci != -1) {
1252 BOOL fStatus2Used = FALSE;
1253
1254 if (fSplitStatus && hwndStatus2) {
1255 if (pci->attrFile & FILE_DIRECTORY)
1256 p = pci->pszFileName;
1257 else {
1258 p = strrchr(pci->pszFileName, '\\');
1259 if (p) {
1260 if (*(p + 1))
1261 p++;
1262 else
1263 p = pci->pszFileName;
1264 }
1265 else
1266 p = pci->pszFileName;
1267 }
1268 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1269 if (!fMoreButtons) {
1270 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
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);
1274 }
1275 else {
1276 if (pci->cbFile + pci->easize > 1024)
1277 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1278 else
1279 *tf = 0;
1280 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
1281 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1282 }
1283 WinSetWindowText(hwndStatus2, s);
1284 fStatus2Used = TRUE;
1285 }
1286 if (fMoreButtons) {
1287 WinSetWindowText(hwndName, pci->pszFileName);
1288 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
1289 pci->date.year, pci->date.month,
1290 pci->date.day, pci->time.hours, pci->time.minutes,
1291 pci->time.seconds);
1292 WinSetWindowText(hwndDate, s);
1293 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1294 }
1295 if (dcd->amextracted && hwndStatus2 && !fStatus2Used)
1296 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1297 }
1298 else {
1299 if (hwndStatus2) {
1300 if (dcd->amextracted)
1301 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1302 else
1303 WinSetWindowText(hwndStatus2, NullStr);
1304 }
1305 if (fMoreButtons) {
1306 WinSetWindowText(hwndName, NullStr);
1307 WinSetWindowText(hwndDate, NullStr);
1308 WinSetWindowText(hwndAttr, NullStr);
1309 }
1310 }
1311 }
1312 }
1313 return 0;
1314
1315 case UM_CONTAINER_FILLED:
1316 DosBeep(1000, 50); // Wake up user?
1317 WinSendMsg(hwnd,
1318 CM_INVALIDATERECORD,
1319 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1320 disable_menuitem(WinWindowFromID(WinQueryWindow(hwndMain, QW_PARENT),
1321 FID_MENU), IDM_GREP, FALSE);
1322 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1323 if (dcd) {
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);
1329 }
1330 else
1331 WinSetWindowPos(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
1332 QW_PARENT),
1333 HWND_TOP,
1334 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ZORDER);
1335 }
1336 return 0;
1337
1338 case UM_SETUP:
1339 if (dcd) {
1340 if (!dcd->hwndObject) {
1341 /* first time through -- set things up */
1342
1343 CNRINFO cnri;
1344
1345 RestorePresParams(hwnd, "Collector");
1346 LoadDetailsSwitches("Collector", &dcd->ds);
1347
1348 dcd->amextracted = FALSE; // Say not busy
1349 dcd->stopflag = 0;
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;
1355 cnri.cxTreeIndent = 12;
1356
1357 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_DETAIL));
1358 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES |
1359 CV_MINI | CV_FLOW);
1360 cnri.pSortRecord = (PVOID) SortCollectorCnr;
1361
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) &&
1367 size) {
1368 PrfQueryProfileData(fmprof, appname, "CollectorFilter", &dcd->mask,
1369 &size);
1370 SetMask(NULL, &dcd->mask);
1371 }
1372 else {
1373 dcd->mask.attrFile = (FILE_NORMAL | FILE_READONLY |
1374 FILE_DIRECTORY | FILE_HIDDEN |
1375 FILE_SYSTEM | FILE_ARCHIVED);
1376 dcd->mask.antiattr = 0;
1377 }
1378
1379 *(dcd->mask.prompt) = 0;
1380
1381 cnri.flWindowAttr |= CV_FLOW;
1382 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
1383 dcd->flWindowAttr = cnri.flWindowAttr;
1384 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1385 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1386 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1387 SetCnrCols(hwnd, FALSE);
1388 AdjustCnrColsForPref(hwnd, NULL, &dcd->ds, FALSE);
1389
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)
1396 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1397 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1398 MPFROMLONG(CMA_XVERTSPLITBAR));
1399
1400 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID)dcd) == -1) {
1401 Runtime_Error(pszSrcFile, __LINE__,
1402 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1403 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1404 return 0;
1405 }
1406 else
1407 DosSleep(32); // Let object window get started
1408 }
1409 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1410 DIR_FILTER), &dcd->mask, FALSE);
1411 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1412 DIR_SORT), CollectorsortFlags, FALSE);
1413 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1414 DIR_VIEW), dcd->flWindowAttr);
1415 }
1416 else {
1417 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1418 return 0;
1419 }
1420 return 0;
1421
1422 case WM_MENUEND:
1423 if (dcd) {
1424 HWND hwndMenu = (HWND) mp2;
1425
1426 if (hwndMenu == CollectorCnrMenu || hwndMenu == CollectorFileMenu ||
1427 hwndMenu == CollectorDirMenu) {
1428 MarkAll(hwnd, TRUE, FALSE, TRUE);
1429 if (dcd->cnremphasized) {
1430 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1431 MPFROM2SHORT(FALSE, CRA_SOURCE));
1432 dcd->cnremphasized = FALSE;
1433 }
1434 }
1435 }
1436 break;
1437
1438 case UM_OPENWINDOWFORME:
1439 if (dcd) {
1440 if (mp1 && !IsFile((CHAR *)mp1))
1441 OpenDirCnr(HWND_DESKTOP, hwndMain, dcd->hwndFrame, FALSE, (PSZ) mp1);
1442 else if (mp1 && IsFile(mp1) == 1)
1443 StartArcCnr(HWND_DESKTOP,
1444 dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
1445 }
1446 return 0;
1447
1448 case MM_PORTHOLEINIT:
1449 if (dcd) {
1450 switch (SHORT1FROMMP(mp1)) {
1451 case 0:
1452 case 1:
1453 {
1454 ULONG wmsg;
1455
1456 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1457 PortholeInit((HWND) WinSendMsg(dcd->hwndClient, wmsg, MPVOID,
1458 MPVOID), mp1, mp2);
1459 }
1460 break;
1461 }
1462 }
1463 break;
1464
1465 case UM_INITMENU:
1466 case WM_INITMENU:
1467 if (dcd) {
1468 switch (SHORT1FROMMP(mp1)) {
1469 case IDM_VIEWSMENU:
1470 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1471 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1472 (dcd->lastselection != NULL));
1473 CopyPresParams((HWND) mp2, hwnd);
1474 break;
1475
1476 case IDM_DETAILSSETUP:
1477 SetDetailsSwitches((HWND) mp2, &dcd->ds);
1478 break;
1479
1480 case IDM_COMMANDSMENU:
1481 SetupCommandMenu((HWND) mp2, hwnd);
1482 break;
1483
1484 case IDM_SORTSUBMENU:
1485 SetSortChecks((HWND) mp2, CollectorsortFlags);
1486 break;
1487 }
1488 dcd->hwndLastMenu = (HWND) mp2;
1489 }
1490 if (msg == WM_INITMENU)
1491 break;
1492 return 0;
1493
1494 case UM_COLLECTFROMFILE:
1495 if (mp1) {
1496# ifdef FORTIFY
1497 Fortify_EnterScope();
1498 Fortify_ChangeOwner(mp1);
1499# endif
1500 if (!dcd)
1501 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1502 else {
1503 if (!PostMsg(dcd->hwndObject, UM_COLLECTFROMFILE, mp1, mp2)) {
1504 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1505 }
1506 }
1507 free(mp1);
1508# ifdef FORTIFY
1509 DosSleep(1); // Let receiver take ownership
1510 Fortify_LeaveScope();
1511# endif
1512 }
1513 return 0;
1514
1515 case UM_COMMAND:
1516 if (mp1) {
1517 if (dcd) {
1518 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1519 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1520 FreeListInfo((LISTINFO *) mp1);
1521 }
1522 else
1523 return (MRESULT) TRUE;
1524 }
1525 else
1526 FreeListInfo((LISTINFO *) mp1);
1527 }
1528 return 0;
1529
1530 case UM_NOTIFY:
1531 if (mp2)
1532 AddNote((CHAR *)mp2);
1533 return 0;
1534
1535 case WM_COMMAND:
1536 DosError(FERR_DISABLEHARDERR);
1537 if (dcd) {
1538 switch (SHORT1FROMMP(mp1)) {
1539 case IDM_SETTARGET:
1540 SetTargetDir(hwnd, FALSE);
1541 break;
1542
1543 case IDM_CONTEXTMENU:
1544 {
1545 PCNRITEM pci;
1546
1547 pci = (PCNRITEM) CurrentRecord(hwnd);
1548 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(COLLECTOR_CNR,
1549 CN_CONTEXTMENU),
1550 MPFROMP(pci));
1551 }
1552 break;
1553
1554 case IDM_SHOWALLFILES:
1555 {
1556 PCNRITEM pci;
1557
1558 pci = WinSendMsg(hwnd,
1559 CM_QUERYRECORDEMPHASIS,
1560 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1561 if (pci && (INT) pci != -1) {
1562 static CHAR dirname[CCHMAXPATH];
1563
1564 strcpy(dirname, pci->pszFileName);
1565 MakeValidDir(dirname);
1566 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1567 }
1568 }
1569 break;
1570
1571 case IDM_BEGINEDIT:
1572 OpenEdit(hwnd);
1573 break;
1574
1575 case IDM_ENDEDIT:
1576 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1577 break;
1578
1579 case IDM_SHOWSELECT:
1580 QuickPopup(hwnd, dcd,
1581 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
1582 IDM_SELECTSUBMENU);
1583 break;
1584
1585 case IDM_SHOWSORT:
1586 QuickPopup(hwnd, dcd,
1587 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
1588 IDM_SORTSUBMENU);
1589 break;
1590
1591 case IDM_VIEWORARC:
1592 {
1593 SWP swp;
1594 PCNRITEM pci;
1595
1596 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1597 MPFROMLONG(CMA_FIRST),
1598 MPFROMSHORT(CRA_CURSORED));
1599 if (pci && (INT) pci != -1) {
1600 WinQueryWindowPos(dcd->hwndFrame, &swp);
1601 DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp,
1602 pci->pszFileName);
1603 }
1604 }
1605 break;
1606
1607 case IDM_SEEALL:
1608 StartSeeAll(HWND_DESKTOP, FALSE, NULL);
1609 break;
1610
1611 case IDM_COLLECTSELECT:
1612 {
1613 CHAR filename[CCHMAXPATH], *p, *pp;
1614
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, '.');
1623 if (p && *(p + 1) && p > pp + 1) {
1624 if (pp > filename)
1625 pp++;
1626 *pp = '*';
1627 pp++;
1628 if (p > pp)
1629 memmove(pp, p, strlen(p) + 1);
1630 }
1631 if (insert_filename(hwnd, filename, FALSE, FALSE)) {
1632# ifdef FORTIFY
1633 Fortify_EnterScope();
1634# endif
1635 p = xstrdup(filename, pszSrcFile, __LINE__);
1636 if (p) {
1637 if (!PostMsg(hwnd, UM_COLLECTFROMFILE, MPFROMP(p), MPVOID))
1638 free(p);
1639 }
1640# ifdef FORTIFY
1641 DosSleep(1); // Let receiver take ownership
1642 Fortify_LeaveScope();
1643# endif
1644 }
1645 }
1646 break;
1647
1648 case IDM_COLLECTORVIEWSETTINGS:
1649 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1650 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_COLLECTORVIEWSETTINGS), mp2);
1651 else {
1652 WinDlgBox(HWND_DESKTOP,
1653 hwnd,
1654 CfgDlgProc,
1655 FM3ModHandle,
1656 CFG_FRAME,
1657 MPFROMLONG(IDM_COLLECTORVIEWSETTINGS));
1658 }
1659 break;
1660
1661 case IDM_RESELECT:
1662 SelectList(hwnd, FALSE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1663 break;
1664
1665 case IDM_HELP:
1666 if (hwndHelp)
1667 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
1668 MPFROM2SHORT(HELP_COLLECT, 0),
1669 MPFROMSHORT(HM_RESOURCEID));
1670 break;
1671
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:
1684 savedSortFlags = CollectorsortFlags;
1685 CollectorsortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1686 case IDM_SORTDIRSFIRST:
1687 case IDM_SORTDIRSLAST:
1688 case IDM_SORTREVERSE:
1689 switch (SHORT1FROMMP(mp1)) {
1690 case IDM_SORTSUBJECT:
1691 CollectorsortFlags |= SORT_SUBJECT;
1692 break;
1693 case IDM_SORTNONE:
1694 CollectorsortFlags |= SORT_NOSORT;
1695 break;
1696 case IDM_SORTSMARTNAME:
1697 if (~savedSortFlags & SORT_FILENAME)
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);
1727 else {
1728 CollectorsortFlags |= SORT_DIRSFIRST;
1729 CollectorsortFlags &= (~SORT_DIRSLAST);
1730 }
1731 break;
1732 case IDM_SORTDIRSLAST:
1733 if (CollectorsortFlags & SORT_DIRSLAST)
1734 CollectorsortFlags &= (~SORT_DIRSLAST);
1735 else {
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;
1753
1754 case IDM_COLLECTFROMCLIP:
1755 {
1756 LISTINFO *li;
1757# ifdef FORTIFY
1758 Fortify_EnterScope();
1759# endif
1760 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1761 if (li) {
1762 li->list = ListFromClipboard(hwnd);
1763 if (!li->list || !li->list[0])
1764 FreeListInfo(li);
1765 else {
1766 li->type = IDM_COLLECT;
1767 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1768 FreeListInfo(li);
1769 }
1770 }
1771# ifdef FORTIFY
1772 DosSleep(1); // Let receiver take ownership
1773 Fortify_LeaveScope();
1774# endif
1775 }
1776 break;
1777
1778 case IDM_REMOVE:
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);
1785 break;
1786
1787 case IDM_CLEARCNR:
1788 {
1789 PCNRITEM pci;
1790
1791 pci = (PCNRITEM) WinSendMsg(hwnd,
1792 CM_QUERYRECORD,
1793 MPVOID,
1794 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
1795 if (pci && (INT) pci != -1) {
1796 RemoveCnrItems(hwnd, NULL, 0, CMA_FREE | CMA_INVALIDATE);
1797 dcd->ullTotalBytes = dcd->selectedbytes = dcd->selectedfiles =
1798 dcd->totalfiles = 0;
1799 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1800 }
1801 }
1802 break;
1803
1804 case DID_CANCEL:
1805 if (dcd->amextracted)
1806 dcd->stopflag = 1; // Request cancel
1807 break;
1808
1809 case IDM_COLLECTOR:
1810 if (mp2) {
1811 LISTINFO *li;
1812# ifdef FORTIFY
1813 Fortify_EnterScope();
1814# endif
1815 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1816 if (li) {
1817 li->list = mp2;
1818 if (!li->list || !li->list[0])
1819 FreeListInfo(li);
1820 else {
1821 li->type = IDM_COLLECT;
1822 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1823 FreeListInfo(li);
1824 }
1825 }
1826 else
1827 FreeList(mp2);
1828# ifdef FORTIFY
1829 DosSleep(1); // Let receiver take ownership
1830 Fortify_LeaveScope();
1831# endif
1832 }
1833 break;
1834
1835 case IDM_UNDELETE:
1836 {
1837 PCNRITEM pci;
1838 CHAR path[CCHMAXPATH];
1839 HOBJECT hObject;
1840 HWND hwndDesktop;
1841
1842 hObject = WinQueryObject("<XWP_TRASHCAN>");
1843 if (hObject != NULLHANDLE && fTrashCan) {
1844 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
1845 WinSetFocus(HWND_DESKTOP, hwndDesktop);
1846 WinOpenObject(hObject, 0, TRUE);
1847 }
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 }
1857 }
1858 break;
1859
1860 case IDM_GREP:
1861 if (dcd->amextracted) {
1862 saymsg(MB_OK | MB_ICONASTERISK,
1863 hwnd,
1864 GetPString(IDS_WARNINGTEXT),
1865 "Collector busy - please try again later");
1866 }
1867 else {
1868 if (WinDlgBox(HWND_DESKTOP, hwnd, GrepDlgProc,
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);
1874 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1875 }
1876 }
1877 break;
1878
1879 case IDM_RESORT:
1880 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1881 break;
1882
1883 case IDM_FILTER:
1884 {
1885 BOOL empty = FALSE;
1886 PCNRITEM pci;
1887 CHAR *p;
1888
1889 if (!*dcd->mask.szMask) {
1890 empty = TRUE;
1891 pci = (PCNRITEM) CurrentRecord(hwnd);
1892 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
1893 p = strrchr(pci->pszFileName, '\\');
1894 if (p) {
1895 p++;
1896 strcpy(dcd->mask.szMask, p);
1897 }
1898 }
1899 }
1900 *(dcd->mask.prompt) = 0;
1901
1902 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
1903 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
1904 size = sizeof(MASK);
1905 PrfWriteProfileData(fmprof, appname, "CollectorFilter",
1906 &dcd->mask, size);
1907 dcd->suspendview = 1;
1908 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1909 dcd->suspendview = 0;
1910 if (fAutoView && hwndMain) {
1911 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1912 MPFROMLONG(CMA_FIRST),
1913 MPFROMSHORT(CRA_CURSORED));
1914 if (pci && (INT) pci != -1 &&
1915 (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
1916 DRIVE_SLOW)))
1917 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName),
1918 MPVOID);
1919 else
1920 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1921 }
1922 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1923 }
1924 else if (empty)
1925 *dcd->mask.szMask = 0;
1926 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1927 DIR_FILTER), &dcd->mask, FALSE);
1928 }
1929 break;
1930
1931 case IDM_UNHIDEALL:
1932 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1933 break;
1934
1935 case IDM_HIDEALL:
1936 if (fAutoView && hwndMain)
1937 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1938 dcd->suspendview = 1;
1939 HideAll(hwnd);
1940 dcd->suspendview = 0;
1941 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1942 break;
1943
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;
1958
1959 pci = (PCNRITEM) CurrentRecord(hwnd);
1960 if ((INT) pci == -1)
1961 pci = NULL;
1962 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
1963 if (pci) {
1964 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
1965 pci->rc.flRecordAttr |= CRA_FILTERED;
1966 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
1967 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
1968 break;
1969 }
1970 }
1971 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
1972 }
1973 break;
1974
1975 case IDM_RESCAN:
1976 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
1977 break;
1978
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:
1991 AdjustDetailsSwitches(hwnd, dcd->hwndLastMenu,
1992 SHORT1FROMMP(mp1), NULL,
1993 "Collector", &dcd->ds, FALSE);
1994 break;
1995
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;
2004
2005 memset(&cnri, 0, sizeof(CNRINFO));
2006 cnri.cb = sizeof(CNRINFO);
2007 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2008 MPFROMLONG(sizeof(CNRINFO)));
2009 switch (SHORT1FROMMP(mp1)) {
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 }
2043 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2044 cnri.flWindowAttr |= CV_FLOW;
2045 dcd->flWindowAttr = cnri.flWindowAttr;
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),
2053 DIR_VIEW), dcd->flWindowAttr);
2054 }
2055 break;
2056
2057 case IDM_SAVETOLIST:
2058 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2059 SAV_FRAME, MPFROMP(&hwnd));
2060 break;
2061
2062 case IDM_SIZES:
2063 {
2064 PCNRITEM pci;
2065
2066 pci = (PCNRITEM) CurrentRecord(hwnd);
2067 if (pci && (INT) pci != -1)
2068 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DirSizeProc, FM3ModHandle,
2069 DSZ_FRAME, pci->pszFileName);
2070 }
2071 break;
2072
2073 case IDM_MKDIR:
2074 {
2075 PCNRITEM pci;
2076
2077 pci = (PCNRITEM) CurrentRecord(hwnd);
2078 PMMkDir(dcd->hwndParent, (pci && (INT) pci != -1) ?
2079 pci->pszFileName : NULL, FALSE);
2080 }
2081 break;
2082
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;
2130# ifdef FORTIFY
2131 Fortify_EnterScope();
2132# endif
2133 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2134 if (li) {
2135 li->type = SHORT1FROMMP(mp1);
2136 li->hwnd = hwnd;
2137 li->list = BuildList(hwnd);
2138 if (li->list) {
2139 switch (SHORT1FROMMP(mp1)) {
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 }
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)) {
2169 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2170 FreeListInfo(li);
2171 }
2172 else if (fUnHilite)
2173 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2174 }
2175 else
2176 free(li);
2177 }
2178# ifdef FORTIFY
2179 Fortify_LeaveScope();
2180# endif
2181 }
2182 break;
2183
2184 default:
2185 if (!cmdloaded)
2186 load_commands();
2187 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2188 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2189 INT x;
2190
2191 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2192 if (x >= 0) {
2193 x++;
2194 RunCommand(hwnd, x);
2195 if (fUnHilite)
2196 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2197 }
2198 }
2199 break;
2200 }
2201 }
2202 return 0;
2203
2204 case UM_FIXCNRMLE:
2205 case UM_FIXEDITNAME:
2206 return CommonCnrProc(hwnd, msg, mp1, mp2);
2207
2208 case UM_FILESMENU:
2209 {
2210 PCNRITEM pci;
2211 HWND menuHwnd = (HWND) 0;
2212
2213 pci = (PCNRITEM) CurrentRecord(hwnd);
2214 if (pci && (INT) pci != -1) {
2215 if (pci->attrFile & FILE_DIRECTORY)
2216 menuHwnd = CheckMenu(hwnd, &CollectorDirMenu, COLLECTORDIR_POPUP);
2217 else
2218 menuHwnd = CheckMenu(hwnd, &CollectorFileMenu, COLLECTORFILE_POPUP);
2219 }
2220 return MRFROMLONG(menuHwnd);
2221 }
2222
2223 case WM_CONTROL:
2224 DosError(FERR_DISABLEHARDERR);
2225 if (dcd) {
2226 switch (SHORT2FROMMP(mp1)) {
2227 case CN_CONTEXTMENU:
2228 {
2229 PCNRITEM pci = (PCNRITEM) mp2;
2230
2231 if (pci) {
2232 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
2233 MPFROM2SHORT(TRUE, CRA_CURSORED));
2234 MarkAll(hwnd, FALSE, FALSE, TRUE);
2235 if (pci->attrFile & FILE_DIRECTORY)
2236 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorDirMenu,
2237 COLLECTORDIR_POPUP);
2238 else
2239 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorFileMenu,
2240 COLLECTORFILE_POPUP);
2241 }
2242 else {
2243 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorCnrMenu,
2244 COLLECTORCNR_POPUP);
2245 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2246 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2247 MPFROM2SHORT(TRUE, CRA_SOURCE));
2248 dcd->cnremphasized = TRUE;
2249 }
2250 }
2251 if (dcd->hwndLastMenu) {
2252 if (dcd->hwndLastMenu == CollectorCnrMenu) {
2253 SetViewMenu(dcd->hwndLastMenu, dcd->flWindowAttr);
2254 SetDetailsSwitches(dcd->hwndLastMenu, &dcd->ds);
2255 CopyPresParams(dcd->hwndLastMenu, hwnd);
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);
2261 }
2262 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2263 if (dcd->cnremphasized) {
2264 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2265 MPFROM2SHORT(FALSE, CRA_SOURCE));
2266 dcd->cnremphasized = TRUE;
2267 }
2268 MarkAll(hwnd, TRUE, FALSE, TRUE);
2269 }
2270 }
2271 }
2272 break;
2273
2274 case CN_DROPHELP:
2275 if (mp2) {
2276 PDRAGINFO pDInfo;
2277 PCNRITEM pci;
2278 ULONG numitems;
2279 USHORT usOperation;
2280
2281 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2282 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2283 if (!DrgAccessDraginfo(pDInfo)) {
2284 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2285 "DrgAccessDraginfo");
2286 return 0;
2287 }
2288 numitems = DrgQueryDragitemCount(pDInfo);
2289 usOperation = pDInfo->usOperation;
2290 FreeDragInfoData(hwnd, pDInfo);
2291 saymsg(MB_ENTER | MB_ICONASTERISK,
2292 hwnd,
2293 GetPString(IDS_DROPHELPHDRTEXT),
2294 GetPString(IDS_DROPHELPTEXT),
2295 numitems,
2296 &"s"[numitems == 1],
2297 (pci) ? NullStr : GetPString(IDS_NOTEXT),
2298 (pci) ? NullStr : " ",
2299 (pci) ? pci->pszFileName : NullStr,
2300 (pci) ? " " : NullStr,
2301 GetPString((usOperation == DO_COPY) ?
2302 IDS_COPYTEXT :
2303 (usOperation == DO_LINK) ?
2304 IDS_LINKTEXT : IDS_MOVETEXT));
2305 }
2306 return 0;
2307
2308 case CN_DRAGLEAVE:
2309 if (mp2) {
2310 PDRAGINFO pDInfo;
2311
2312 // fixme to know why needed
2313 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2314 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
2315 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2316 }
2317 return 0;
2318
2319 case CN_DRAGAFTER:
2320 case CN_DRAGOVER:
2321 if (mp2) {
2322 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2323 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2324 PCNRITEM pci;
2325 USHORT uso;
2326
2327 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2328 // if(SHORT1FROMMP(mp1) == CN_DRAGAFTER)
2329 // pci = NULL;
2330 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2331 if (!DrgAccessDraginfo(pDInfo)) {
2332 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2333 "DrgAccessDraginfo");
2334 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2335 }
2336 if (pci) {
2337 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2338 DrgFreeDraginfo(pDInfo);
2339 return (MRFROM2SHORT(DOR_NODROP, 0));
2340 }
2341 uso = pDInfo->usOperation;
2342 if (uso == DO_DEFAULT)
2343 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
2344 if (!(pci->attrFile & FILE_DIRECTORY)) {
2345 if (uso != DO_LINK && uso != DO_MOVE && uso != DO_COPY) {
2346 DrgFreeDraginfo(pDInfo);
2347 return MRFROM2SHORT(DOR_NODROP, 0);
2348 }
2349 if (uso != DO_LINK &&
2350 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2351 DRIVE_NOTWRITEABLE)) {
2352 ARC_TYPE *info = NULL;
2353
2354 if (!fQuickArcFind &&
2355 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2356 DRIVE_SLOW))
2357 info = find_type(pci->pszFileName, NULL);
2358 else
2359 info = quick_find_type(pci->pszFileName, NULL);
2360 if (!info || ((uso == DO_MOVE && !info->move) ||
2361 (uso == DO_COPY && !info->create))) {
2362 DrgFreeDraginfo(pDInfo);
2363 return MRFROM2SHORT(DOR_NODROP, 0);
2364 }
2365 }
2366 }
2367 }
2368 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
2369 0); /* Index to DRAGITEM */
2370 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
2371 DRM_OS2FILE, /* mechanisms and data */
2372 NULL)) {
2373 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2374 if (pci) {
2375 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
2376 DRIVE_NOTWRITEABLE)
2377 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2378 if (toupper(*pci->pszFileName) < 'C')
2379 return MRFROM2SHORT(DOR_DROP, DO_COPY);
2380 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2381 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2382 }
2383 else
2384 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2385 DO_COPY);
2386 }
2387 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2388 }
2389 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2390
2391 case CN_INITDRAG:
2392 if (mp2) {
2393 BOOL wasemphasized = FALSE;
2394 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2395 PCNRITEM pci;
2396
2397 if (pcd) {
2398 pci = (PCNRITEM) pcd->pRecord;
2399 if (pci) {
2400 if (pci->rc.flRecordAttr & CRA_SELECTED)
2401 wasemphasized = TRUE;
2402 if (IsRoot(pci->pszFileName))
2403 break;
2404 if (hwndStatus2)
2405 WinSetWindowText(hwndStatus2,
2406 GetPString(IDS_DRAGFILEOBJTEXT));
2407 if (DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE)) {
2408 if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
2409 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2410 }
2411 if (hwndStatus2)
2412 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2413 }
2414 }
2415 }
2416 return 0;
2417
2418 case CN_DROP:
2419 if (mp2) {
2420 LISTINFO *li;
2421 ULONG action = UM_ACTION;
2422
2423 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
2424 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
2425 if (li) {
2426 if (!*li->targetpath) {
2427 li->type = IDM_COLLECT;
2428 action = UM_COLLECT;
2429 }
2430 else {
2431 if (li->list && li->list[0] && IsRoot(li->list[0]))
2432 li->type = DO_LINK;
2433 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2434 CHECKLIST cl;
2435
2436 memset(&cl, 0, sizeof(cl));
2437 cl.size = sizeof(cl);
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,
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) {
2449 FreeListInfo(li);
2450 return 0;
2451 }
2452 li->list = cl.list;
2453 if (!li->list || !li->list[0]) {
2454 FreeListInfo(li);
2455 return 0;
2456 }
2457 }
2458 switch (li->type) {
2459 case DND_LAUNCH:
2460 strcat(li->targetpath, " %a");
2461 ExecOnList(dcd->hwndParent, li->targetpath,
2462 PROMPT | WINDOWED, NULL, li->list, NULL,
2463 pszSrcFile, __LINE__);
2464 FreeList(li->list);
2465 li->list = NULL;
2466 break;
2467 case DO_LINK:
2468 if (fLinkSetsIcon) {
2469 li->type = IDM_SETICON;
2470 action = UM_MASSACTION;
2471 }
2472 else
2473 li->type = IDM_COMPARE;
2474 break;
2475 case DND_EXTRACT:
2476 if (*li->targetpath && !IsFile(li->targetpath))
2477 li->type = IDM_EXTRACT;
2478 break;
2479 case DND_MOVE:
2480 li->type = IDM_MOVE;
2481 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2482 action = UM_MASSACTION;
2483 li->type = IDM_ARCHIVEM;
2484 }
2485 break;
2486 case DND_WILDMOVE:
2487 li->type = IDM_WILDMOVE;
2488 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2489 action = UM_MASSACTION;
2490 li->type = IDM_ARCHIVEM;
2491 }
2492 break;
2493 case DND_OBJECT:
2494 li->type = IDM_OBJECT;
2495 action = UM_MASSACTION;
2496 break;
2497 case DND_SHADOW:
2498 li->type = IDM_SHADOW;
2499 action = UM_MASSACTION;
2500 break;
2501 case DND_COMPARE:
2502 li->type = IDM_COMPARE;
2503 break;
2504 case DND_SETICON:
2505 action = UM_MASSACTION;
2506 li->type = IDM_SETICON;
2507 break;
2508 case DND_WILDCOPY:
2509 li->type = IDM_WILDCOPY;
2510 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2511 action = UM_MASSACTION;
2512 li->type = IDM_ARCHIVE;
2513 }
2514 break;
2515 case DND_COPY:
2516 li->type = IDM_COPY;
2517 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2518 action = UM_MASSACTION;
2519 li->type = IDM_ARCHIVE;
2520 }
2521 break;
2522 default:
2523 if (*li->arcname && li->info) {
2524 action = UM_MASSACTION;
2525 li->type =
2526 (li->type ==
2527 DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
2528 }
2529 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2530 action = UM_MASSACTION;
2531 li->type =
2532 (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2533 }
2534 else
2535 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2536 break;
2537 }
2538 }
2539 if (!li->list || !li->list[0])
2540 FreeListInfo(li);
2541 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
2542 FreeListInfo(li);
2543 else {
2544 USHORT usop = 0;
2545
2546 switch (li->type) {
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;
2563
2564 case CN_BEGINEDIT:
2565 case CN_REALLOCPSZ:
2566 case CN_ENDEDIT:
2567 {
2568 MRESULT mre;
2569
2570 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
2571 if (mre != (MRESULT) - 1)
2572 return mre;
2573 }
2574 break;
2575
2576 case CN_EMPHASIS:
2577 if (mp2) {
2578 PNOTIFYRECORDEMPHASIS pre = mp2;
2579 PCNRITEM pci;
2580 CHAR s[CCHMAXPATH + 91], tb[81], tf[81], *p;
2581
2582 pci = (PCNRITEM) ((pre) ? pre->pRecord : NULL);
2583 if (!pci) {
2584 if (hwndStatus2)
2585 WinSetWindowText(hwndStatus2, NullStr);
2586 if (fMoreButtons) {
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 }
2595 if (pre->fEmphasisMask & CRA_SELECTED) {
2596 if (pci->rc.flRecordAttr & CRA_SELECTED) {
2597 dcd->selectedbytes += (pci->cbFile + pci->easize);
2598 dcd->selectedfiles++;
2599 }
2600 else if (dcd->selectedfiles) {
2601 dcd->selectedbytes -= (pci->cbFile + pci->easize);
2602 dcd->selectedfiles--;
2603 }
2604 if (!dcd->suspendview) {
2605 commafmt(tf, sizeof(tf), dcd->selectedfiles);
2606 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
2607 sprintf(s, "%s / %s", tf, tb);
2608 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
2609 }
2610 }
2611 if (!dcd->suspendview &&
2612 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
2613 if (pre->fEmphasisMask & CRA_CURSORED) {
2614 if (pci->rc.flRecordAttr & CRA_CURSORED) {
2615 if (fSplitStatus && hwndStatus2) {
2616 if (pci->attrFile & FILE_DIRECTORY)
2617 p = pci->pszFileName;
2618 else {
2619 p = strrchr(pci->pszFileName, '\\');
2620 if (p) {
2621 if (*(p + 1))
2622 p++;
2623 else
2624 p = pci->pszFileName;
2625 }
2626 else
2627 p = pci->pszFileName;
2628 }
2629 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
2630 if (!fMoreButtons)
2631 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
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);
2636 else {
2637 if (pci->cbFile + pci->easize > 1024)
2638 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize,
2639 ' ');
2640 else
2641 *tf = 0;
2642 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
2643 tb,
2644 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
2645 }
2646 WinSetWindowText(hwndStatus2, s);
2647 }
2648 if (fMoreButtons) {
2649 WinSetWindowText(hwndName, pci->pszFileName);
2650 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
2651 pci->date.year, pci->date.month,
2652 pci->date.day, pci->time.hours, pci->time.minutes,
2653 pci->time.seconds);
2654 WinSetWindowText(hwndDate, s);
2655 WinSetWindowText(hwndAttr, pci->pszDispAttr);
2656 }
2657 }
2658 }
2659 }
2660 if (!dcd->suspendview && hwndMain &&
2661 (pre->fEmphasisMask & CRA_CURSORED) &&
2662 (pci->rc.flRecordAttr & CRA_CURSORED) &&
2663 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame)
2664 WinSendMsg(hwndMain, UM_LOADFILE,
2665 MPFROMP(((fComments
2666 || (pci->attrFile & FILE_DIRECTORY) ==
2667 0) ? pci->pszFileName : NULL)), MPVOID);
2668 }
2669 break;
2670
2671 case CN_ENTER:
2672 if (mp2) {
2673 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
2674 FILEFINDBUF3 ffb;
2675 HDIR hDir = HDIR_CREATE;
2676 ULONG nm = 1;
2677 APIRET status = 0;
2678
2679 SetShiftState();
2680 if (pci) {
2681 if (pci->rc.flRecordAttr & CRA_INUSE)
2682 break;
2683 DosError(FERR_DISABLEHARDERR);
2684 status = DosFindFirst(pci->pszFileName, &hDir,
2685 FILE_NORMAL | FILE_DIRECTORY |
2686 FILE_ARCHIVED | FILE_READONLY |
2687 FILE_HIDDEN | FILE_SYSTEM,
2688 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
2689 priority_bumped();
2690 if (!status) {
2691 DosFindClose(hDir);
2692 if (ffb.attrFile & FILE_DIRECTORY) {
2693 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
2694 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0),
2695 MPVOID);
2696 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
2697 (KC_CTRL | KC_SHIFT))
2698 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
2699 else if (shiftstate & KC_CTRL)
2700 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
2701 else
2702 OpenDirCnr(HWND_DESKTOP,
2703 hwndMain,
2704 dcd->hwndFrame, FALSE, pci->pszFileName);
2705 }
2706 else {
2707 SWP swp;
2708
2709 WinSendMsg(hwnd,
2710 CM_SETRECORDEMPHASIS,
2711 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
2712 WinQueryWindowPos(dcd->hwndFrame, &swp);
2713 DefaultViewKeys(hwnd,
2714 dcd->hwndFrame,
2715 dcd->hwndParent, &swp, pci->pszFileName);
2716 WinSendMsg(hwnd,
2717 CM_SETRECORDEMPHASIS,
2718 MPFROMP(pci),
2719 MPFROM2SHORT(FALSE, CRA_INUSE |
2720 ((fUnHilite) ? CRA_SELECTED : 0)));
2721 }
2722 }
2723 else
2724 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
2725 }
2726 }
2727 break;
2728 }
2729 }
2730 return 0;
2731
2732 case UM_LOADFILE:
2733 if (dcd && mp2) {
2734
2735 HWND hwnd;
2736
2737 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
2738 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
2739 (CHAR *)mp2, dcd->hwndFrame);
2740 else
2741 hwnd = StartMLEEditor(dcd->hwndParent,
2742 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
2743 free((CHAR *)mp2);
2744 return MRFROMLONG(hwnd);
2745 }
2746 return 0;
2747
2748 case UM_CLOSE:
2749 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
2750 QW_PARENT));
2751 return 0;
2752
2753 case UM_FOLDUP:
2754 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
2755 DosExit(EXIT_PROCESS, 1);
2756 return 0;
2757
2758 case WM_CLOSE:
2759 if (dcd) {
2760 dcd->namecanchange = TRUE;
2761 dcd->stopflag = 1;
2762 if (dcd->amextracted)
2763 return 0; // Can not close yet
2764 }
2765 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
2766 if (dcd) {
2767 if (!dcd->dontclose && ParentIsDesktop(hwnd, dcd->hwndParent))
2768 PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
2769 if (dcd->hwndObject) {
2770 DosSleep(32); // Allow UM_FOLDUP to process
2771 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
2772 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
2773 }
2774 }
2775 else
2776 WinSendMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
2777 return 0;
2778
2779 case WM_DESTROY:
2780 if (CollectorDirMenu)
2781 WinDestroyWindow(CollectorDirMenu);
2782 if (CollectorFileMenu)
2783 WinDestroyWindow(CollectorFileMenu);
2784 if (CollectorCnrMenu)
2785 WinDestroyWindow(CollectorCnrMenu);
2786 CollectorCnrMenu = CollectorFileMenu = CollectorDirMenu = (HWND) 0;
2787 Collector = (HWND) 0;
2788 EmptyCnr(hwnd);
2789 break;
2790 }
2791 if (dcd && dcd->oldproc){
2792 return dcd->oldproc(hwnd, msg, mp1, mp2);
2793 }
2794 else
2795 return PFNWPCnr(hwnd, msg, mp1, mp2);
2796}
2797
2798MRESULT EXPENTRY CollectorMenuProc(HWND hwnd, ULONG msg, MPARAM mp1,
2799 MPARAM mp2)
2800{
2801 PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
2802 static short sLastMenuitem;
2803
2804 switch (msg) {
2805 case WM_MOUSEMOVE: {
2806 if (fOtherHelp) {
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;
2816
2817
2818 for (i=0; i<MenuItems; i++) {
2819 sCurrentMenuitem = asMenuIDs[i];
2820 oldMenuProc(hwnd,MM_QUERYITEMRECT,
2821 MPFROM2SHORT(asMenuIDs[i], FALSE),
2822 &rectl);
2823
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;
2829 } // for
2830
2831
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 }
2850
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 }
2859 }
2860 }
2861 }
2862 return oldMenuProc(hwnd, msg, mp1, mp2);
2863}
2864
2865HWND StartCollector(HWND hwndParent, INT flags)
2866{
2867 HWND hwndFrame = (HWND) 0;
2868 HWND hwndClient;
2869 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
2870 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
2871 USHORT id;
2872 DIRCNRDATA *dcd;
2873
2874 static USHORT idinc = 0;
2875
2876 if (ParentIsDesktop(hwndParent, hwndParent))
2877 FrameFlags |= (FCF_TASKLIST | FCF_SHELLPOSITION | FCF_MENU);
2878 if (Collector) {
2879 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
2880 QW_PARENT),
2881 QW_PARENT),
2882 HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE);
2883 return WinQueryWindow(WinQueryWindow(Collector, QW_PARENT), QW_PARENT);
2884 }
2885 hwndFrame = WinCreateStdWindow(hwndParent,
2886 WS_VISIBLE,
2887 &FrameFlags,
2888 WC_COLLECTOR,
2889 NULL,
2890 WS_VISIBLE | fwsAnimate,
2891 FM3ModHandle, COLLECTOR_FRAME, &hwndClient);
2892 if (hwndFrame && hwndClient) {
2893 id = COLLECTOR_FRAME + idinc++;
2894 WinSetWindowUShort(hwndFrame, QWS_ID, id);
2895# ifdef FORTIFY
2896 Fortify_EnterScope();
2897# endif
2898 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
2899 if (!dcd) {
2900 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2901 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
2902 hwndFrame = (HWND) 0;
2903 }
2904 else {
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;
2911 if (flags & 4)
2912 dcd->dontclose = TRUE;
2913 {
2914 PFNWP oldproc;
2915
2916 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) CollectorFrameWndProc);
2917 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
2918 }
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);
2936 free(dcd);
2937 hwndFrame = (HWND) 0;
2938 }
2939 else {
2940 Collector = dcd->hwndCnr;
2941 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
2942 WinSetWindowText(hwndFrame, GetPString(IDS_COLLECTORTITLETEXT));
2943 if (FrameFlags & FCF_MENU) {
2944 PFNWP oldmenuproc;
2945 HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
2946
2947 oldmenuproc = WinSubclassWindow(hwndMenu, (PFNWP) CollectorMenuProc);
2948 WinSetWindowPtr(hwndMenu, QWL_USER, (PVOID) oldmenuproc);
2949 if (!fToolbar) {
2950 if (hwndMenu) {
2951
2952 WinSendMsg(hwndMenu,
2953 MM_DELETEITEM,
2954 MPFROM2SHORT(IDM_SEEALL, FALSE), MPVOID);
2955 WinSendMsg(hwndMenu,
2956 MM_DELETEITEM,
2957 MPFROM2SHORT(IDM_GREP, FALSE), MPVOID);
2958 WinSendMsg(hwndMenu,
2959 MM_DELETEITEM,
2960 MPFROM2SHORT(IDM_CLEARCNR, FALSE), MPVOID);
2961 WinSendMsg(hwndMenu,
2962 MM_DELETEITEM,
2963 MPFROM2SHORT(IDM_REMOVE, FALSE), MPVOID);
2964 }
2965 }
2966 }
2967 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
2968 (PFNWP) CollectorCnrWndProc);
2969 {
2970 USHORT ids[] = { DIR_TOTALS,
2971 DIR_SELECTED,
2972 DIR_VIEW,
2973 DIR_SORT,
2974 DIR_FILTER,
2975 0
2976 };
2977
2978 CommonCreateTextChildren(dcd->hwndClient,
2979 WC_COLSTATUS, ids);
2980 }
2981 if (FrameFlags & FCF_SHELLPOSITION)
2982 PostMsg(hwndClient, UM_SIZE, MPVOID, MPVOID);
2983 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
2984 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
2985 }
2986 }
2987# ifdef FORTIFY
2988 DosSleep(1); // Let receiver take ownership
2989 Fortify_LeaveScope();
2990# endif
2991 }
2992 return hwndFrame;
2993}
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.