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