1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: treecnr.c 1819 2015-06-24 03:29:30Z stevenhl $
|
---|
5 |
|
---|
6 | Tree containers
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2001-2012 Steven H. Levine
|
---|
10 |
|
---|
11 | 16 Oct 02 SHL Handle large partitions
|
---|
12 | 11 Jun 03 SHL Add JFS and FAT32 support
|
---|
13 | 25 May 05 SHL Rename comnam to szCommonName and fix typo
|
---|
14 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL
|
---|
15 | 26 May 05 SHL More large file formatting updates
|
---|
16 | 05 Jun 05 SHL Use QWL_USER
|
---|
17 | 06 Aug 05 SHL Renames
|
---|
18 | 08 Dec 05 SHL TreeCnrWndProc: disable menu items if drive not ready
|
---|
19 | 17 Jul 06 SHL Use Runtime_Error
|
---|
20 | 15 Aug 06 SHL Rework SetMask args
|
---|
21 | 31 Aug 06 JS Add more partitioning menu items
|
---|
22 | 22 Oct 06 GKY Add NDFS32 support
|
---|
23 | 29 Dec 06 GKY Fixed menu gray out for remote drives (added variable "remote")
|
---|
24 | 29 Dec 06 GKY Enabled edit of drive flags on "not ready" drives
|
---|
25 | 18 Feb 07 GKY More drive type and icon support
|
---|
26 | 08 Mar 07 SHL Ensure drive icon updates after drive flags change
|
---|
27 | 09 Mar 07 GKY Use SelectDriveIcon
|
---|
28 | 30 Mar 07 GKY Remove GetPString for window class names
|
---|
29 | 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
|
---|
30 | 06 Apr 07 GKY Add some error checking in drag/drop
|
---|
31 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
|
---|
32 | 19 Apr 07 SHL Add more drag/drop error checking
|
---|
33 | 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
|
---|
34 | 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
|
---|
35 | 10 Jun 07 GKY Mouse button 3 white space click to fail silently
|
---|
36 | 05 Jul 07 SHL Disable leftover debug code
|
---|
37 | 02 Aug 07 SHL Sync with CNRITEM mods
|
---|
38 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
---|
39 | 14 Aug 07 SHL Revert ShowTreeRec DosSleep to 0
|
---|
40 | 14 Aug 07 SHL Optimze ShowTreeRec collapse - was really slow
|
---|
41 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
42 | 22 Aug 07 SHL Disable DbgMsgs shipped with 3.0.8beta1
|
---|
43 | 26 Aug 07 SHL Revert to DosSleep(0)
|
---|
44 | 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
|
---|
45 | 10 Jan 08 SHL Sync with CfgDlgProc mods
|
---|
46 | 15 Feb 08 SHL Sync with settings menu rework
|
---|
47 | 15 Feb 08 SHL Avoid death if tree container 0 width
|
---|
48 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory
|
---|
49 | 02 Aug 08 GKY Always pass temp variable point to UM_SHOWME to avoid freeing pci->pszFileName early
|
---|
50 | 19 Oct 08 GKY Fixed logic for greying menu items (Format etc) on remote and virtual drives (it was reversed)
|
---|
51 | 19 Oct 08 GKY Fixed context menu to be "drives" menu on unformatted drives
|
---|
52 | 28 Nov 08 GKY Remove unneeded DosEnterCriSec calls
|
---|
53 | 10 Dec 08 SHL Integrate exception handler support
|
---|
54 | 25 Dec 08 GKY Add code to allow write verify to be turned off on a per drive basis
|
---|
55 | 26 Dec 08 GKY Implemented DROPHELP for the tree container
|
---|
56 | 27 Dec 08 GKY Add refresh removable media to tree container menus
|
---|
57 | 28 Dec 08 GKY Rework partition submenu to gray out unavailable items (check for existence of files)
|
---|
58 | and have no default choice.
|
---|
59 | 01 Jan 09 GKY Add Seek and Scan to drives & directory context menus pass drive/dir as search root
|
---|
60 | 11 Jan 09 GKY Replace font names in the string file with global set at compile in init.c
|
---|
61 | 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
|
---|
62 | 07 Feb 09 GKY Add *DateFormat functions to format dates based on locale
|
---|
63 | 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error
|
---|
64 | 08 Mar 09 GKY Renamed commafmt.h i18nutil.h
|
---|
65 | 08 Mar 09 GKY Additional strings move to PCSZs in init.c
|
---|
66 | 12 Mar 09 SHL Use common SearchContainer
|
---|
67 | 14 Mar 09 GKY Prevent execution of UM_SHOWME while drive scan is occuring
|
---|
68 | 06 Jun 09 GKY Add option to show file system type or drive label in tree
|
---|
69 | 06 Jun 09 GKY Status line to show file sys/label not shown in tree; shortened to fit split status
|
---|
70 | 07 Jun 09 GKY Fixed double names in tree container when collapsed tree is accessed
|
---|
71 | before recursive scan
|
---|
72 | 12 Jul 09 GKY Add option to show file system type or drive label in tree
|
---|
73 | (get NOPRESCAN drives working)
|
---|
74 | 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
|
---|
75 | 22 Jul 09 GKY Consolidated driveflag setting code in DriveFlagsOne
|
---|
76 | 22 Jul 09 GKY Streamline scanning code for faster Tree rescans
|
---|
77 | 14 Sep 09 SHL Drop experimental code
|
---|
78 | 15 Sep 09 SHL Use UM_GREP when passing pathname
|
---|
79 | 15 Nov 09 GKY Add semaphore to fix double names in tree container caused by UM_SHOWME
|
---|
80 | before scan completes
|
---|
81 | 22 Nov 09 GKY Add LVM.EXE to partition submenu
|
---|
82 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast
|
---|
83 | CHAR CONSTANT * as CHAR *.
|
---|
84 | 11 Apr 10 GKY Fix drive tree rescan failure and program hang caused by event sem
|
---|
85 | never being posted
|
---|
86 | 20 Nov 10 GKY Rework scanning code to remove redundant scans, prevent double directory
|
---|
87 | entries in the tree container, fix related semaphore performance using
|
---|
88 | combination of event and mutex semaphores
|
---|
89 | 04 Aug 12 GKY Fix trap reported by Ben
|
---|
90 | 30 Dec 12 GKY Changed refresh removable media to query LVM directly to call Rediscover_PRMs (Ticket 472);
|
---|
91 | Also added a tree rescan following volume detach.
|
---|
92 | 22 Feb 14 GKY Fix warn readonly yes don't ask to work when recursing directories.
|
---|
93 | 07 Sep 14 GKY Fix tree container mis-draws (stacked icons with RWS) The problem was magnified
|
---|
94 | by RWS but I think the occasional extra blank directory or duplicating
|
---|
95 | directories is related.
|
---|
96 | 16 Mar 15 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents
|
---|
97 | a trap when FM2 is shutdown or the container is closed while tree
|
---|
98 | container is still populating
|
---|
99 | 02 May 15 GKY Changes to allow a JAVA executable object to be created using "Real object"
|
---|
100 | menu item on a jar file.
|
---|
101 |
|
---|
102 | ***********************************************************************/
|
---|
103 |
|
---|
104 | #include <stdlib.h>
|
---|
105 | #include <string.h>
|
---|
106 | #include <ctype.h>
|
---|
107 | // #include <process.h> // _beginthread
|
---|
108 |
|
---|
109 | #define INCL_DOS
|
---|
110 | #define INCL_WIN
|
---|
111 | #define INCL_LONGLONG
|
---|
112 | #define INCL_DOSERRORS
|
---|
113 |
|
---|
114 | #include "fm3dll.h"
|
---|
115 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
116 | #include "treecnr.h"
|
---|
117 | #include "mainwnd2.h" // Data declaration(s)
|
---|
118 | #include "grep.h" // Data declaration(s)
|
---|
119 | #include "dircnrs.h" // Data declaration(s)
|
---|
120 | #include "info.h" // Data declaration(s)
|
---|
121 | #include "fm3dlg.h"
|
---|
122 | #include "fm3str.h"
|
---|
123 | #include "mle.h"
|
---|
124 | #include "comp.h" // COMPARE
|
---|
125 | #include "filldir.h" // RemoveCnrItems...
|
---|
126 | #include "errutil.h" // Dos_Error...
|
---|
127 | #include "strutil.h" // GetPString
|
---|
128 | #include "notebook.h" // CfgDlgProc
|
---|
129 | #include "command.h" // RunCommand
|
---|
130 | #include "worker.h" // Action, MassAction
|
---|
131 | #include "mainwnd.h" // BubbleHelp, FindDirCnrByName, GetNextWindowPos
|
---|
132 | #include "misc.h" // CnrDirectEdit, EmphasizeButton, FindDirCnr
|
---|
133 | // FindDirCnr, FixSwitchList, OpenEdit, QuickPopup
|
---|
134 | // SetSortChecks, SwitchCommand, CheckMenu
|
---|
135 | // CurrentRecord, IsFm2Window
|
---|
136 | #include "common.h" // CommonCnrProc, CommonDriveCmd, CommonFrameWndProc
|
---|
137 | // CommonTextProc
|
---|
138 | #include "valid.h" // CheckDrive, DriveFlagsOne, IsValidDrive
|
---|
139 | #include "chklist.h" // DropListProc
|
---|
140 | #include "select.h" // ExpandAll
|
---|
141 | #include "findrec.h" // FindCnrRecord, FindParentRecord, ShowCnrRecord
|
---|
142 | #include "flesh.h" // Flesh, UnFlesh
|
---|
143 | #include "notify.h" // HideNote
|
---|
144 | #include "objwin.h" // MakeObjWin
|
---|
145 | #include "notify.h" // NotifyError
|
---|
146 | #include "remap.h" // RemapDlgProc
|
---|
147 | #include "saveclip.h" // SaveListDlgProc
|
---|
148 | #include "update.h" // SelectDriveIcon, UpdateCnrList, UpdateCnrRecord
|
---|
149 | #include "sortcnr.h" // SortTreeCnr
|
---|
150 | #include "droplist.h" // AcceptOneDrop, CheckPmDrgLimit, DropHelp, GetOneDrop
|
---|
151 | #include "presparm.h" // CopyPresParams
|
---|
152 | #include "defview.h" // DefaultViewKeys
|
---|
153 | #include "draglist.h" // DoFileDrag
|
---|
154 | #include "filter.h" // Filter
|
---|
155 | #include "shadow.h" // OpenObject
|
---|
156 | #include "mkdir.h" // PMMkDir
|
---|
157 | #include "collect.h" // StartCollector
|
---|
158 | #include "viewer.h" // StartMLEEditor
|
---|
159 | #include "newview.h" // StartViewer
|
---|
160 | #include "walkem.h" // WalkAllDlgProc
|
---|
161 | #include "i18nutil.h" // CommaFmtULL
|
---|
162 | #include "wrappers.h" // xDosFindFirst
|
---|
163 | #include "systemf.h" // runemf2
|
---|
164 | #include "dirs.h" // save_dir2
|
---|
165 | #include "fortify.h"
|
---|
166 | #include "init.h" // GetTidForWindow
|
---|
167 | #include "excputil.h" // xbeginthread
|
---|
168 | #include "copyf.h" // ignorereadonly
|
---|
169 |
|
---|
170 | // Data definitions
|
---|
171 |
|
---|
172 | #pragma data_seg(GLOBAL1)
|
---|
173 | HWND LastDir;
|
---|
174 | HWND TreeCnrMenu;
|
---|
175 | INT driveserial[26];
|
---|
176 | BOOL fDCOpens;
|
---|
177 | BOOL fDummy;
|
---|
178 | BOOL fFollowTree;
|
---|
179 | BOOL fTopDir;
|
---|
180 | BOOL fLVMGui;
|
---|
181 | BOOL fDFSee;
|
---|
182 | BOOL fFDisk;
|
---|
183 | BOOL fMiniLVM;
|
---|
184 | BOOL fLVM;
|
---|
185 | HPOINTER hptrDunno;
|
---|
186 | HWND hwndMainMenu;
|
---|
187 |
|
---|
188 | #pragma data_seg(GLOBAL2)
|
---|
189 | ULONG FM3UL;
|
---|
190 | INT TreesortFlags;
|
---|
191 |
|
---|
192 | #pragma data_seg(DATA1)
|
---|
193 |
|
---|
194 | static PSZ pszSrcFile = __FILE__;
|
---|
195 | static BOOL fOkayMinimize;
|
---|
196 |
|
---|
197 | APIRET16 APIENTRY16 Dos16MemAvail(PULONG pulAvailMem);
|
---|
198 |
|
---|
199 | typedef struct APPNOTIFY
|
---|
200 | {
|
---|
201 | HAPP happ;
|
---|
202 | CHAR device;
|
---|
203 | struct APPNOTIFY *next;
|
---|
204 | struct APPNOTIFY *prev;
|
---|
205 | }
|
---|
206 | APPNOTIFY;
|
---|
207 |
|
---|
208 | MRESULT EXPENTRY OpenButtonProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
209 | {
|
---|
210 | static BOOL emphasized = FALSE;
|
---|
211 |
|
---|
212 | switch (msg) {
|
---|
213 | case WM_CREATE:
|
---|
214 | {
|
---|
215 | MRESULT rc;
|
---|
216 |
|
---|
217 | rc = PFNWPButton(hwnd, msg, mp1, mp2);
|
---|
218 | //fixme to allow user to change presparams 1-10-09 GKY
|
---|
219 | WinSetPresParam(hwnd, PP_FONTNAMESIZE,
|
---|
220 | strlen(FNT_8TIMESNEWROMAN) + 1,
|
---|
221 | (PVOID) FNT_8TIMESNEWROMAN);
|
---|
222 | return rc;
|
---|
223 | }
|
---|
224 |
|
---|
225 | case WM_MOUSEMOVE:
|
---|
226 | BubbleHelp(hwnd, TRUE, FALSE, TRUE, GetPString(IDS_OPENBUTTONHELP));
|
---|
227 | break;
|
---|
228 |
|
---|
229 | case WM_CONTEXTMENU:
|
---|
230 | PostMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
231 | WM_COMMAND, MPFROM2SHORT(IDM_OPENWALK, 0), MPVOID);
|
---|
232 | return 0;
|
---|
233 |
|
---|
234 | case DM_DRAGOVER:
|
---|
235 | if (!emphasized) {
|
---|
236 | emphasized = TRUE;
|
---|
237 | EmphasizeButton(hwnd, emphasized);
|
---|
238 | }
|
---|
239 | if (AcceptOneDrop(hwnd, mp1, mp2))
|
---|
240 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
241 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
242 |
|
---|
243 | case DM_DRAGLEAVE:
|
---|
244 | if (emphasized) {
|
---|
245 | emphasized = FALSE;
|
---|
246 | EmphasizeButton(hwnd, emphasized);
|
---|
247 | }
|
---|
248 | break;
|
---|
249 |
|
---|
250 | case DM_DROPHELP:
|
---|
251 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_OPENDROPHELP));
|
---|
252 | return 0;
|
---|
253 |
|
---|
254 | case DM_DROP:
|
---|
255 | {
|
---|
256 | char szFrom[CCHMAXPATH + 2];
|
---|
257 |
|
---|
258 | if (emphasized) {
|
---|
259 | emphasized = FALSE;
|
---|
260 | EmphasizeButton(hwnd, emphasized);
|
---|
261 | }
|
---|
262 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
|
---|
263 | MakeValidDir(szFrom);
|
---|
264 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
265 | UM_OPENWINDOWFORME, MPFROMP(szFrom), MPVOID);
|
---|
266 | }
|
---|
267 | }
|
---|
268 | return 0;
|
---|
269 |
|
---|
270 | }
|
---|
271 | return PFNWPButton(hwnd, msg, mp1, mp2);
|
---|
272 | }
|
---|
273 |
|
---|
274 | VOID ShowTreeRec(HWND hwndCnr,
|
---|
275 | CHAR *dirname,
|
---|
276 | BOOL collapsefirst,
|
---|
277 | BOOL maketop)
|
---|
278 | {
|
---|
279 | /**
|
---|
280 | * Find a record in tree view, move it so it shows in container and
|
---|
281 | * make it the current record
|
---|
282 | */
|
---|
283 |
|
---|
284 | PCNRITEM pci, pciToSelect, pciP;
|
---|
285 | BOOL quickbail = FALSE;
|
---|
286 | CHAR szDir[CCHMAXPATH], *p;
|
---|
287 |
|
---|
288 | // already positioned to requested record?
|
---|
289 | pci = WinSendMsg(hwndCnr,
|
---|
290 | CM_QUERYRECORDEMPHASIS,
|
---|
291 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
---|
292 | if (pci && (INT) pci != -1 && !stricmp(pci->pszFileName, dirname)) {
|
---|
293 | quickbail = TRUE; // Bypass repositioning
|
---|
294 | goto MakeTop;
|
---|
295 | }
|
---|
296 | WinEnableWindowUpdate(hwndCnr, FALSE);
|
---|
297 | pci = FindCnrRecord(hwndCnr, dirname, NULL, TRUE, FALSE, TRUE);
|
---|
298 | if (!pci || (INT) pci == -1) {
|
---|
299 | *szDir = *dirname;
|
---|
300 | szDir[1] = ':';
|
---|
301 | szDir[2] = '\\';
|
---|
302 | szDir[3] = 0;
|
---|
303 | p = szDir + 3; // Point after root backslash
|
---|
304 | for (;;) {
|
---|
305 | pciP = FindCnrRecord(hwndCnr, szDir, NULL, TRUE, FALSE, TRUE);
|
---|
306 | if (pciP && (INT) pciP != -1) {
|
---|
307 | if (!stricmp(dirname, pciP->pszFileName))
|
---|
308 | break; // Found it
|
---|
309 | if (~pciP->rc.flRecordAttr & CRA_EXPANDED)
|
---|
310 | WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciP), MPVOID);
|
---|
311 | strcpy(szDir, dirname);
|
---|
312 | if (p - szDir >= strlen(szDir))
|
---|
313 | break; // Not root dir
|
---|
314 | p = strchr(p, '\\');
|
---|
315 | if (p) {
|
---|
316 | *p = 0; // fixme?
|
---|
317 | p++;
|
---|
318 | }
|
---|
319 | else
|
---|
320 | break;
|
---|
321 | }
|
---|
322 | else
|
---|
323 | break;
|
---|
324 | DosSleep(0);
|
---|
325 | } // for
|
---|
326 | pci = FindCnrRecord(hwndCnr, dirname, NULL, TRUE, FALSE, TRUE);
|
---|
327 | }
|
---|
328 | if (pci && (INT) pci != -1) {
|
---|
329 | if (~pci->rc.flRecordAttr & CRA_CURSORED) {
|
---|
330 | if (collapsefirst) {
|
---|
331 | pciP = WinSendMsg(hwndCnr,
|
---|
332 | CM_QUERYRECORD,
|
---|
333 | MPVOID, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
334 | while (pciP && (INT) pciP != -1) {
|
---|
335 | #if 1 // 05 Jan 08 SHL fixme to be sure this is correct code
|
---|
336 | if (pciP->rc.flRecordAttr & CRA_EXPANDED) {
|
---|
337 | // collapse top level of all branches
|
---|
338 | WinSendMsg(hwndCnr, CM_COLLAPSETREE, MPFROMP(pciP), MPVOID);
|
---|
339 | }
|
---|
340 | #else // fixme to be gone
|
---|
341 | if (toupper(*pciP->pszFileName) == toupper(*dirname)) {
|
---|
342 | // collapse all levels if branch is our drive
|
---|
343 | if (pciP->rc.flRecordAttr & CRA_EXPANDED)
|
---|
344 | ExpandAll(hwndCnr, FALSE, pciP);
|
---|
345 | }
|
---|
346 | else if (pciP->rc.flRecordAttr & CRA_EXPANDED) {
|
---|
347 | // collapse top level of all branches
|
---|
348 | WinSendMsg(hwndCnr, CM_COLLAPSETREE, MPFROMP(pciP), MPVOID);
|
---|
349 | }
|
---|
350 | #endif
|
---|
351 | pciP = WinSendMsg(hwndCnr,
|
---|
352 | CM_QUERYRECORD,
|
---|
353 | MPFROMP(pciP),
|
---|
354 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
355 | } // while
|
---|
356 | }
|
---|
357 | // expand all parent branches
|
---|
358 | pciToSelect = pci;
|
---|
359 | for (;;) {
|
---|
360 | pciP = WinSendMsg(hwndCnr,
|
---|
361 | CM_QUERYRECORD,
|
---|
362 | MPFROMP(pciToSelect),
|
---|
363 | MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
|
---|
364 | if (pciP && (INT) pciP != -1) {
|
---|
365 | if (!(pciP->rc.flRecordAttr & CRA_EXPANDED))
|
---|
366 | WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciP), MPVOID);
|
---|
367 | pciToSelect = pciP;
|
---|
368 | }
|
---|
369 | else
|
---|
370 | break;
|
---|
371 | DosSleep(0); // Let GUI update
|
---|
372 | } // for
|
---|
373 | }
|
---|
374 | // make record visible
|
---|
375 | MakeTop:
|
---|
376 | pciToSelect = pci;
|
---|
377 | if (pciToSelect && (INT) pciToSelect != -1) {
|
---|
378 | //DbgMsg(pszSrcFile, __LINE__, "TOP %i %i", fTopDir, maketop);
|
---|
379 | if (fSwitchTreeExpand && ~pciToSelect->rc.flRecordAttr & CRA_EXPANDED)
|
---|
380 | WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciToSelect), MPVOID);
|
---|
381 | if (fTopDir || maketop) {
|
---|
382 | ShowCnrRecord(hwndCnr, (PMINIRECORDCORE) pciToSelect);
|
---|
383 | }
|
---|
384 | if (!quickbail) {
|
---|
385 | WinSendMsg(hwndCnr,
|
---|
386 | CM_SETRECORDEMPHASIS,
|
---|
387 | MPFROMP(pciToSelect),
|
---|
388 | MPFROM2SHORT(TRUE, CRA_SELECTED | CRA_CURSORED));
|
---|
389 | }
|
---|
390 | }
|
---|
391 | }
|
---|
392 | WinEnableWindowUpdate(hwndCnr, TRUE);
|
---|
393 | }
|
---|
394 |
|
---|
395 | MRESULT EXPENTRY TreeTitleWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
396 | MPARAM mp2)
|
---|
397 | {
|
---|
398 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
399 |
|
---|
400 | switch (msg) {
|
---|
401 | case WM_CONTEXTMENU:
|
---|
402 | return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
403 | UM_CONTEXTMENU, mp1, mp2);
|
---|
404 | }
|
---|
405 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
406 | }
|
---|
407 |
|
---|
408 | MRESULT EXPENTRY TreeStatProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
409 | {
|
---|
410 | switch (msg) {
|
---|
411 | case WM_CREATE:
|
---|
412 | return CommonTextProc(hwnd, msg, mp1, mp2);
|
---|
413 |
|
---|
414 | case WM_CONTEXTMENU:
|
---|
415 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), msg, mp1, mp2);
|
---|
416 | return 0;
|
---|
417 |
|
---|
418 | case WM_PAINT:
|
---|
419 | {
|
---|
420 | MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
421 |
|
---|
422 | PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
|
---|
423 | return mr;
|
---|
424 | }
|
---|
425 |
|
---|
426 | case WM_SETFOCUS:
|
---|
427 | if (mp2)
|
---|
428 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
|
---|
429 | break;
|
---|
430 |
|
---|
431 | case UM_FOCUSME:
|
---|
432 | WinSetFocus(HWND_DESKTOP, WinQueryWindow(hwnd, QW_PARENT));
|
---|
433 | return 0;
|
---|
434 | }
|
---|
435 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
436 | }
|
---|
437 |
|
---|
438 | MRESULT EXPENTRY TreeFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
439 | MPARAM mp2)
|
---|
440 | {
|
---|
441 | switch (msg) {
|
---|
442 | case UM_RESCAN:
|
---|
443 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), msg, mp1, mp2);
|
---|
444 | return 0;
|
---|
445 |
|
---|
446 | case WM_ADJUSTWINDOWPOS:
|
---|
447 | {
|
---|
448 | SWP *pswp;
|
---|
449 |
|
---|
450 | pswp = (SWP *) mp1;
|
---|
451 | if (ParentIsDesktop(hwnd, (HWND) 0)) {
|
---|
452 | if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
|
---|
453 | HideNote();
|
---|
454 | }
|
---|
455 | }
|
---|
456 | break;
|
---|
457 |
|
---|
458 | case WM_TRACKFRAME:
|
---|
459 | if (!fFreeTree && !ParentIsDesktop(hwnd, (HWND) 0)) {
|
---|
460 | switch (SHORT1FROMMP(mp1) & TF_MOVE) {
|
---|
461 | case TF_MOVE:
|
---|
462 | case TF_LEFT:
|
---|
463 | case TF_TOP:
|
---|
464 | case (TF_LEFT | TF_BOTTOM):
|
---|
465 | case (TF_LEFT | TF_TOP):
|
---|
466 | {
|
---|
467 | SWP swp;
|
---|
468 |
|
---|
469 | WinQueryWindowPos(hwnd, &swp);
|
---|
470 | if (!(swp.fl & SWP_ACTIVATE))
|
---|
471 | WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
|
---|
472 | SWP_ZORDER | SWP_ACTIVATE);
|
---|
473 | }
|
---|
474 | return 0;
|
---|
475 | }
|
---|
476 | }
|
---|
477 | break;
|
---|
478 |
|
---|
479 | case WM_CALCFRAMERECT:
|
---|
480 | if (*(ULONG *) realappname != FM3UL) {
|
---|
481 |
|
---|
482 | MRESULT mr;
|
---|
483 | PRECTL prectl;
|
---|
484 |
|
---|
485 | mr = CommonFrameWndProc(TREE_CNR, hwnd, msg, mp1, mp2);
|
---|
486 |
|
---|
487 | /**
|
---|
488 | * Calculate the position of the client rectangle.
|
---|
489 | * Otherwise, we'll see a lot of redraw when we move the
|
---|
490 | * client during WM_FORMATFRAME.
|
---|
491 | */
|
---|
492 |
|
---|
493 | if (mr && mp2) {
|
---|
494 | prectl = (PRECTL) mp1;
|
---|
495 | prectl->yTop -= 22;
|
---|
496 | }
|
---|
497 | return mr;
|
---|
498 | }
|
---|
499 | break;
|
---|
500 |
|
---|
501 | case WM_FORMATFRAME:
|
---|
502 | {
|
---|
503 | SHORT sCount;
|
---|
504 | PSWP pswp, pswpClient, pswpNew;
|
---|
505 |
|
---|
506 | sCount = (SHORT) CommonFrameWndProc(TREE_CNR, hwnd, msg, mp1, mp2);
|
---|
507 |
|
---|
508 | // Reformat the frame to "squeeze" the client
|
---|
509 |
|
---|
510 | pswp = (PSWP) mp1;
|
---|
511 | {
|
---|
512 | SHORT x;
|
---|
513 |
|
---|
514 | for (x = 0; x < sCount; x++) {
|
---|
515 | if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
|
---|
516 | pswpClient = pswp;
|
---|
517 | break;
|
---|
518 | }
|
---|
519 | pswp++;
|
---|
520 | }
|
---|
521 | }
|
---|
522 | pswpNew = (PSWP) mp1 + sCount;
|
---|
523 | *pswpNew = *pswpClient;
|
---|
524 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_STATUS);
|
---|
525 | if (*(ULONG *) realappname == FM3UL) {
|
---|
526 |
|
---|
527 | PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
|
---|
528 | SHORT x;
|
---|
529 |
|
---|
530 | pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWINDOW);
|
---|
531 | pswp = (PSWP) mp1;
|
---|
532 | for (x = 0; x < sCount; x++) {
|
---|
533 | if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
|
---|
534 | pswpTitlebar = pswp;
|
---|
535 | else if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
|
---|
536 | pswpMinbutton = pswp;
|
---|
537 | if (pswpTitlebar && pswpMinbutton)
|
---|
538 | break;
|
---|
539 | pswp++;
|
---|
540 | }
|
---|
541 | pswpNew->cy = pswpMinbutton->cy + 3;
|
---|
542 | pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
|
---|
543 | pswpTitlebar->cx -= (pswpNew->cx + 1);
|
---|
544 | pswpNew->x = pswpTitlebar->x + pswpTitlebar->cx;
|
---|
545 | pswpNew->y = pswpMinbutton->y - 1;
|
---|
546 | }
|
---|
547 | else {
|
---|
548 | pswpNew->x = pswpClient->x + 3;
|
---|
549 | pswpNew->y = (pswpClient->y + pswpClient->cy) - 20;
|
---|
550 | pswpNew->cx = pswpClient->cx - 6;
|
---|
551 | pswpNew->cy = 18;
|
---|
552 | pswpClient->cy -= 22;
|
---|
553 | }
|
---|
554 | sCount++;
|
---|
555 | return MRFROMSHORT(sCount);
|
---|
556 | }
|
---|
557 |
|
---|
558 | case WM_QUERYFRAMECTLCOUNT:
|
---|
559 | {
|
---|
560 | SHORT sCount;
|
---|
561 |
|
---|
562 | sCount = (SHORT) CommonFrameWndProc(TREE_CNR, hwnd, msg, mp1, mp2);
|
---|
563 | sCount++;
|
---|
564 | return MRFROMSHORT(sCount);
|
---|
565 | }
|
---|
566 | }
|
---|
567 | return CommonFrameWndProc(TREE_CNR, hwnd, msg, mp1, mp2);
|
---|
568 | }
|
---|
569 |
|
---|
570 | MRESULT EXPENTRY TreeClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
571 | MPARAM mp2)
|
---|
572 | {
|
---|
573 | switch (msg) {
|
---|
574 | case UM_CONTAINERHWND:
|
---|
575 | return MRFROMLONG(WinWindowFromID(hwnd, TREE_CNR));
|
---|
576 |
|
---|
577 | case UM_VIEWSMENU:
|
---|
578 | return MRFROMLONG(CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP));
|
---|
579 |
|
---|
580 | case UM_TIMER:
|
---|
581 | case UM_ACTION:
|
---|
582 | case UM_SHOWME:
|
---|
583 | case UM_OPENWINDOWFORME:
|
---|
584 | case UM_MINIMIZE:
|
---|
585 | case UM_MAXIMIZE:
|
---|
586 | case WM_INITMENU:
|
---|
587 | case UM_INITMENU:
|
---|
588 | case UM_FILTER:
|
---|
589 | case UM_FILESMENU:
|
---|
590 | case UM_UPDATERECORD:
|
---|
591 | case UM_UPDATERECORDLIST:
|
---|
592 | case MM_PORTHOLEINIT:
|
---|
593 | case UM_DRIVECMD:
|
---|
594 | case WM_CLOSE:
|
---|
595 | case WM_CONTROL:
|
---|
596 | case UM_COMMAND:
|
---|
597 | case WM_COMMAND:
|
---|
598 | return WinSendMsg(WinWindowFromID(hwnd, TREE_CNR), msg, mp1, mp2);
|
---|
599 |
|
---|
600 | case WM_PSETFOCUS:
|
---|
601 | case WM_SETFOCUS:
|
---|
602 | if (mp2)
|
---|
603 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
|
---|
604 | break;
|
---|
605 |
|
---|
606 | case UM_FOCUSME:
|
---|
607 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, TREE_CNR));
|
---|
608 | break;
|
---|
609 |
|
---|
610 | case WM_ERASEBACKGROUND:
|
---|
611 | WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
|
---|
612 | return 0;
|
---|
613 |
|
---|
614 | case WM_PAINT:
|
---|
615 | {
|
---|
616 | HPS hps;
|
---|
617 | RECTL rcl;
|
---|
618 |
|
---|
619 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
|
---|
620 | if (hps) {
|
---|
621 | WinQueryWindowRect(hwnd, &rcl);
|
---|
622 | WinFillRect(hps, &rcl, CLR_PALEGRAY);
|
---|
623 | PaintRecessedWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
624 | MAIN_STATUS), hps, FALSE, FALSE);
|
---|
625 | WinEndPaint(hps);
|
---|
626 | }
|
---|
627 | }
|
---|
628 | break;
|
---|
629 |
|
---|
630 | case WM_SIZE:
|
---|
631 | WinSetWindowPos(WinWindowFromID(hwnd, TREE_CNR),
|
---|
632 | HWND_TOP,
|
---|
633 | 0,
|
---|
634 | 0,
|
---|
635 | SHORT1FROMMP(mp2),
|
---|
636 | SHORT2FROMMP(mp2), SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
637 | if (hwndMain)
|
---|
638 | PostMsg(hwndMain, UM_SIZE, MPVOID, MPVOID);
|
---|
639 | break;
|
---|
640 |
|
---|
641 | case WM_CONTEXTMENU:
|
---|
642 | case UM_CONTEXTMENU:
|
---|
643 | PostMsg(WinWindowFromID(hwnd, TREE_CNR),
|
---|
644 | WM_CONTROL, MPFROM2SHORT(TREE_CNR, CN_CONTEXTMENU), MPVOID);
|
---|
645 | return 0;
|
---|
646 | }
|
---|
647 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
648 | }
|
---|
649 |
|
---|
650 | MRESULT EXPENTRY TreeObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
651 | {
|
---|
652 | DIRCNRDATA *dcd;
|
---|
653 |
|
---|
654 | switch (msg) {
|
---|
655 | case UM_SHOWME:
|
---|
656 | if (mp1) {
|
---|
657 | # ifdef FORTIFY
|
---|
658 | Fortify_BecomeOwner(mp1);
|
---|
659 | # endif
|
---|
660 | dcd = INSTDATA(hwnd);
|
---|
661 | if (dcd) {
|
---|
662 | BOOL tempsusp, tempfollow, temptop;
|
---|
663 |
|
---|
664 | DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT);
|
---|
665 | tempsusp = dcd->suspendview;
|
---|
666 | dcd->suspendview = TRUE;
|
---|
667 | tempfollow = fFollowTree;
|
---|
668 | fFollowTree = FALSE;
|
---|
669 | if (mp2) {
|
---|
670 | temptop = fTopDir;
|
---|
671 | fTopDir = TRUE;
|
---|
672 | }
|
---|
673 | ShowTreeRec(dcd->hwndCnr, (CHAR *)mp1, fCollapseFirst, TRUE);
|
---|
674 | PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
|
---|
675 | dcd->suspendview = (USHORT) tempsusp;
|
---|
676 | fFollowTree = tempfollow;
|
---|
677 | if (mp2)
|
---|
678 | fTopDir = temptop;
|
---|
679 | }
|
---|
680 | free((CHAR *)mp1);
|
---|
681 | }
|
---|
682 | return 0;
|
---|
683 |
|
---|
684 | case DM_PRINTOBJECT:
|
---|
685 | return MRFROMLONG(DRR_TARGET);
|
---|
686 |
|
---|
687 | case DM_DISCARDOBJECT:
|
---|
688 | dcd = INSTDATA(hwnd);
|
---|
689 | if (fFM2Deletes && dcd) {
|
---|
690 |
|
---|
691 | LISTINFO *li;
|
---|
692 | CNRDRAGINFO cni;
|
---|
693 |
|
---|
694 | cni.pRecord = NULL;
|
---|
695 | cni.pDragInfo = (PDRAGINFO) mp1;
|
---|
696 | li = DoFileDrop(dcd->hwndCnr,
|
---|
697 | dcd->directory, FALSE, MPVOID, MPFROMP(&cni));
|
---|
698 | CheckPmDrgLimit(cni.pDragInfo);
|
---|
699 | if (li) {
|
---|
700 | li->type = ((fDefaultDeletePerm) ? IDM_PERMDELETE : IDM_DELETE);
|
---|
701 | if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
|
---|
702 | FreeListInfo(li);
|
---|
703 | else
|
---|
704 | return MRFROMLONG(DRR_SOURCE);
|
---|
705 | }
|
---|
706 | }
|
---|
707 | return MRFROMLONG(DRR_TARGET);
|
---|
708 |
|
---|
709 | case UM_EXPAND:
|
---|
710 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
711 | if (!dcd)
|
---|
712 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
713 | else {
|
---|
714 | BOOL tempsusp = dcd->suspendview;
|
---|
715 |
|
---|
716 | dcd->suspendview = TRUE;
|
---|
717 | ExpandAll(dcd->hwndCnr,
|
---|
718 | (SHORT1FROMMP(mp1) == IDM_EXPAND), (PCNRITEM) mp2);
|
---|
719 | DosSleep(1); // Fixes tree epansion (dir text and icons all placed on
|
---|
720 | // the same line as the drive) failure on startup using RWS
|
---|
721 | dcd->suspendview = (USHORT) tempsusp;
|
---|
722 | PostMsg(dcd->hwndCnr, UM_FILTER, MPVOID, MPVOID);
|
---|
723 | }
|
---|
724 | return 0;
|
---|
725 |
|
---|
726 | case UM_UPDATERECORDLIST:
|
---|
727 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
728 | if (!dcd || !mp1)
|
---|
729 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
730 | else {
|
---|
731 | INT numentries = 0;
|
---|
732 | CHAR **list = (CHAR **) mp1;
|
---|
733 |
|
---|
734 | while (list[numentries])
|
---|
735 | numentries++;
|
---|
736 | if (numentries)
|
---|
737 | UpdateCnrList(dcd->hwndCnr, list, numentries, TRUE, dcd);
|
---|
738 | }
|
---|
739 | return 0;
|
---|
740 |
|
---|
741 | case UM_SETUP:
|
---|
742 | # ifdef FORTIFY
|
---|
743 | Fortify_EnterScope();
|
---|
744 | # endif
|
---|
745 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
746 | if (!dcd)
|
---|
747 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
748 | else {
|
---|
749 | # ifdef FORTIFY
|
---|
750 | Fortify_BecomeOwner(dcd);
|
---|
751 | # endif
|
---|
752 | dcd->hwndObject = hwnd;
|
---|
753 | if (ParentIsDesktop(hwnd, dcd->hwndParent))
|
---|
754 | DosSleep(100); //05 Aug 07 GKY 250
|
---|
755 | }
|
---|
756 | return 0;
|
---|
757 |
|
---|
758 | case UM_RESCAN2:
|
---|
759 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
760 | if (!dcd)
|
---|
761 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
762 | // Bypass if not running integrated (i.e if vtree)
|
---|
763 | else if (hwndStatus &&
|
---|
764 | dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
|
---|
765 | CHAR s[CCHMAXPATH * 2];
|
---|
766 | PCNRITEM pci = (PCNRITEM) mp1;
|
---|
767 | FSALLOCATE fsa;
|
---|
768 | struct
|
---|
769 | {
|
---|
770 | ULONG serial;
|
---|
771 | CHAR volumelength;
|
---|
772 | CHAR volumelabel[CCHMAXPATH];
|
---|
773 | }
|
---|
774 | volser;
|
---|
775 | CHAR tb[64];
|
---|
776 | CHAR szFree[64];
|
---|
777 | CNRINFO cnri;
|
---|
778 | CHAR FileSystem[CCHMAXPATH * 2];
|
---|
779 | CHAR szTmpLabel[CCHMAXPATH];
|
---|
780 | ULONG type;
|
---|
781 |
|
---|
782 | strcpy(s, GetPString(IDS_TREETEXT));
|
---|
783 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
784 | cnri.cb = sizeof(CNRINFO);
|
---|
785 | WinSendMsg(dcd->hwndCnr,
|
---|
786 | CM_QUERYCNRINFO,
|
---|
787 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
788 | if (cnri.cRecords) {
|
---|
789 | sprintf(s, GetPString(IDS_NUMDRIVESTEXT), cnri.cRecords);
|
---|
790 | if (pci && (INT) pci != -1 && pci->pszFileName) { //fixme? will try checking pci->pszFileName instead of the pointer
|
---|
791 | if (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
|
---|
792 | DRIVE_REMOVABLE) ||
|
---|
793 | driveserial[toupper(*pci->pszFileName) - 'A'] != -1) {
|
---|
794 | memset(&volser, 0, sizeof(volser));
|
---|
795 | DosError(FERR_DISABLEHARDERR);
|
---|
796 | if (!DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
|
---|
797 | FSIL_VOLSER,
|
---|
798 | &volser,
|
---|
799 | (ULONG) sizeof(volser)) &&
|
---|
800 | dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
|
---|
801 | DosError(FERR_DISABLEHARDERR);
|
---|
802 | if (!DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
|
---|
803 | FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
|
---|
804 | CommaFmtULL(tb, sizeof(tb),
|
---|
805 | (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit *
|
---|
806 | fsa.cbSector), 'M');
|
---|
807 | sprintf(szFree, " %s %s", tb, GetPString(IDS_FREETEXT));
|
---|
808 | }
|
---|
809 | else
|
---|
810 | *szFree = 0;
|
---|
811 | //Show information on status line not shown in the tree container
|
---|
812 | driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
|
---|
813 | if (CheckDrive(toupper(*pci->pszFileName), FileSystem, &type) == -1 ||
|
---|
814 | fShowFSTypeInTree)
|
---|
815 | strcpy(FileSystem, NullStr);
|
---|
816 | if (fShowDriveLabelInTree)
|
---|
817 | strcpy(szTmpLabel, NullStr);
|
---|
818 | else
|
---|
819 | strcpy(szTmpLabel, volser.volumelabel);
|
---|
820 | if (fSplitStatus) {
|
---|
821 | CHAR temp[CCHMAXPATH] = " [";
|
---|
822 |
|
---|
823 | strcat(temp, s);
|
---|
824 | strcat(temp, "]");
|
---|
825 | sprintf(s,
|
---|
826 | GetPString(fShowFSTypeInTree ? IDS_TREESTATUSSTART1TEXT :
|
---|
827 | fShowDriveLabelInTree ? IDS_TREESTATUSSTART2TEXT :
|
---|
828 | IDS_TREESTATUSSTARTTEXT), toupper(*pci->pszFileName),
|
---|
829 | FileSystem, szTmpLabel, volser.serial, szFree);
|
---|
830 | strcat(s, temp);
|
---|
831 | }
|
---|
832 | else {
|
---|
833 | strcat(s, " [");
|
---|
834 | sprintf(&s[strlen(s)],
|
---|
835 | GetPString(fShowFSTypeInTree ? IDS_TREESTATUSSTART1TEXT :
|
---|
836 | fShowDriveLabelInTree ? IDS_TREESTATUSSTART2TEXT :
|
---|
837 | IDS_TREESTATUSSTARTTEXT), toupper(*pci->pszFileName),
|
---|
838 | FileSystem, szTmpLabel, volser.serial, szFree);
|
---|
839 | strcat(s, "]");
|
---|
840 | }
|
---|
841 | if (!fMoreButtons) {
|
---|
842 | if (*dcd->mask.szMask ||
|
---|
843 | (dcd->mask.attrFile != ALLATTRS ||
|
---|
844 | ((fFilesInTree ||
|
---|
845 | (driveflags[toupper(*pci->pszFileName)] &
|
---|
846 | DRIVE_INCLUDEFILES)) ?
|
---|
847 | dcd->mask.antiattr :
|
---|
848 | (dcd->mask.antiattr &&
|
---|
849 | dcd->mask.antiattr != FILE_DIRECTORY)))) {
|
---|
850 | sprintf(&s[strlen(s)],
|
---|
851 | " (%s)",
|
---|
852 | (*dcd->mask.szMask) ?
|
---|
853 | dcd->mask.szMask : GetPString(IDS_ATTRTEXT));
|
---|
854 | }
|
---|
855 | }
|
---|
856 | }
|
---|
857 | }
|
---|
858 | else {
|
---|
859 | // find root record and strip it
|
---|
860 | pci = FindParentRecord(dcd->hwndCnr, pci);
|
---|
861 | driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
|
---|
862 | UnFlesh(dcd->hwndCnr, pci);
|
---|
863 | }
|
---|
864 | }
|
---|
865 | }
|
---|
866 | // 21 Sep 09 SHL fixme to know why checking again - focus change?
|
---|
867 | if (dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
|
---|
868 | WinSetWindowText(hwndStatus, s);
|
---|
869 | }
|
---|
870 | return 0;
|
---|
871 |
|
---|
872 | case UM_RESCAN:
|
---|
873 | // populate container
|
---|
874 | DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT);
|
---|
875 | DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
|
---|
876 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
877 | if (!dcd)
|
---|
878 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
879 | else {
|
---|
880 | RemoveCnrItems(dcd->hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
|
---|
881 | WinSendMsg(dcd->hwndCnr,
|
---|
882 | CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-1));
|
---|
883 | WinSendMsg(dcd->hwndCnr,
|
---|
884 | CM_SCROLLWINDOW,
|
---|
885 | MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(-1));
|
---|
886 | FillTreeCnr(dcd->hwndCnr, dcd->hwndParent);
|
---|
887 | if (fOkayMinimize) {
|
---|
888 | PostMsg(dcd->hwndCnr, UM_MINIMIZE, MPVOID, MPVOID);
|
---|
889 | fOkayMinimize = FALSE;
|
---|
890 | }
|
---|
891 | WinSendMsg(dcd->hwndCnr,
|
---|
892 | CM_INVALIDATERECORD,
|
---|
893 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
---|
894 | PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
895 | }
|
---|
896 | return 0;
|
---|
897 |
|
---|
898 | case UM_COMMAND:
|
---|
899 | if (mp1) {
|
---|
900 |
|
---|
901 | LISTINFO *li = (LISTINFO *) mp1;
|
---|
902 |
|
---|
903 | switch (li->type) {
|
---|
904 | case IDM_DOITYOURSELF:
|
---|
905 | case IDM_APPENDTOCLIP:
|
---|
906 | case IDM_SAVETOCLIP:
|
---|
907 | case IDM_ARCHIVE:
|
---|
908 | case IDM_VIEW:
|
---|
909 | case IDM_EDIT:
|
---|
910 | case IDM_OBJECT:
|
---|
911 | case IDM_SHADOW:
|
---|
912 | case IDM_SHADOW2:
|
---|
913 | case IDM_JAVAEXE:
|
---|
914 | case IDM_PRINT:
|
---|
915 | case IDM_ATTRS:
|
---|
916 | case IDM_DELETE:
|
---|
917 | case IDM_PERMDELETE:
|
---|
918 | if (li->type == IDM_DELETE)
|
---|
919 | ignorereadonly = FALSE;
|
---|
920 | if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
|
---|
921 | return (MRESULT) TRUE;
|
---|
922 | default:
|
---|
923 | if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
|
---|
924 | return (MRESULT) TRUE;
|
---|
925 | }
|
---|
926 | }
|
---|
927 | return 0;
|
---|
928 |
|
---|
929 | case UM_MASSACTION:
|
---|
930 | if (mp1) {
|
---|
931 |
|
---|
932 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
933 | if (!dcd)
|
---|
934 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
935 | else {
|
---|
936 | WORKER *wk;
|
---|
937 | # ifdef FORTIFY
|
---|
938 | Fortify_EnterScope();
|
---|
939 | # endif
|
---|
940 | wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
|
---|
941 | if (!wk)
|
---|
942 | FreeListInfo((LISTINFO *) mp1);
|
---|
943 | else {
|
---|
944 | wk->size = sizeof(WORKER);
|
---|
945 | wk->hwndCnr = dcd->hwndCnr;
|
---|
946 | wk->hwndParent = dcd->hwndParent;
|
---|
947 | wk->hwndFrame = dcd->hwndFrame;
|
---|
948 | wk->hwndClient = dcd->hwndClient;
|
---|
949 | wk->li = (LISTINFO *) mp1;
|
---|
950 | strcpy(wk->directory, dcd->directory);
|
---|
951 | if (xbeginthread(MassAction,
|
---|
952 | 122880,
|
---|
953 | wk,
|
---|
954 | pszSrcFile,
|
---|
955 | __LINE__) == -1)
|
---|
956 | {
|
---|
957 | free(wk);
|
---|
958 | FreeListInfo((LISTINFO *) mp1);
|
---|
959 | }
|
---|
960 | }
|
---|
961 | # ifdef FORTIFY
|
---|
962 | Fortify_LeaveScope();
|
---|
963 | # endif
|
---|
964 | }
|
---|
965 | }
|
---|
966 | return 0;
|
---|
967 |
|
---|
968 | case UM_ACTION:
|
---|
969 | # ifdef FORTIFY
|
---|
970 | Fortify_EnterScope();
|
---|
971 | # endif
|
---|
972 | if (mp1) {
|
---|
973 | # ifdef FORTIFY
|
---|
974 | Fortify_BecomeOwner(mp1);
|
---|
975 | # endif
|
---|
976 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
977 | if (!dcd)
|
---|
978 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
979 | else {
|
---|
980 | WORKER *wk;
|
---|
981 | wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
|
---|
982 | if (!wk)
|
---|
983 | FreeListInfo((LISTINFO *) mp1);
|
---|
984 | else {
|
---|
985 | wk->size = sizeof(WORKER);
|
---|
986 | wk->hwndCnr = dcd->hwndCnr;
|
---|
987 | wk->hwndParent = dcd->hwndParent;
|
---|
988 | wk->hwndFrame = dcd->hwndFrame;
|
---|
989 | wk->hwndClient = dcd->hwndClient;
|
---|
990 | wk->li = (LISTINFO *) mp1;
|
---|
991 | strcpy(wk->directory, dcd->directory);
|
---|
992 | if (xbeginthread(Action,
|
---|
993 | 122880,
|
---|
994 | wk,
|
---|
995 | pszSrcFile,
|
---|
996 | __LINE__) == -1)
|
---|
997 | {
|
---|
998 | free(wk);
|
---|
999 | FreeListInfo((LISTINFO *) mp1);
|
---|
1000 | }
|
---|
1001 | }
|
---|
1002 | }
|
---|
1003 | }
|
---|
1004 | # ifdef FORTIFY
|
---|
1005 | Fortify_LeaveScope();
|
---|
1006 | # endif
|
---|
1007 | return 0;
|
---|
1008 |
|
---|
1009 | case WM_CLOSE:
|
---|
1010 | WinDestroyWindow(hwnd);
|
---|
1011 | break;
|
---|
1012 |
|
---|
1013 | case WM_DESTROY:
|
---|
1014 | hwndTree = (HWND) 0;
|
---|
1015 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
1016 | if (dcd) {
|
---|
1017 | WinSendMsg(dcd->hwndCnr,
|
---|
1018 | UM_CLOSE, MPFROMLONG(dcd->dontclose != FALSE), MPVOID);
|
---|
1019 | WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL); // 13 Apr 10 SHL Set NULL before freeing dcd
|
---|
1020 | free(dcd);
|
---|
1021 | # ifdef FORTIFY
|
---|
1022 | Fortify_LeaveScope();
|
---|
1023 | # endif
|
---|
1024 | }
|
---|
1025 | DosPostEventSem(CompactSem);
|
---|
1026 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
1027 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
1028 | break;
|
---|
1029 | }
|
---|
1030 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 | MRESULT EXPENTRY TreeCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1034 | {
|
---|
1035 | static APPNOTIFY *apphead = NULL, *apptail = NULL;
|
---|
1036 | DIRCNRDATA *dcd = INSTDATA(hwnd);
|
---|
1037 | PCNRITEM pci;
|
---|
1038 |
|
---|
1039 | switch (msg) {
|
---|
1040 | case DM_PRINTOBJECT:
|
---|
1041 | return MRFROMLONG(DRR_TARGET);
|
---|
1042 |
|
---|
1043 | case DM_DISCARDOBJECT:
|
---|
1044 | if (dcd)
|
---|
1045 | return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
|
---|
1046 | else
|
---|
1047 | return MRFROMLONG(DRR_TARGET);
|
---|
1048 |
|
---|
1049 | case WM_CHAR:
|
---|
1050 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
1051 | if (SHORT1FROMMP(mp1) & KC_KEYUP)
|
---|
1052 | return (MRESULT) TRUE;
|
---|
1053 | if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
|
---|
1054 | switch (SHORT2FROMMP(mp2)) {
|
---|
1055 | case VK_INSERT:
|
---|
1056 | if ((shiftstate & KC_CTRL) == KC_CTRL)
|
---|
1057 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
|
---|
1058 | break;
|
---|
1059 | case VK_DELETE:
|
---|
1060 | if ((shiftstate & KC_CTRL) == KC_CTRL)
|
---|
1061 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
|
---|
1062 | else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
|
---|
1063 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
|
---|
1064 | else
|
---|
1065 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
|
---|
1066 | break;
|
---|
1067 | } // switch
|
---|
1068 | }
|
---|
1069 |
|
---|
1070 | if (SearchContainer(hwnd, msg, mp1, mp2))
|
---|
1071 | return (MRESULT)TRUE; // Avoid default handler
|
---|
1072 |
|
---|
1073 | break; // Let default handler see key
|
---|
1074 |
|
---|
1075 | case WM_MOUSEMOVE:
|
---|
1076 | case WM_BUTTON1UP:
|
---|
1077 | case WM_BUTTON2UP:
|
---|
1078 | case WM_BUTTON3UP:
|
---|
1079 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
1080 | break;
|
---|
1081 |
|
---|
1082 | case UM_TIMER:
|
---|
1083 | if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent) &&
|
---|
1084 | hwndStatus2) {
|
---|
1085 | FILEFINDBUF3L ffb;
|
---|
1086 | ULONG nm = 1;
|
---|
1087 | HDIR hdir = HDIR_CREATE;
|
---|
1088 |
|
---|
1089 | if (*SwapperDat) {
|
---|
1090 | if (!xDosFindFirst(SwapperDat,
|
---|
1091 | &hdir,
|
---|
1092 | FILE_NORMAL | FILE_HIDDEN |
|
---|
1093 | FILE_SYSTEM | FILE_ARCHIVED | FILE_READONLY,
|
---|
1094 | &ffb, sizeof(ffb), &nm, FIL_STANDARDL)) {
|
---|
1095 | CHAR tb[39], tm[39], tpm[39], s[163];
|
---|
1096 | ULONG amem;
|
---|
1097 |
|
---|
1098 | priority_bumped();
|
---|
1099 | DosFindClose(hdir);
|
---|
1100 | if (!DosQuerySysInfo(QSV_TOTAVAILMEM,
|
---|
1101 | QSV_TOTAVAILMEM,
|
---|
1102 | (PVOID) & amem, sizeof(amem))) {
|
---|
1103 | CommaFmtULL(tpm, sizeof(tpm), amem, 'M');
|
---|
1104 | }
|
---|
1105 | else
|
---|
1106 | *tpm = 0;
|
---|
1107 | if (!Dos16MemAvail(&amem))
|
---|
1108 | CommaFmtULL(tm, sizeof(tm), amem, 'M');
|
---|
1109 | else
|
---|
1110 | *tm = 0;
|
---|
1111 | CommaFmtULL(tb, sizeof(tb), ffb.cbFile, 'M');
|
---|
1112 | sprintf(s, " %s %s%s%s%s%s",
|
---|
1113 | GetPString(IDS_SWAPFILETEXT),
|
---|
1114 | tb,
|
---|
1115 | *tm ? GetPString(IDS_TREEMEMTEXT) : NullStr,
|
---|
1116 | tm, *tpm ? "/" : NullStr, tpm);
|
---|
1117 | WinSetWindowText(hwndStatus2, s);
|
---|
1118 | }
|
---|
1119 | else
|
---|
1120 | WinSetWindowText(hwndStatus2, NullStr);
|
---|
1121 | }
|
---|
1122 | else
|
---|
1123 | WinSetWindowText(hwndStatus2, NullStr);
|
---|
1124 | }
|
---|
1125 | // 13 Jul 09 SHL fixme to make sense
|
---|
1126 | if (msg == UM_TIMER)
|
---|
1127 | return 0;
|
---|
1128 | break;
|
---|
1129 |
|
---|
1130 | case WM_PRESPARAMCHANGED:
|
---|
1131 | PresParamChanged(hwnd, PCSZ_TREECNR, mp1, mp2);
|
---|
1132 | break;
|
---|
1133 |
|
---|
1134 | case UM_FILESMENU:
|
---|
1135 | {
|
---|
1136 | HWND menuHwnd = (HWND) 0;
|
---|
1137 | FSALLOCATE fsa;
|
---|
1138 |
|
---|
1139 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
1140 | if (pci && (INT) pci != -1) {
|
---|
1141 | if (IsRoot(pci->pszFileName) || !DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
|
---|
1142 | FSIL_ALLOC, &fsa,
|
---|
1143 | sizeof(FSALLOCATE)))
|
---|
1144 | menuHwnd = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
|
---|
1145 | else {
|
---|
1146 | menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
|
---|
1147 | // WinEnableMenuItem(DirMenu,
|
---|
1148 | // IDM_TREE,
|
---|
1149 | // FALSE);
|
---|
1150 | }
|
---|
1151 | if (!(pci->attrFile & FILE_DIRECTORY))
|
---|
1152 | menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
|
---|
1153 | }
|
---|
1154 | return MRFROMLONG(menuHwnd);
|
---|
1155 | }
|
---|
1156 |
|
---|
1157 | case UM_COMPARE:
|
---|
1158 | if (dcd && mp1 && mp2) {
|
---|
1159 |
|
---|
1160 | COMPARE *cmp;
|
---|
1161 | CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
|
---|
1162 |
|
---|
1163 | if (!IsFile(leftdir) && !IsFile(rightdir)) {
|
---|
1164 | cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
|
---|
1165 | if (cmp) {
|
---|
1166 | cmp->size = sizeof(COMPARE);
|
---|
1167 | strcpy(cmp->leftdir, leftdir);
|
---|
1168 | strcpy(cmp->rightdir, rightdir);
|
---|
1169 | cmp->hwndParent = dcd->hwndParent;
|
---|
1170 | cmp->dcd.hwndParent = dcd->hwndParent;
|
---|
1171 | WinDlgBox(HWND_DESKTOP,
|
---|
1172 | HWND_DESKTOP,
|
---|
1173 | CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
|
---|
1174 | }
|
---|
1175 | }
|
---|
1176 | }
|
---|
1177 | return 0;
|
---|
1178 |
|
---|
1179 | case UM_UPDATERECORDLIST:
|
---|
1180 | if (dcd && mp1)
|
---|
1181 | WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
|
---|
1182 | return 0;
|
---|
1183 |
|
---|
1184 | case UM_UPDATERECORD:
|
---|
1185 | if (dcd && mp1) {
|
---|
1186 | CHAR *filename;
|
---|
1187 | filename = mp1;
|
---|
1188 | if (filename) {
|
---|
1189 | UpdateCnrRecord(hwnd, filename, TRUE, dcd);
|
---|
1190 | }
|
---|
1191 | }
|
---|
1192 | return 0;
|
---|
1193 |
|
---|
1194 | case WM_SETFOCUS:
|
---|
1195 | if (dcd && hwndStatus && mp2) {
|
---|
1196 | WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1197 | if (hwndMain)
|
---|
1198 | PostMsg(hwndMain, UM_ADVISEFOCUS, MPFROMLONG(dcd->hwndFrame), MPVOID);
|
---|
1199 | }
|
---|
1200 | break;
|
---|
1201 |
|
---|
1202 | case UM_RESCAN:
|
---|
1203 |
|
---|
1204 | if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
|
---|
1205 | // put name of our window on status line
|
---|
1206 |
|
---|
1207 | PCNRITEM pci = NULL;
|
---|
1208 | CHAR str[CCHMAXPATH + 6];
|
---|
1209 |
|
---|
1210 | if (fAutoView && hwndMain) {
|
---|
1211 | pci = WinSendMsg(hwnd,
|
---|
1212 | CM_QUERYRECORDEMPHASIS,
|
---|
1213 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
---|
1214 | if (pci && (INT) pci != -1 && fComments &&
|
---|
1215 | !(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW))
|
---|
1216 | WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
|
---|
1217 | else
|
---|
1218 | WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
|
---|
1219 | }
|
---|
1220 | if (!fAutoView || !hwndMain)
|
---|
1221 | pci = (PCNRITEM) WinSendMsg(hwnd,
|
---|
1222 | CM_QUERYRECORDEMPHASIS,
|
---|
1223 | MPFROMLONG(CMA_FIRST),
|
---|
1224 | MPFROMSHORT(CRA_CURSORED));
|
---|
1225 | if ((INT) pci == -1)
|
---|
1226 | pci = NULL;
|
---|
1227 | if (pci) {
|
---|
1228 | if (*(ULONG *) realappname == FM3UL) {
|
---|
1229 | sprintf(str, "%s %s", GetPString(IDS_DTTEXT), pci->pszFileName);
|
---|
1230 | WinSetWindowText(dcd->hwndFrame, str);
|
---|
1231 | WinSetWindowText(WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR),
|
---|
1232 | str);
|
---|
1233 | }
|
---|
1234 | else
|
---|
1235 | WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
|
---|
1236 | MAIN_STATUS), pci->pszFileName);
|
---|
1237 | if (fMoreButtons && hwndName) {
|
---|
1238 | CHAR szDate[DATE_BUF_BYTES];
|
---|
1239 |
|
---|
1240 | DateFormat(szDate, pci->date);
|
---|
1241 | WinSetWindowText(hwndName, pci->pszFileName);
|
---|
1242 | sprintf(str, "%s %02u%s%02u%s%02u", szDate,
|
---|
1243 | pci->time.hours, TimeSeparator,
|
---|
1244 | pci->time.minutes, TimeSeparator, pci->time.seconds);
|
---|
1245 | WinSetWindowText(hwndDate, str);
|
---|
1246 | WinSetWindowText(hwndAttr, pci->pszDispAttr);
|
---|
1247 | }
|
---|
1248 | }
|
---|
1249 | PostMsg(dcd->hwndObject, UM_RESCAN2, MPFROMP(pci), MPVOID);
|
---|
1250 | if (hwndStatus2)
|
---|
1251 | PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID);
|
---|
1252 | }
|
---|
1253 | return 0;
|
---|
1254 |
|
---|
1255 | case UM_SETUP2:
|
---|
1256 | {
|
---|
1257 | PCNRITEM pci = (PCNRITEM) mp1;
|
---|
1258 |
|
---|
1259 | if (pci)
|
---|
1260 | NotifyError(pci->pszFileName, (ULONG) mp2);
|
---|
1261 | }
|
---|
1262 | return 0;
|
---|
1263 |
|
---|
1264 | case UM_SETUP:
|
---|
1265 | # ifdef FORTIFY
|
---|
1266 | // Balance WM_DESTROY
|
---|
1267 | Fortify_EnterScope();
|
---|
1268 | # endif
|
---|
1269 |
|
---|
1270 | if (!dcd) {
|
---|
1271 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
1272 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
1273 | return 0;
|
---|
1274 | }
|
---|
1275 | else {
|
---|
1276 | if (!dcd->hwndObject) {
|
---|
1277 | // first time through -- set things up
|
---|
1278 | CNRINFO cnri;
|
---|
1279 |
|
---|
1280 | # ifdef FORTIFY
|
---|
1281 | Fortify_EnterScope();
|
---|
1282 | # endif
|
---|
1283 |
|
---|
1284 | RestorePresParams(hwnd, PCSZ_TREECNR);
|
---|
1285 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
1286 | cnri.cb = sizeof(CNRINFO);
|
---|
1287 | WinSendMsg(hwnd,
|
---|
1288 | CM_QUERYCNRINFO,
|
---|
1289 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
1290 | cnri.cyLineSpacing = 0;
|
---|
1291 | cnri.cxTreeIndent = 12;
|
---|
1292 | cnri.pSortRecord = (PVOID) SortTreeCnr;
|
---|
1293 | cnri.flWindowAttr &= (~(CV_NAME | CV_DETAIL | CV_TEXT));
|
---|
1294 | cnri.flWindowAttr |= (CV_TREE | CA_TREELINE | CV_ICON | CV_MINI);
|
---|
1295 | {
|
---|
1296 | ULONG size = sizeof(ULONG);
|
---|
1297 |
|
---|
1298 | PrfQueryProfileData(fmprof,
|
---|
1299 | appname,
|
---|
1300 | "TreeflWindowAttr",
|
---|
1301 | (PVOID) & cnri.flWindowAttr, &size);
|
---|
1302 | size = sizeof(MASK);
|
---|
1303 | *dcd->mask.prompt = 0;
|
---|
1304 | if (!*dcd->mask.szMask && !dcd->mask.attrFile) {
|
---|
1305 | if (PrfQueryProfileSize(fmprof,
|
---|
1306 | appname, "TreeFilter", &size) && size) {
|
---|
1307 | PrfQueryProfileData(fmprof,
|
---|
1308 | appname, "TreeFilter", &dcd->mask, &size);
|
---|
1309 | SetMask(NULL, &dcd->mask);
|
---|
1310 | }
|
---|
1311 | else
|
---|
1312 | dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
|
---|
1313 | FILE_ARCHIVED | FILE_DIRECTORY |
|
---|
1314 | FILE_HIDDEN | FILE_SYSTEM);
|
---|
1315 | }
|
---|
1316 | dcd->mask.attrFile |= FILE_DIRECTORY;
|
---|
1317 | }
|
---|
1318 | cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
|
---|
1319 | cnri.flWindowAttr |= CV_FLOW;
|
---|
1320 | dcd->flWindowAttr = cnri.flWindowAttr;
|
---|
1321 | WinSendMsg(hwnd,
|
---|
1322 | CM_SETCNRINFO,
|
---|
1323 | MPFROMP(&cnri),
|
---|
1324 | MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
|
---|
1325 | CMA_CXTREEINDENT | CMA_PSORTRECORD));
|
---|
1326 | if (xbeginthread(MakeObjWin,
|
---|
1327 | 327680,
|
---|
1328 | dcd,
|
---|
1329 | pszSrcFile,
|
---|
1330 | __LINE__) == -1)
|
---|
1331 | {
|
---|
1332 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
1333 | }
|
---|
1334 | else
|
---|
1335 | DosSleep(1);
|
---|
1336 | # ifdef FORTIFY
|
---|
1337 | Fortify_LeaveScope();
|
---|
1338 | # endif
|
---|
1339 | }
|
---|
1340 | }
|
---|
1341 | return 0;
|
---|
1342 |
|
---|
1343 | case WM_BUTTON3CLICK:
|
---|
1344 | case WM_CHORD:
|
---|
1345 | {
|
---|
1346 | PCNRITEM pci = NULL;
|
---|
1347 | QUERYRECFROMRECT pqr;
|
---|
1348 | NOTIFYRECORDENTER nr;
|
---|
1349 | BOOL tbool = fDCOpens;
|
---|
1350 | RECTL rectl;
|
---|
1351 | POINTL ptl;
|
---|
1352 |
|
---|
1353 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
1354 | if (msg == WM_CHORD) {
|
---|
1355 | if (!WinQueryPointerPos(HWND_DESKTOP, &ptl))
|
---|
1356 | break;
|
---|
1357 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
|
---|
1358 | }
|
---|
1359 | else {
|
---|
1360 | ptl.x = SHORT1FROMMP(mp1);
|
---|
1361 | ptl.y = SHORT2FROMMP(mp1);
|
---|
1362 | }
|
---|
1363 | memset(&rectl, 0, sizeof(rectl));
|
---|
1364 | memset(&pqr, 0, sizeof(pqr));
|
---|
1365 | pqr.cb = sizeof(pqr);
|
---|
1366 | pqr.rect.xLeft = ptl.x - 1;
|
---|
1367 | pqr.rect.xRight = ptl.x + 1;
|
---|
1368 | pqr.rect.yTop = ptl.y + 1;
|
---|
1369 | pqr.rect.yBottom = ptl.y - 1;
|
---|
1370 | pqr.fsSearch = CMA_PARTIAL;
|
---|
1371 | pci = (PCNRITEM) WinSendMsg(hwnd,
|
---|
1372 | CM_QUERYRECORDFROMRECT,
|
---|
1373 | MPFROMLONG(CMA_FIRST), MPFROMP(&pqr));
|
---|
1374 | if (!pci || (INT) pci == -1)
|
---|
1375 | break; //Probable B3 click on white space
|
---|
1376 | else {
|
---|
1377 | memset(&nr, 0, sizeof(nr));
|
---|
1378 | nr.hwndCnr = hwnd;
|
---|
1379 | nr.pRecord = (PRECORDCORE) pci;
|
---|
1380 | fDCOpens = TRUE;
|
---|
1381 | WinSendMsg(hwnd,
|
---|
1382 | WM_CONTROL,
|
---|
1383 | MPFROM2SHORT(WinQueryWindowUShort(hwnd,
|
---|
1384 | QWS_ID),
|
---|
1385 | CN_ENTER), MPFROMP(&nr));
|
---|
1386 | PostMsg(hwnd, UM_RESTOREDC, MPFROMLONG(tbool), MPVOID);
|
---|
1387 | }
|
---|
1388 | }
|
---|
1389 | break;
|
---|
1390 |
|
---|
1391 | case UM_RESTOREDC:
|
---|
1392 | fDCOpens = (BOOL) mp1;
|
---|
1393 | return 0;
|
---|
1394 |
|
---|
1395 | case WM_CONTROL:
|
---|
1396 | DosError(FERR_DISABLEHARDERR);
|
---|
1397 | if (dcd) {
|
---|
1398 | switch (SHORT2FROMMP(mp1)) {
|
---|
1399 | case CN_BEGINEDIT:
|
---|
1400 | case CN_REALLOCPSZ:
|
---|
1401 | case CN_ENDEDIT:
|
---|
1402 | {
|
---|
1403 | MRESULT mre;
|
---|
1404 |
|
---|
1405 | mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
|
---|
1406 | if (mre != (MRESULT) - 1)
|
---|
1407 | return mre;
|
---|
1408 | }
|
---|
1409 | break;
|
---|
1410 |
|
---|
1411 | case CN_DRAGLEAVE:
|
---|
1412 | if (mp2) {
|
---|
1413 |
|
---|
1414 | PDRAGINFO pDInfo;
|
---|
1415 |
|
---|
1416 | // fixme to know why - seems superfluous
|
---|
1417 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
---|
1418 | DrgAccessDraginfo(pDInfo);
|
---|
1419 | DrgFreeDraginfo(pDInfo);
|
---|
1420 | }
|
---|
1421 | return 0;
|
---|
1422 |
|
---|
1423 | case CN_DROPHELP:
|
---|
1424 | if (mp2) {
|
---|
1425 |
|
---|
1426 | PDRAGINFO pDInfo;
|
---|
1427 | PCNRITEM pci;
|
---|
1428 | ULONG numitems;
|
---|
1429 | USHORT usOperation;
|
---|
1430 |
|
---|
1431 | pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
|
---|
1432 | pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
|
---|
1433 | if (!DrgAccessDraginfo(pDInfo)) {
|
---|
1434 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
1435 | GetPString(IDS_DROPERRORTEXT));
|
---|
1436 | }
|
---|
1437 | else {
|
---|
1438 | numitems = DrgQueryDragitemCount(pDInfo);
|
---|
1439 | usOperation = pDInfo->usOperation;
|
---|
1440 | if (usOperation == DO_DEFAULT)
|
---|
1441 | usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
|
---|
1442 | FreeDragInfoData(hwnd, pDInfo);
|
---|
1443 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
---|
1444 | hwnd,
|
---|
1445 | GetPString(IDS_DROPHELPHDRTEXT),
|
---|
1446 | GetPString(IDS_DROPHELPTEXT),
|
---|
1447 | numitems,
|
---|
1448 | &"s"[numitems == 1L],
|
---|
1449 | pci ? NullStr : GetPString(IDS_NOTEXT),
|
---|
1450 | pci ? NullStr : " ",
|
---|
1451 | pci ? pci->pszFileName : NullStr,
|
---|
1452 | pci ? " " : NullStr,
|
---|
1453 | GetPString((usOperation == DO_MOVE) ?
|
---|
1454 | IDS_MOVETEXT :
|
---|
1455 | (usOperation == DO_LINK) ?
|
---|
1456 | IDS_LINKTEXT : IDS_COPYTEXT));
|
---|
1457 | }
|
---|
1458 | }
|
---|
1459 | return 0;
|
---|
1460 |
|
---|
1461 | case CN_DRAGAFTER:
|
---|
1462 | case CN_DRAGOVER:
|
---|
1463 | if (mp2) {
|
---|
1464 |
|
---|
1465 | PDRAGITEM pDItem;
|
---|
1466 | PDRAGINFO pDInfo;
|
---|
1467 | PCNRITEM pci;
|
---|
1468 | USHORT uso;
|
---|
1469 |
|
---|
1470 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
---|
1471 | if (!DrgAccessDraginfo(pDInfo)) {
|
---|
1472 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
1473 | PCSZ_DRGACCESSDRAGINFO);
|
---|
1474 | return (MRFROM2SHORT(DOR_NODROP, 0)); // Drop not valid
|
---|
1475 | }
|
---|
1476 | pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
|
---|
1477 | if ((INT) pci == -1)
|
---|
1478 | pci = NULL;
|
---|
1479 | if (pci && (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODROP))) {
|
---|
1480 | DrgFreeDraginfo(pDInfo);
|
---|
1481 | return MRFROM2SHORT(DOR_NODROP, 0);
|
---|
1482 | }
|
---|
1483 | if (!WinIsWindowEnabled(dcd->hwndFrame)) {
|
---|
1484 | DrgFreeDraginfo(pDInfo);
|
---|
1485 | return MRFROM2SHORT(DOR_NODROP, 0);
|
---|
1486 | }
|
---|
1487 | if (pci) {
|
---|
1488 | uso = pDInfo->usOperation;
|
---|
1489 | if (uso == DO_DEFAULT)
|
---|
1490 | uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
|
---|
1491 | if (!(pci->attrFile & FILE_DIRECTORY)) {
|
---|
1492 | if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
|
---|
1493 | DrgFreeDraginfo(pDInfo);
|
---|
1494 | return (MRFROM2SHORT(DOR_NODROP, 0));
|
---|
1495 | }
|
---|
1496 | if (uso != DO_LINK &&
|
---|
1497 | !(driveflags[toupper(*pci->pszFileName) - 'A'] &
|
---|
1498 | DRIVE_NOTWRITEABLE)) {
|
---|
1499 |
|
---|
1500 | ARC_TYPE *info;
|
---|
1501 |
|
---|
1502 | if (!fQuickArcFind &&
|
---|
1503 | !(driveflags[toupper(*pci->pszFileName) - 'A'] &
|
---|
1504 | DRIVE_SLOW))
|
---|
1505 | info = find_type(pci->pszFileName, NULL);
|
---|
1506 | else
|
---|
1507 | info = quick_find_type(pci->pszFileName, NULL);
|
---|
1508 | if (!info || ((uso == DO_MOVE && !info->move) ||
|
---|
1509 | (uso == DO_COPY && !info->create))) {
|
---|
1510 | DrgFreeDraginfo(pDInfo);
|
---|
1511 | return (MRFROM2SHORT(DOR_NODROP, 0));
|
---|
1512 | }
|
---|
1513 | }
|
---|
1514 | }
|
---|
1515 | }
|
---|
1516 | pDItem = DrgQueryDragitemPtr(pDInfo, // Access DRAGITEM
|
---|
1517 | 0); // Index to DRAGITEM
|
---|
1518 | if (DrgVerifyRMF(pDItem, // Check valid rendering
|
---|
1519 | (CHAR *) DRM_OS2FILE, // mechanisms and data
|
---|
1520 | NULL) || DrgVerifyRMF(pDItem,
|
---|
1521 | (CHAR *) DRM_FM2ARCMEMBER,
|
---|
1522 | (CHAR *) DRF_FM2ARCHIVE)) { // formats
|
---|
1523 | DrgFreeDraginfo(pDInfo); // Free DRAGINFO
|
---|
1524 | if (!pci || (INT) pci == -1)
|
---|
1525 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
1526 | if (driveflags[toupper(*pci->pszFileName) - 'A'] &
|
---|
1527 | DRIVE_NOTWRITEABLE)
|
---|
1528 | return MRFROM2SHORT(DOR_DROP, DO_LINK);
|
---|
1529 | if (toupper(*pci->pszFileName) < 'C')
|
---|
1530 | return MRFROM2SHORT(DOR_DROP, DO_COPY);
|
---|
1531 | return MRFROM2SHORT(DOR_DROP, // Return okay to drop
|
---|
1532 | ((fCopyDefault) ? DO_COPY : DO_MOVE));
|
---|
1533 | }
|
---|
1534 | DrgFreeDraginfo(pDInfo); // Free DRAGINFO
|
---|
1535 | }
|
---|
1536 | return MRFROM2SHORT(DOR_NODROP, 0); // Drop not valid
|
---|
1537 |
|
---|
1538 | case CN_INITDRAG:
|
---|
1539 | {
|
---|
1540 | PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
|
---|
1541 | PCNRITEM pci;
|
---|
1542 |
|
---|
1543 | if (!pcd) {
|
---|
1544 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
1545 | break;
|
---|
1546 | }
|
---|
1547 | else {
|
---|
1548 | pci = (PCNRITEM) pcd->pRecord;
|
---|
1549 | if (!pci || (INT) pci == -1) {
|
---|
1550 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
1551 | break;
|
---|
1552 | }
|
---|
1553 | if (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODRAG)) {
|
---|
1554 | Runtime_Error(pszSrcFile, __LINE__, "drag not allowed");
|
---|
1555 | break;
|
---|
1556 | }
|
---|
1557 | if (hwndStatus2) {
|
---|
1558 | WinSetWindowText(hwndStatus2, (IsRoot(pci->pszFileName)) ?
|
---|
1559 | (CHAR *) GetPString(IDS_DRAGROOTTEXT) :
|
---|
1560 | (pci->attrFile & FILE_DIRECTORY) ?
|
---|
1561 | (CHAR *) GetPString(IDS_DRAGDIRTEXT) :
|
---|
1562 | (CHAR *) GetPString(IDS_DRAGFILETEXT));
|
---|
1563 | }
|
---|
1564 | DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE);
|
---|
1565 | if (hwndStatus2) {
|
---|
1566 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1567 | }
|
---|
1568 | }
|
---|
1569 | }
|
---|
1570 | return 0;
|
---|
1571 |
|
---|
1572 | case CN_DROP:
|
---|
1573 | {
|
---|
1574 | LISTINFO *li;
|
---|
1575 | ULONG action = UM_ACTION;
|
---|
1576 |
|
---|
1577 | li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
|
---|
1578 | CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
|
---|
1579 | if (li) {
|
---|
1580 | if (!*li->targetpath) {
|
---|
1581 | if (li->list[0])
|
---|
1582 | PMMkDir(dcd->hwndParent, li->list[0], FALSE);
|
---|
1583 | FreeListInfo(li);
|
---|
1584 | return 0;
|
---|
1585 | }
|
---|
1586 | if (li->list && li->list[0] && IsRoot(li->list[0]))
|
---|
1587 | li->type = DO_LINK;
|
---|
1588 | else if (fDragndropDlg && (!*li->arcname || !li->info)) {
|
---|
1589 |
|
---|
1590 | CHECKLIST cl;
|
---|
1591 |
|
---|
1592 | memset(&cl, 0, sizeof(cl));
|
---|
1593 | cl.size = sizeof(cl);
|
---|
1594 | cl.flags = li->type;
|
---|
1595 | cl.list = li->list;
|
---|
1596 | cl.cmd = li->type;
|
---|
1597 | cl.prompt = li->targetpath;
|
---|
1598 | li->type = WinDlgBox(HWND_DESKTOP,
|
---|
1599 | dcd->hwndParent,
|
---|
1600 | DropListProc,
|
---|
1601 | FM3ModHandle, DND_FRAME, MPFROMP(&cl));
|
---|
1602 | if (li->type == DID_ERROR)
|
---|
1603 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
1604 | GetPString(IDS_DRAGDROPDIALOGTEXT));
|
---|
1605 | if (!li->type) {
|
---|
1606 | FreeListInfo(li);
|
---|
1607 | return 0;
|
---|
1608 | }
|
---|
1609 | li->list = cl.list;
|
---|
1610 | if (!li->list || !li->list[0]) {
|
---|
1611 | FreeListInfo(li);
|
---|
1612 | return 0;
|
---|
1613 | }
|
---|
1614 | }
|
---|
1615 | switch (li->type) {
|
---|
1616 | case DO_LINK:
|
---|
1617 | if (fLinkSetsIcon) {
|
---|
1618 | li->type = IDM_SETICON;
|
---|
1619 | action = UM_MASSACTION;
|
---|
1620 | }
|
---|
1621 | else
|
---|
1622 | li->type = IDM_COMPARE;
|
---|
1623 | break;
|
---|
1624 | case DND_EXTRACT:
|
---|
1625 | if (*li->targetpath && !IsFile(li->targetpath))
|
---|
1626 | li->type = IDM_EXTRACT;
|
---|
1627 | break;
|
---|
1628 | case DND_MOVE:
|
---|
1629 | li->type = IDM_MOVE;
|
---|
1630 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
---|
1631 | action = UM_MASSACTION;
|
---|
1632 | li->type = IDM_ARCHIVEM;
|
---|
1633 | }
|
---|
1634 | break;
|
---|
1635 | case DND_WILDMOVE:
|
---|
1636 | li->type = IDM_WILDMOVE;
|
---|
1637 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
---|
1638 | action = UM_MASSACTION;
|
---|
1639 | li->type = IDM_ARCHIVEM;
|
---|
1640 | }
|
---|
1641 | break;
|
---|
1642 | case DND_OBJECT:
|
---|
1643 | li->type = IDM_OBJECT;
|
---|
1644 | action = UM_MASSACTION;
|
---|
1645 | break;
|
---|
1646 | case DND_SHADOW:
|
---|
1647 | li->type = IDM_SHADOW;
|
---|
1648 | action = UM_MASSACTION;
|
---|
1649 | break;
|
---|
1650 | case DND_COMPARE:
|
---|
1651 | li->type = IDM_COMPARE;
|
---|
1652 | break;
|
---|
1653 | case DND_SETICON:
|
---|
1654 | action = UM_MASSACTION;
|
---|
1655 | li->type = IDM_SETICON;
|
---|
1656 | break;
|
---|
1657 | case DND_COPY:
|
---|
1658 | li->type = IDM_COPY;
|
---|
1659 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
---|
1660 | action = UM_MASSACTION;
|
---|
1661 | li->type = IDM_ARCHIVE;
|
---|
1662 | }
|
---|
1663 | break;
|
---|
1664 | case DND_WILDCOPY:
|
---|
1665 | li->type = IDM_WILDCOPY;
|
---|
1666 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
---|
1667 | action = UM_MASSACTION;
|
---|
1668 | li->type = IDM_ARCHIVE;
|
---|
1669 | }
|
---|
1670 | break;
|
---|
1671 | default:
|
---|
1672 | if (*li->arcname && li->info) {
|
---|
1673 | action = UM_MASSACTION;
|
---|
1674 | li->type = (li->type == DO_MOVE) ?
|
---|
1675 | IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
|
---|
1676 | }
|
---|
1677 | else if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
---|
1678 | action = UM_MASSACTION;
|
---|
1679 | li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
|
---|
1680 | }
|
---|
1681 | else
|
---|
1682 | li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
|
---|
1683 | break;
|
---|
1684 | }
|
---|
1685 | if (!li->list || !li->list[0])
|
---|
1686 | FreeListInfo(li);
|
---|
1687 | else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
|
---|
1688 | FreeListInfo(li);
|
---|
1689 | else {
|
---|
1690 |
|
---|
1691 | USHORT usop = 0;
|
---|
1692 |
|
---|
1693 | switch (li->type) {
|
---|
1694 | case IDM_COPY:
|
---|
1695 | case IDM_WILDCOPY:
|
---|
1696 | usop = DO_COPY;
|
---|
1697 | break;
|
---|
1698 | case IDM_MOVE:
|
---|
1699 | case IDM_WILDMOVE:
|
---|
1700 | case IDM_ARCHIVEM:
|
---|
1701 | usop = DO_MOVE;
|
---|
1702 | break;
|
---|
1703 | }
|
---|
1704 | if (usop)
|
---|
1705 | return MRFROM2SHORT(DOR_DROP, usop);
|
---|
1706 | }
|
---|
1707 | }
|
---|
1708 | }
|
---|
1709 | return 0;
|
---|
1710 |
|
---|
1711 | case CN_EMPHASIS:
|
---|
1712 | if (!fDummy) {
|
---|
1713 |
|
---|
1714 | PNOTIFYRECORDEMPHASIS pre = mp2;
|
---|
1715 |
|
---|
1716 | if (pre->fEmphasisMask & CRA_SELECTED) {
|
---|
1717 | if (pre->pRecord->flRecordAttr & CRA_SELECTED) {
|
---|
1718 | if (((PCNRITEM) (pre->pRecord))->attrFile & FILE_DIRECTORY) {
|
---|
1719 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1720 | if (fFollowTree &&
|
---|
1721 | !(driveflags
|
---|
1722 | [toupper(*((PCNRITEM) pre->pRecord)->pszFileName) -
|
---|
1723 | 'A'] & DRIVE_INVALID)) {
|
---|
1724 | if (!LastDir && !ParentIsDesktop(hwnd, dcd->hwndParent))
|
---|
1725 | LastDir = FindDirCnr(dcd->hwndParent);
|
---|
1726 | if (LastDir) {
|
---|
1727 |
|
---|
1728 | NOTIFYRECORDENTER pri;
|
---|
1729 | BOOL tbool = fDCOpens;
|
---|
1730 |
|
---|
1731 | fDCOpens = FALSE;
|
---|
1732 | memset(&pri, 0, sizeof(pri));
|
---|
1733 | pri.hwndCnr = hwnd;
|
---|
1734 | pri.fKey = FALSE;
|
---|
1735 | pri.pRecord = pre->pRecord;
|
---|
1736 | WinSendMsg(hwnd,
|
---|
1737 | WM_CONTROL,
|
---|
1738 | MPFROM2SHORT(SHORT1FROMMP(mp1),
|
---|
1739 | CN_ENTER), MPFROMP(&pri));
|
---|
1740 | fDCOpens = tbool;
|
---|
1741 | }
|
---|
1742 | }
|
---|
1743 | if (*(ULONG *) realappname != FM3UL)
|
---|
1744 | WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
|
---|
1745 | MAIN_STATUS),
|
---|
1746 | ((PCNRITEM) (pre->pRecord))->pszFileName);
|
---|
1747 | }
|
---|
1748 | }
|
---|
1749 | }
|
---|
1750 | }
|
---|
1751 | break;
|
---|
1752 |
|
---|
1753 | case CN_CONTEXTMENU:
|
---|
1754 | {
|
---|
1755 | PCNRITEM pci = (PCNRITEM) mp2;
|
---|
1756 | BOOL wasFollowing;
|
---|
1757 |
|
---|
1758 | //DosEnterCritSec(); //GKY 11-28-08
|
---|
1759 | wasFollowing = fFollowTree;
|
---|
1760 | fFollowTree = FALSE;
|
---|
1761 | //DosExitCritSec();
|
---|
1762 | if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
|
---|
1763 | WinSendMsg(hwnd,
|
---|
1764 | CM_SETRECORDEMPHASIS,
|
---|
1765 | MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
|
---|
1766 | MarkAll(hwnd, FALSE, FALSE, TRUE);
|
---|
1767 | if (!(pci->attrFile & FILE_DIRECTORY))
|
---|
1768 | dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
|
---|
1769 | else if (!IsRoot(pci->pszFileName))
|
---|
1770 | dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
|
---|
1771 | else
|
---|
1772 | dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
|
---|
1773 | }
|
---|
1774 | else {
|
---|
1775 | dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP);
|
---|
1776 | if (dcd->hwndLastMenu && !dcd->cnremphasized) {
|
---|
1777 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
---|
1778 | MPFROM2SHORT(TRUE, CRA_SOURCE));
|
---|
1779 | dcd->cnremphasized = TRUE;
|
---|
1780 | }
|
---|
1781 | }
|
---|
1782 | if (dcd->hwndLastMenu) {
|
---|
1783 | if (dcd->hwndLastMenu == DirMenu)
|
---|
1784 | WinEnableMenuItem(DirMenu, IDM_TREE, FALSE);
|
---|
1785 | if (dcd->hwndLastMenu == TreeCnrMenu) {
|
---|
1786 | if (dcd->flWindowAttr & CV_MINI)
|
---|
1787 | WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
|
---|
1788 | }
|
---|
1789 | if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
|
---|
1790 | if (dcd->cnremphasized) {
|
---|
1791 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
---|
1792 | MPFROM2SHORT(FALSE, CRA_SOURCE));
|
---|
1793 | dcd->cnremphasized = FALSE;
|
---|
1794 | }
|
---|
1795 | if (dcd->hwndLastMenu != TreeCnrMenu)
|
---|
1796 | MarkAll(hwnd, TRUE, FALSE, TRUE);
|
---|
1797 | }
|
---|
1798 | }
|
---|
1799 | //DosEnterCritSec(); //GKY 11-28-08
|
---|
1800 | fFollowTree = wasFollowing;
|
---|
1801 | //DosExitCritSec();
|
---|
1802 | }
|
---|
1803 | break;
|
---|
1804 |
|
---|
1805 | case CN_ENTER:
|
---|
1806 | if (mp2) {
|
---|
1807 | PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
|
---|
1808 |
|
---|
1809 | PostMsg(hwnd, UM_ENTER, MPFROMP(pci), MPVOID);
|
---|
1810 | }
|
---|
1811 | break;
|
---|
1812 |
|
---|
1813 | case CN_COLLAPSETREE:
|
---|
1814 | case CN_EXPANDTREE:
|
---|
1815 | {
|
---|
1816 | PCNRITEM pci = (PCNRITEM) mp2;
|
---|
1817 |
|
---|
1818 | if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
|
---|
1819 | if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
|
---|
1820 |
|
---|
1821 | struct
|
---|
1822 | {
|
---|
1823 | ULONG serial;
|
---|
1824 | CHAR volumelength;
|
---|
1825 | CHAR volumelabel[CCHMAXPATH];
|
---|
1826 | }
|
---|
1827 | volser;
|
---|
1828 |
|
---|
1829 | memset(&volser, 0, sizeof(volser));
|
---|
1830 | DosError(FERR_DISABLEHARDERR);
|
---|
1831 | if (!DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
|
---|
1832 | FSIL_VOLSER, &volser,
|
---|
1833 | (ULONG) sizeof(volser))) {
|
---|
1834 | if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
|
---|
1835 | !volser.serial ||
|
---|
1836 | driveserial[toupper(*pci->pszFileName) - 'A'] !=
|
---|
1837 | volser.serial)
|
---|
1838 | UnFlesh(hwnd, pci);
|
---|
1839 | if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
|
---|
1840 | (!volser.serial ||
|
---|
1841 | driveserial[toupper(*pci->pszFileName) - 'A'] !=
|
---|
1842 | volser.serial)) {
|
---|
1843 | if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && Flesh(hwnd, pci)
|
---|
1844 | &&!dcd->suspendview && fTopDir) {
|
---|
1845 | PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
|
---|
1846 | //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
|
---|
1847 | }
|
---|
1848 | }
|
---|
1849 | driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
|
---|
1850 | }
|
---|
1851 | else {
|
---|
1852 | driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
|
---|
1853 | UnFlesh(hwnd, pci);
|
---|
1854 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1855 | if (!fAlertBeepOff)
|
---|
1856 | DosBeep(250, 100);
|
---|
1857 | }
|
---|
1858 | }
|
---|
1859 | else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
|
---|
1860 | if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir){
|
---|
1861 | PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
|
---|
1862 | //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
|
---|
1863 | }
|
---|
1864 | }
|
---|
1865 | if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview){
|
---|
1866 | WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
|
---|
1867 | //DbgMsg(pszSrcFile, __LINE__, "UM_FILTER %p pci %p", hwnd, pci);
|
---|
1868 | }
|
---|
1869 | }
|
---|
1870 | }
|
---|
1871 | break;
|
---|
1872 | } // switch WM_CONTROL
|
---|
1873 | }
|
---|
1874 | return 0;
|
---|
1875 |
|
---|
1876 | case UM_ACTION:
|
---|
1877 | if (mp1) {
|
---|
1878 |
|
---|
1879 | LISTINFO *li = mp1;
|
---|
1880 | ULONG action = (ULONG) mp2;
|
---|
1881 |
|
---|
1882 | if (!li->list || !li->list[0] ||
|
---|
1883 | !PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
|
---|
1884 | FreeListInfo(li);
|
---|
1885 | }
|
---|
1886 | return 0;
|
---|
1887 |
|
---|
1888 | case UM_SHOWME:
|
---|
1889 | if (mp1 && dcd) {
|
---|
1890 | CHAR *dir = xstrdup((CHAR *)mp1, pszSrcFile, __LINE__);
|
---|
1891 |
|
---|
1892 | if (dir) {
|
---|
1893 | if (!PostMsg(dcd->hwndObject, UM_SHOWME, MPFROMP(dir), MPVOID))
|
---|
1894 | free(dir);
|
---|
1895 | }
|
---|
1896 | }
|
---|
1897 | return 0;
|
---|
1898 |
|
---|
1899 | case UM_TOPDIR:
|
---|
1900 | if (mp1) {
|
---|
1901 |
|
---|
1902 | PCNRITEM pci = (PCNRITEM) mp1;
|
---|
1903 |
|
---|
1904 | ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
|
---|
1905 | }
|
---|
1906 | return 0;
|
---|
1907 |
|
---|
1908 | case UM_ENTER:
|
---|
1909 | {
|
---|
1910 | FILEFINDBUF3 ffb;
|
---|
1911 | HDIR hDir = HDIR_CREATE;
|
---|
1912 | ULONG nm = 1;
|
---|
1913 | APIRET status;
|
---|
1914 | BOOL IsOk = FALSE;
|
---|
1915 | ULONG ulDriveNum, ulDriveMap;
|
---|
1916 | PCNRITEM pciP, pciL, pci;
|
---|
1917 | ULONG fl = SWP_ACTIVATE;
|
---|
1918 | INT x;
|
---|
1919 |
|
---|
1920 | DosRequestMutexSem(hmtxScanning, SEM_INDEFINITE_WAIT);
|
---|
1921 | DosQueryEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
|
---|
1922 | if (ulScanPostCnt < 1)
|
---|
1923 | return 0;
|
---|
1924 | DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
|
---|
1925 | if (fFollowTree)
|
---|
1926 | fl = 0;
|
---|
1927 | SetShiftState();
|
---|
1928 | pci = (PCNRITEM) mp1;
|
---|
1929 | if (pci &&
|
---|
1930 | (INT) pci != -1 &&
|
---|
1931 | !(pci->rc.flRecordAttr & CRA_INUSE) &&
|
---|
1932 | !(pci->flags & RECFLAGS_ENV) && IsFullName(pci->pszFileName)) {
|
---|
1933 | x = (INT) (toupper(*pci->pszFileName) - 'A');
|
---|
1934 | if (driveflags[x] & DRIVE_INVALID) {
|
---|
1935 | if (!fAlertBeepOff)
|
---|
1936 | DosBeep(50, 100);
|
---|
1937 | if (hwndStatus)
|
---|
1938 | WinSetWindowText(hwndStatus, (CHAR *) GetPString(IDS_RESCANSUGTEXT));
|
---|
1939 | DosPostEventSem(hevTreeCnrScanComplete);
|
---|
1940 | return 0;
|
---|
1941 | }
|
---|
1942 | DosError(FERR_DISABLEHARDERR);
|
---|
1943 | if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) {
|
---|
1944 | if (!(ulDriveMap & 1 << x)) {
|
---|
1945 | pciL = pciP = pci;
|
---|
1946 | for (;;) {
|
---|
1947 | pciP = WinSendMsg(hwnd,
|
---|
1948 | CM_QUERYRECORD,
|
---|
1949 | MPFROMP(pciL),
|
---|
1950 | MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
|
---|
1951 | if (pciP && (INT) pciP != -1)
|
---|
1952 | pciL = pciP;
|
---|
1953 | else {
|
---|
1954 | pciP = pciL;
|
---|
1955 | break;
|
---|
1956 | }
|
---|
1957 | } // for
|
---|
1958 | RemoveCnrItems(hwnd, pciP, 1, CMA_FREE | CMA_INVALIDATE);
|
---|
1959 | DosPostEventSem(hevTreeCnrScanComplete);
|
---|
1960 | return 0;
|
---|
1961 | }
|
---|
1962 | }
|
---|
1963 | if (driveflags[x] & (DRIVE_REMOVABLE | DRIVE_NOPRESCAN)) {
|
---|
1964 |
|
---|
1965 | struct
|
---|
1966 | {
|
---|
1967 | ULONG serial;
|
---|
1968 | CHAR volumelength;
|
---|
1969 | CHAR volumelabel[CCHMAXPATH];
|
---|
1970 | }
|
---|
1971 | volser;
|
---|
1972 | CHAR FileSystem[CCHMAXPATH];
|
---|
1973 | CHAR szBuf[CCHMAXPATH];
|
---|
1974 |
|
---|
1975 | pciL = pciP = pci;
|
---|
1976 | for (;;) {
|
---|
1977 | pciP = WinSendMsg(hwnd,
|
---|
1978 | CM_QUERYRECORD,
|
---|
1979 | MPFROMP(pciL),
|
---|
1980 | MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
|
---|
1981 | if (pciP && (INT) pciP != -1)
|
---|
1982 | pciL = pciP;
|
---|
1983 | else {
|
---|
1984 | pciP = pciL;
|
---|
1985 | break;
|
---|
1986 | }
|
---|
1987 | }
|
---|
1988 | if ((driveflags[x] & DRIVE_NOPRESCAN) || (toupper(*pci->pszFileName) > 'B' &&
|
---|
1989 | !(driveflags[x] & DRIVE_CDROM))) {
|
---|
1990 | DriveFlagsOne(x, FileSystem, &volser);
|
---|
1991 | SelectDriveIcon(pciP);
|
---|
1992 | if (hwndMain)
|
---|
1993 | PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
|
---|
1994 | }
|
---|
1995 | memset(&volser, 0, sizeof(volser));
|
---|
1996 | DosError(FERR_DISABLEHARDERR);
|
---|
1997 | status = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
|
---|
1998 | FSIL_VOLSER, &volser,
|
---|
1999 | (ULONG) sizeof(volser));
|
---|
2000 | if (!status) {
|
---|
2001 | if (!volser.serial || driveserial[x] != volser.serial) {
|
---|
2002 | Flesh(hwnd, pciP);
|
---|
2003 | driveserial[x] = volser.serial;
|
---|
2004 | }
|
---|
2005 | pciL = WinSendMsg(hwnd,
|
---|
2006 | CM_QUERYRECORD,
|
---|
2007 | MPFROMP(pciP),
|
---|
2008 | MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
|
---|
2009 | if (!pciL) {
|
---|
2010 | Flesh(hwnd, pciP);
|
---|
2011 | }
|
---|
2012 | if ((fShowFSTypeInTree || fShowDriveLabelInTree) &&
|
---|
2013 | strlen(pciP->pszFileName) < 4) {
|
---|
2014 | strcpy(szBuf, pciP->pszFileName);
|
---|
2015 | strcat(szBuf, " [");
|
---|
2016 | strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
|
---|
2017 | strcat(szBuf, "]");
|
---|
2018 | pciP->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
|
---|
2019 | pciP->rc.pszIcon = pciP->pszDisplayName;
|
---|
2020 | }
|
---|
2021 | WinSendMsg(hwnd,
|
---|
2022 | CM_INVALIDATERECORD,
|
---|
2023 | MPFROMP(&pciP),
|
---|
2024 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
|
---|
2025 | }
|
---|
2026 | else {
|
---|
2027 | driveserial[x] = -1;
|
---|
2028 | UnFlesh(hwnd, pci);
|
---|
2029 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
2030 | PostMsg(hwnd, UM_SETUP2, MPFROMP(pci), MPFROMLONG(status));
|
---|
2031 | DosPostEventSem(hevTreeCnrScanComplete);
|
---|
2032 | return 0;
|
---|
2033 | }
|
---|
2034 | }
|
---|
2035 | status = 0;
|
---|
2036 | IsOk = (IsRoot(pci->pszFileName) &&
|
---|
2037 | IsValidDrive(toupper(*pci->pszFileName)));
|
---|
2038 | if (!IsOk) {
|
---|
2039 | DosError(FERR_DISABLEHARDERR);
|
---|
2040 | status = DosFindFirst(pci->pszFileName, &hDir,
|
---|
2041 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
2042 | FILE_ARCHIVED | FILE_READONLY |
|
---|
2043 | FILE_HIDDEN | FILE_SYSTEM,
|
---|
2044 | &ffb, sizeof(ffb), &nm, FIL_STANDARD);
|
---|
2045 | priority_bumped();
|
---|
2046 | }
|
---|
2047 | if (!status) {
|
---|
2048 | if (!IsOk)
|
---|
2049 | DosFindClose(hDir);
|
---|
2050 | if (IsOk || (ffb.attrFile & FILE_DIRECTORY)) {
|
---|
2051 | if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT)) {
|
---|
2052 | PostMsg(hwnd,
|
---|
2053 | WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
|
---|
2054 | DosPostEventSem(hevTreeCnrScanComplete);
|
---|
2055 | return 0;
|
---|
2056 | }
|
---|
2057 | if ((shiftstate & (KC_CTRL | KC_SHIFT)) == (KC_CTRL | KC_SHIFT)) {
|
---|
2058 | OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
|
---|
2059 | DosPostEventSem(hevTreeCnrScanComplete);
|
---|
2060 | return 0;
|
---|
2061 | }
|
---|
2062 | if (!(shiftstate & (KC_CTRL | KC_SHIFT))) {
|
---|
2063 | if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
2064 | if (FindDirCnrByName(pci->pszFileName, TRUE)) {
|
---|
2065 | DosPostEventSem(hevTreeCnrScanComplete);
|
---|
2066 | return 0;
|
---|
2067 | }
|
---|
2068 | }
|
---|
2069 | }
|
---|
2070 | if ((shiftstate & KC_CTRL) ||
|
---|
2071 | (!(shiftstate & KC_SHIFT) &&
|
---|
2072 | ParentIsDesktop(hwnd, dcd->hwndParent) && fVTreeOpensWPS)) {
|
---|
2073 |
|
---|
2074 | ULONG size = sizeof(ULONG), flWindowAttr = CV_ICON;
|
---|
2075 | CHAR s[33];
|
---|
2076 |
|
---|
2077 | strcpy(s, PCSZ_ICON);
|
---|
2078 | PrfQueryProfileData(fmprof,
|
---|
2079 | appname,
|
---|
2080 | "DirflWindowAttr",
|
---|
2081 | (PVOID) & flWindowAttr, &size);
|
---|
2082 | if (flWindowAttr & CV_DETAIL) {
|
---|
2083 | if (IsRoot(pci->pszFileName))
|
---|
2084 | strcpy(s, PCSZ_TREE);
|
---|
2085 | else
|
---|
2086 | strcpy(s, Details);
|
---|
2087 | }
|
---|
2088 | OpenObject(pci->pszFileName, s, dcd->hwndFrame);
|
---|
2089 | DosPostEventSem(hevTreeCnrScanComplete);
|
---|
2090 | return 0;
|
---|
2091 | }
|
---|
2092 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
2093 | !fDCOpens && !LastDir && !(shiftstate & KC_SHIFT))
|
---|
2094 | LastDir = FindDirCnr(dcd->hwndParent);
|
---|
2095 | if (LastDir && !fDCOpens && !(shiftstate & KC_SHIFT)) {
|
---|
2096 | WinSendMsg(LastDir,
|
---|
2097 | UM_SETDIR, MPFROMP(pci->pszFileName), MPVOID);
|
---|
2098 | WinSetWindowPos(WinQueryWindow(WinQueryWindow(LastDir,
|
---|
2099 | QW_PARENT),
|
---|
2100 | QW_PARENT),
|
---|
2101 | HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | fl);
|
---|
2102 | }
|
---|
2103 | else
|
---|
2104 | OpenDirCnr(hwnd,
|
---|
2105 | dcd->hwndParent,
|
---|
2106 | dcd->hwndFrame, FALSE, pci->pszFileName);
|
---|
2107 | }
|
---|
2108 | else {
|
---|
2109 | if (!(driveflags[x] & DRIVE_INCLUDEFILES))
|
---|
2110 | RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE);
|
---|
2111 | else {
|
---|
2112 |
|
---|
2113 | SWP swp;
|
---|
2114 |
|
---|
2115 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
---|
2116 | DefaultViewKeys(hwnd,
|
---|
2117 | dcd->hwndFrame,
|
---|
2118 | dcd->hwndParent, &swp, pci->pszFileName);
|
---|
2119 | }
|
---|
2120 | }
|
---|
2121 | }
|
---|
2122 | else {
|
---|
2123 | if (!IsRoot(pci->pszFileName)) {
|
---|
2124 | NotifyError(pci->pszFileName, status);
|
---|
2125 | RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE);
|
---|
2126 | }
|
---|
2127 | }
|
---|
2128 | }
|
---|
2129 | else if (!pci)
|
---|
2130 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
|
---|
2131 | if (fFollowTree)
|
---|
2132 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
2133 | DosPostEventSem(hevTreeCnrScanComplete);
|
---|
2134 | }
|
---|
2135 | return 0;
|
---|
2136 |
|
---|
2137 | case WM_MENUEND:
|
---|
2138 | if (dcd) {
|
---|
2139 |
|
---|
2140 | HWND hwndMenu = (HWND) mp2;
|
---|
2141 |
|
---|
2142 | if (hwndMenu == TreeCnrMenu || hwndMenu == TreeMenu ||
|
---|
2143 | hwndMenu == DirMenu) {
|
---|
2144 | MarkAll(hwnd, TRUE, FALSE, TRUE);
|
---|
2145 | if (dcd->cnremphasized) {
|
---|
2146 | WinSendMsg(hwnd,
|
---|
2147 | CM_SETRECORDEMPHASIS,
|
---|
2148 | MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
|
---|
2149 | dcd->cnremphasized = FALSE;
|
---|
2150 | }
|
---|
2151 | }
|
---|
2152 | }
|
---|
2153 | break;
|
---|
2154 |
|
---|
2155 | case UM_OPENWINDOWFORME:
|
---|
2156 | if (dcd) {
|
---|
2157 | if (mp1 && !IsFile((CHAR *)mp1))
|
---|
2158 | OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
|
---|
2159 | }
|
---|
2160 | return 0;
|
---|
2161 |
|
---|
2162 | case MM_PORTHOLEINIT:
|
---|
2163 | if (dcd) {
|
---|
2164 | switch (SHORT1FROMMP(mp1)) {
|
---|
2165 | case 0:
|
---|
2166 | case 1:
|
---|
2167 | {
|
---|
2168 | ULONG wmsg;
|
---|
2169 |
|
---|
2170 | wmsg = ((SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU);
|
---|
2171 | PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
|
---|
2172 | wmsg, MPVOID, MPVOID), mp1, mp2);
|
---|
2173 | }
|
---|
2174 | break;
|
---|
2175 | }
|
---|
2176 | }
|
---|
2177 | break;
|
---|
2178 |
|
---|
2179 | case UM_INITMENU:
|
---|
2180 | case WM_INITMENU:
|
---|
2181 | if (dcd) {
|
---|
2182 |
|
---|
2183 | switch (SHORT1FROMMP(mp1)) {
|
---|
2184 | case IDM_FILESMENU:
|
---|
2185 | {
|
---|
2186 | PCNRITEM pci;
|
---|
2187 |
|
---|
2188 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2189 | if (pci && (INT) pci != -1) {
|
---|
2190 | BOOL rdy;
|
---|
2191 | BOOL writeable;
|
---|
2192 | BOOL removable;
|
---|
2193 | BOOL local;
|
---|
2194 | BOOL underenv;
|
---|
2195 | CHAR chDrvU;
|
---|
2196 | CHAR szDrv[CCHMAXPATH];
|
---|
2197 |
|
---|
2198 | strcpy(szDrv, pci->pszFileName);
|
---|
2199 | chDrvU = *pci->pszFileName;
|
---|
2200 | chDrvU = toupper(chDrvU);
|
---|
2201 | MakeValidDir(szDrv);
|
---|
2202 | rdy = *szDrv == chDrvU; // Drive not ready if MakeValidDir changes drive letter
|
---|
2203 | removable = rdy
|
---|
2204 | && (driveflags[chDrvU - 'A'] & DRIVE_REMOVABLE) != 0;
|
---|
2205 | writeable = rdy
|
---|
2206 | && !(driveflags[chDrvU - 'A'] & DRIVE_NOTWRITEABLE);
|
---|
2207 | local = rdy && (!(driveflags[chDrvU - 'A'] & (DRIVE_REMOTE | DRIVE_VIRTUAL)));
|
---|
2208 | underenv = (pci->flags & RECFLAGS_UNDERENV) != 0;
|
---|
2209 |
|
---|
2210 | CopyPresParams((HWND) mp2, hwndMainMenu);
|
---|
2211 | WinEnableMenuItem((HWND) mp2, IDM_INFO, rdy);
|
---|
2212 |
|
---|
2213 | WinEnableMenuItem((HWND) mp2, IDM_ATTRS, writeable);
|
---|
2214 | WinEnableMenuItem((HWND) mp2, IDM_EAS, writeable);
|
---|
2215 | WinEnableMenuItem((HWND) mp2, IDM_SUBJECT, writeable);
|
---|
2216 | WinEnableMenuItem((HWND) mp2, IDM_DRVFLAGS, 1); // fixme to allow if not ready
|
---|
2217 |
|
---|
2218 | WinEnableMenuItem((HWND) mp2, IDM_ARCHIVE, rdy);
|
---|
2219 |
|
---|
2220 | WinEnableMenuItem((HWND) mp2, IDM_UPDATE, !underenv);
|
---|
2221 | WinEnableMenuItem((HWND) mp2, IDM_EXPANDSUBMENU, !underenv);
|
---|
2222 | WinEnableMenuItem((HWND) mp2, IDM_EXPAND, !underenv);
|
---|
2223 | WinEnableMenuItem((HWND) mp2, IDM_COLLAPSE, !underenv);
|
---|
2224 |
|
---|
2225 | WinEnableMenuItem((HWND) mp2, IDM_SIZES, rdy);
|
---|
2226 | WinEnableMenuItem((HWND) mp2, IDM_MKDIR, writeable);
|
---|
2227 | WinEnableMenuItem((HWND) mp2, IDM_SHOWALLFILES, rdy);
|
---|
2228 | WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, writeable);
|
---|
2229 |
|
---|
2230 | WinEnableMenuItem((HWND) mp2, IDM_CHKDSK, writeable && local);
|
---|
2231 | WinEnableMenuItem((HWND) mp2, IDM_FORMAT, writeable && local);
|
---|
2232 | WinEnableMenuItem((HWND) mp2, IDM_OPTIMIZE, writeable && local);
|
---|
2233 | WinEnableMenuItem((HWND) mp2, IDM_PARTITIONSMENU, local);
|
---|
2234 | WinEnableMenuItem((HWND) mp2, IDM_PARTITION, fMiniLVM);
|
---|
2235 | WinEnableMenuItem((HWND) mp2, IDM_PARTITIONDF, fDFSee);
|
---|
2236 | WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVMG, fLVMGui);
|
---|
2237 | WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVM, fLVM);
|
---|
2238 | WinEnableMenuItem((HWND) mp2, IDM_PARTITIONFD, fFDisk);
|
---|
2239 |
|
---|
2240 | WinEnableMenuItem((HWND) mp2, IDM_DETACH, !local);
|
---|
2241 |
|
---|
2242 | WinEnableMenuItem((HWND) mp2, IDM_EJECT, removable);
|
---|
2243 |
|
---|
2244 | WinEnableMenuItem((HWND) mp2, IDM_LOCK, removable);
|
---|
2245 | WinEnableMenuItem((HWND) mp2, IDM_UNLOCK, removable);
|
---|
2246 |
|
---|
2247 | WinEnableMenuItem((HWND) mp2, IDM_DELETE, !underenv && writeable);
|
---|
2248 | WinEnableMenuItem((HWND) mp2, IDM_PERMDELETE, !underenv
|
---|
2249 | && writeable);
|
---|
2250 | WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, !underenv
|
---|
2251 | && writeable);
|
---|
2252 | WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, !underenv
|
---|
2253 | && writeable);
|
---|
2254 | WinEnableMenuItem((HWND) mp2, IDM_RENAME, !underenv && writeable);
|
---|
2255 |
|
---|
2256 | }
|
---|
2257 | }
|
---|
2258 | break;
|
---|
2259 |
|
---|
2260 | case IDM_VIEWSMENU:
|
---|
2261 | WinCheckMenuItem((HWND) mp2,
|
---|
2262 | IDM_MINIICONS, ((dcd->flWindowAttr & CV_MINI) != 0));
|
---|
2263 | CopyPresParams((HWND) mp2, hwndMainMenu);
|
---|
2264 | WinEnableMenuItem((HWND) mp2, IDM_RESELECT, FALSE);
|
---|
2265 | WinEnableMenuItem((HWND) mp2, IDM_PARTITION, fMiniLVM);
|
---|
2266 | WinEnableMenuItem((HWND) mp2, IDM_PARTITIONDF, fDFSee);
|
---|
2267 | WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVMG, fLVMGui);
|
---|
2268 | WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVM, fLVM);
|
---|
2269 | WinEnableMenuItem((HWND) mp2, IDM_PARTITIONFD, fFDisk);
|
---|
2270 | break;
|
---|
2271 |
|
---|
2272 | case IDM_COMMANDSMENU:
|
---|
2273 | SetupCommandMenu((HWND) mp2, hwnd);
|
---|
2274 | CopyPresParams((HWND) mp2, hwndMainMenu);
|
---|
2275 | break;
|
---|
2276 |
|
---|
2277 | case IDM_SORTSUBMENU:
|
---|
2278 | SetSortChecks((HWND) mp2, TreesortFlags);
|
---|
2279 | CopyPresParams((HWND) mp2, hwndMainMenu);
|
---|
2280 | break;
|
---|
2281 |
|
---|
2282 | case IDM_WINDOWSMENU:
|
---|
2283 | SetupWinList((HWND) mp2,
|
---|
2284 | (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
|
---|
2285 | CopyPresParams((HWND) mp2, hwndMainMenu);
|
---|
2286 | break;
|
---|
2287 | }
|
---|
2288 | dcd->hwndLastMenu = (HWND) mp2;
|
---|
2289 | }
|
---|
2290 | if (msg == WM_INITMENU)
|
---|
2291 | break;
|
---|
2292 | return 0;
|
---|
2293 |
|
---|
2294 | case UM_COMMAND:
|
---|
2295 | if (!mp1)
|
---|
2296 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
2297 | else {
|
---|
2298 | if (!dcd) {
|
---|
2299 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
2300 | FreeListInfo((LISTINFO *) mp1);
|
---|
2301 | }
|
---|
2302 | else {
|
---|
2303 | if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
|
---|
2304 | Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
|
---|
2305 | FreeListInfo((LISTINFO *) mp1);
|
---|
2306 | }
|
---|
2307 | else
|
---|
2308 | return (MRESULT) TRUE;
|
---|
2309 | }
|
---|
2310 | }
|
---|
2311 | return 0;
|
---|
2312 |
|
---|
2313 | case UM_LOADFILE:
|
---|
2314 | if (dcd && mp2) {
|
---|
2315 |
|
---|
2316 | HWND hwnd;
|
---|
2317 |
|
---|
2318 | if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
|
---|
2319 | hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
|
---|
2320 | (CHAR *)mp2, dcd->hwndFrame);
|
---|
2321 | else
|
---|
2322 | hwnd = StartMLEEditor(dcd->hwndParent,
|
---|
2323 | (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
|
---|
2324 | free((CHAR *)mp2);
|
---|
2325 | return MRFROMLONG(hwnd);
|
---|
2326 | }
|
---|
2327 | return 0;
|
---|
2328 |
|
---|
2329 | case UM_FIXCNRMLE:
|
---|
2330 | case UM_FIXEDITNAME:
|
---|
2331 | return CommonCnrProc(hwnd, msg, mp1, mp2);
|
---|
2332 |
|
---|
2333 | case UM_NOTIFY:
|
---|
2334 | if (mp2)
|
---|
2335 | Notify((CHAR *)mp2);
|
---|
2336 | return 0;
|
---|
2337 |
|
---|
2338 | case UM_FILTER:
|
---|
2339 | if (dcd) {
|
---|
2340 |
|
---|
2341 | BOOL tempsusp = dcd->suspendview;
|
---|
2342 |
|
---|
2343 | if (mp1)
|
---|
2344 | SetMask((CHAR *)mp1, &dcd->mask);
|
---|
2345 |
|
---|
2346 | dcd->suspendview = TRUE;
|
---|
2347 | dcd->mask.attrFile |= FILE_DIRECTORY;
|
---|
2348 | WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
|
---|
2349 | dcd->suspendview = (USHORT) tempsusp;
|
---|
2350 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
2351 | //DbgMsg(pszSrcFile, __LINE__, "UM_RESCAN %p pci %s", hwnd, (CHAR *) mp1);
|
---|
2352 | }
|
---|
2353 | return 0;
|
---|
2354 |
|
---|
2355 | case UM_DRIVECMD:
|
---|
2356 | if (mp1) {
|
---|
2357 | ShowTreeRec(hwnd, (CHAR *)mp1, FALSE, TRUE);
|
---|
2358 | PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
|
---|
2359 | }
|
---|
2360 | return 0;
|
---|
2361 |
|
---|
2362 | case WM_APPTERMINATENOTIFY:
|
---|
2363 | {
|
---|
2364 | APPNOTIFY *info;
|
---|
2365 | PCNRITEM pci;
|
---|
2366 | CHAR s[] = " :\\";
|
---|
2367 |
|
---|
2368 | if (!mp2) {
|
---|
2369 | if (hwndMain)
|
---|
2370 | PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
|
---|
2371 | }
|
---|
2372 | info = apphead;
|
---|
2373 | while (info) {
|
---|
2374 | if (info->happ == (HAPP) mp1) {
|
---|
2375 | *s = info->device;
|
---|
2376 | pci = FindCnrRecord(hwnd, s, NULL, FALSE, FALSE, TRUE);
|
---|
2377 | if (pci && (INT) pci != -1) {
|
---|
2378 | INT x = info->device - 'A';
|
---|
2379 | CHAR FileSystem[CCHMAXPATH];
|
---|
2380 |
|
---|
2381 | driveserial[x] = -1;
|
---|
2382 | DriveFlagsOne(x, FileSystem, NULL);
|
---|
2383 | if (driveflags[x] &
|
---|
2384 | (DRIVE_INVALID | DRIVE_IGNORE))
|
---|
2385 | RemoveCnrItems(hwnd, pci, 1, CMA_FREE);
|
---|
2386 | else
|
---|
2387 | Flesh(hwnd, pci);
|
---|
2388 | }
|
---|
2389 | if (info->prev)
|
---|
2390 | info->prev->next = info->next;
|
---|
2391 | if (info->next)
|
---|
2392 | info->next->prev = info->prev;
|
---|
2393 | if (apphead == info)
|
---|
2394 | apphead = info->next;
|
---|
2395 | if (apptail == info)
|
---|
2396 | apptail = info->prev;
|
---|
2397 | free(info);
|
---|
2398 | break;
|
---|
2399 | }
|
---|
2400 | info = info->next;
|
---|
2401 | }
|
---|
2402 | }
|
---|
2403 | break;
|
---|
2404 |
|
---|
2405 | case WM_COMMAND:
|
---|
2406 | DosError(FERR_DISABLEHARDERR);
|
---|
2407 | if (dcd) {
|
---|
2408 | if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
|
---|
2409 | return 0;
|
---|
2410 | switch (SHORT1FROMMP(mp1)) {
|
---|
2411 | case IDM_SETTARGET:
|
---|
2412 | SetTargetDir(hwnd, FALSE, NULL);
|
---|
2413 | break;
|
---|
2414 |
|
---|
2415 | case IDM_DETACH:
|
---|
2416 | {
|
---|
2417 | CHAR d[3] = " :";
|
---|
2418 | PCNRITEM pci;
|
---|
2419 | PROGDETAILS pgd;
|
---|
2420 | CHAR params[368], *p;
|
---|
2421 | HAPP happ;
|
---|
2422 |
|
---|
2423 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2424 | if (pci && (INT) pci != -1 && isalpha(*pci->pszFileName)) {
|
---|
2425 | *d = toupper(*pci->pszFileName);
|
---|
2426 | p = GetCmdSpec(FALSE);
|
---|
2427 | memset(&pgd, 0, sizeof(pgd));
|
---|
2428 | pgd.Length = sizeof(pgd);
|
---|
2429 | pgd.progt.progc = PROG_WINDOWABLEVIO;
|
---|
2430 | pgd.progt.fbVisible = SHE_VISIBLE;
|
---|
2431 | pgd.pszTitle = (PSZ)GetPString(IDS_DETACHREQUESTTEXT);
|
---|
2432 | pgd.pszExecutable = p;
|
---|
2433 | pgd.pszParameters = params;
|
---|
2434 | pgd.pszStartupDir = NULL;
|
---|
2435 | pgd.pszIcon = NULL;
|
---|
2436 | pgd.pszEnvironment = NULL;
|
---|
2437 | pgd.swpInitial.hwndInsertBehind = HWND_TOP;
|
---|
2438 | pgd.swpInitial.hwnd = hwnd;
|
---|
2439 | pgd.swpInitial.fl = SWP_SHOW | SWP_ACTIVATE;
|
---|
2440 | sprintf(params, "/C NET USE %s /D", d);
|
---|
2441 | happ = WinStartApp(hwnd, &pgd, pgd.pszParameters,
|
---|
2442 | NULL, SAF_MAXIMIZED);
|
---|
2443 | if (!happ) {
|
---|
2444 | saymsg(MB_CANCEL | MB_ICONEXCLAMATION, hwnd,
|
---|
2445 | GetPString(IDS_ERRORTEXT),
|
---|
2446 | GetPString(IDS_CANTSTARTTEXT), p, params);
|
---|
2447 | }
|
---|
2448 | else {
|
---|
2449 | APPNOTIFY *info;
|
---|
2450 |
|
---|
2451 | info = xmallocz(sizeof(APPNOTIFY), pszSrcFile, __LINE__);
|
---|
2452 | if (info) {
|
---|
2453 | info->happ = happ;
|
---|
2454 | info->device = *d;
|
---|
2455 | if (!apphead)
|
---|
2456 | apphead = info;
|
---|
2457 | else {
|
---|
2458 | apptail->next = info;
|
---|
2459 | info->prev = apptail;
|
---|
2460 | }
|
---|
2461 | apptail = info;
|
---|
2462 | }
|
---|
2463 | PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
|
---|
2464 | }
|
---|
2465 | }
|
---|
2466 | }
|
---|
2467 | break;
|
---|
2468 |
|
---|
2469 | case IDM_REMAP:
|
---|
2470 | WinDlgBox(HWND_DESKTOP, hwnd, RemapDlgProc,
|
---|
2471 | FM3ModHandle, MAP_FRAME, NULL);
|
---|
2472 | break;
|
---|
2473 |
|
---|
2474 | case IDM_CONTEXTMENU:
|
---|
2475 | {
|
---|
2476 | PCNRITEM pci;
|
---|
2477 |
|
---|
2478 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2479 | PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
|
---|
2480 | MPFROMP(pci));
|
---|
2481 | }
|
---|
2482 | break;
|
---|
2483 |
|
---|
2484 | case IDM_FINDINTREE:
|
---|
2485 | {
|
---|
2486 | PSZ pszTempDir;
|
---|
2487 | PCNRITEM pci;
|
---|
2488 |
|
---|
2489 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2490 | if (pci && (INT) pci != -1) {
|
---|
2491 | pszTempDir = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
|
---|
2492 | if (pszTempDir)
|
---|
2493 | MakeValidDir(pszTempDir);
|
---|
2494 | }
|
---|
2495 | else
|
---|
2496 | pszTempDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
|
---|
2497 | if (pszTempDir) {
|
---|
2498 | if (WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
|
---|
2499 | WalkAllDlgProc,
|
---|
2500 | FM3ModHandle, WALK_FRAME, MPFROMP(pszTempDir))) {
|
---|
2501 | if (!WinSendMsg(hwnd, UM_SHOWME, MPFROMP(pszTempDir), MPFROMLONG(1)))
|
---|
2502 | free(pszTempDir);
|
---|
2503 | }
|
---|
2504 | else
|
---|
2505 | free(pszTempDir);
|
---|
2506 | }
|
---|
2507 | }
|
---|
2508 | break;
|
---|
2509 |
|
---|
2510 | case IDM_BEGINEDIT:
|
---|
2511 | OpenEdit(hwnd);
|
---|
2512 | break;
|
---|
2513 |
|
---|
2514 | case IDM_ENDEDIT:
|
---|
2515 | WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
|
---|
2516 | break;
|
---|
2517 |
|
---|
2518 | case IDM_FILTER:
|
---|
2519 | {
|
---|
2520 | BOOL empty = FALSE;
|
---|
2521 | PCNRITEM pci;
|
---|
2522 |
|
---|
2523 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2524 | if (!*dcd->mask.szMask)
|
---|
2525 | empty = TRUE;
|
---|
2526 | dcd->mask.fIsTree = TRUE;
|
---|
2527 | *dcd->mask.prompt = 0;
|
---|
2528 | if (pci && (INT) pci != -1)
|
---|
2529 | dcd->mask.fFilesIncluded =
|
---|
2530 | ((driveflags[toupper(*pci->pszFileName) - 'A'] &
|
---|
2531 | DRIVE_INCLUDEFILES) != 0);
|
---|
2532 | else
|
---|
2533 | dcd->mask.fFilesIncluded = FALSE;
|
---|
2534 | if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
|
---|
2535 | FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
|
---|
2536 | WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
|
---|
2537 | else if (empty)
|
---|
2538 | *dcd->mask.szMask = 0;
|
---|
2539 | PrfWriteProfileData(fmprof, appname, "TreeFilter", &dcd->mask,
|
---|
2540 | sizeof(MASK));
|
---|
2541 | }
|
---|
2542 | break;
|
---|
2543 |
|
---|
2544 | case IDM_SHOWSORT:
|
---|
2545 | QuickPopup(hwnd, dcd, CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP),
|
---|
2546 | IDM_SORTSUBMENU);
|
---|
2547 | break;
|
---|
2548 |
|
---|
2549 | case IDM_SHOWSELECT:
|
---|
2550 | QuickPopup(hwnd, dcd, CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP),
|
---|
2551 | IDM_SELECTSUBMENU);
|
---|
2552 | break;
|
---|
2553 |
|
---|
2554 | case IDM_TREECNRVIEWSETTINGS:
|
---|
2555 | if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
|
---|
2556 | PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_TREECNRVIEWSETTINGS), mp2);
|
---|
2557 | else {
|
---|
2558 | WinDlgBox(HWND_DESKTOP,
|
---|
2559 | hwnd,
|
---|
2560 | CfgDlgProc,
|
---|
2561 | FM3ModHandle,
|
---|
2562 | CFG_FRAME,
|
---|
2563 | MPFROMLONG(IDM_TREECNRVIEWSETTINGS));
|
---|
2564 | }
|
---|
2565 | break;
|
---|
2566 |
|
---|
2567 | case IDM_WALKDIR:
|
---|
2568 | case IDM_OPENWALK:
|
---|
2569 | {
|
---|
2570 | CHAR newpath[CCHMAXPATH];
|
---|
2571 | PCNRITEM pci;
|
---|
2572 |
|
---|
2573 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2574 | if (pci && (INT) pci != -1) {
|
---|
2575 | strcpy(newpath, pci->pszFileName);
|
---|
2576 | MakeValidDir(newpath);
|
---|
2577 | }
|
---|
2578 | else
|
---|
2579 | strcpy(newpath, pFM2SaveDirectory);
|
---|
2580 | if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkAllDlgProc,
|
---|
2581 | FM3ModHandle, WALK_FRAME,
|
---|
2582 | MPFROMP(newpath)) || !*newpath)
|
---|
2583 | break;
|
---|
2584 | WinSendMsg(hwnd, UM_OPENWINDOWFORME, MPFROMP(newpath), MPVOID);
|
---|
2585 | }
|
---|
2586 | break;
|
---|
2587 |
|
---|
2588 | case IDM_HELP:
|
---|
2589 | if (hwndHelp) {
|
---|
2590 | if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
|
---|
2591 | PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
|
---|
2592 | else
|
---|
2593 | WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
|
---|
2594 | }
|
---|
2595 | break;
|
---|
2596 |
|
---|
2597 | case IDM_PARTITION:
|
---|
2598 | runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
2599 | NULL, NULL,
|
---|
2600 | "%s", PCSZ_MINILVMEXE);
|
---|
2601 | break;
|
---|
2602 |
|
---|
2603 | case IDM_PARTITIONDF:
|
---|
2604 | runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
2605 | NULL, NULL,
|
---|
2606 | "%s", PCSZ_DFSOS2EXE);
|
---|
2607 | break;
|
---|
2608 |
|
---|
2609 | case IDM_PARTITIONLVMG:
|
---|
2610 | runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
2611 | NULL, NULL,
|
---|
2612 | "%s", PCSZ_LVMGUICMD);
|
---|
2613 | break;
|
---|
2614 |
|
---|
2615 | case IDM_PARTITIONLVM:
|
---|
2616 | runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
2617 | NULL, NULL,
|
---|
2618 | "%s", PCSZ_LVMEXE);
|
---|
2619 | break;
|
---|
2620 |
|
---|
2621 | case IDM_PARTITIONFD:
|
---|
2622 | runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
2623 | NULL, NULL,
|
---|
2624 | "%s", PCSZ_FDISKPMEXE);
|
---|
2625 | break;
|
---|
2626 |
|
---|
2627 | case IDM_REFRESHREMOVABLES:
|
---|
2628 | {
|
---|
2629 | PFN Rediscover_PRMs;
|
---|
2630 | HMODULE hmod = 0;
|
---|
2631 | APIRET rc;
|
---|
2632 | CHAR objerr[CCHMAXPATH];
|
---|
2633 |
|
---|
2634 | rc = DosLoadModule(objerr, sizeof(objerr), "LVM", &hmod);
|
---|
2635 | if (!rc) {
|
---|
2636 | rc = DosQueryProcAddr(hmod, 70, NULL, &Rediscover_PRMs);
|
---|
2637 | if (!rc)
|
---|
2638 | Rediscover_PRMs(&rc);
|
---|
2639 | DosFreeModule(hmod);
|
---|
2640 | }
|
---|
2641 | if (!rc)
|
---|
2642 | PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
|
---|
2643 | break;
|
---|
2644 | }
|
---|
2645 |
|
---|
2646 | case IDM_SORTNAME:
|
---|
2647 | case IDM_SORTFILENAME:
|
---|
2648 | case IDM_SORTSIZE:
|
---|
2649 | case IDM_SORTEASIZE:
|
---|
2650 | case IDM_SORTFIRST:
|
---|
2651 | case IDM_SORTLAST:
|
---|
2652 | case IDM_SORTLWDATE:
|
---|
2653 | case IDM_SORTLADATE:
|
---|
2654 | case IDM_SORTCRDATE:
|
---|
2655 | TreesortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
|
---|
2656 | case IDM_SORTDIRSFIRST:
|
---|
2657 | case IDM_SORTDIRSLAST:
|
---|
2658 | case IDM_SORTREVERSE:
|
---|
2659 | switch (SHORT1FROMMP(mp1)) {
|
---|
2660 | case IDM_SORTFILENAME:
|
---|
2661 | TreesortFlags |= SORT_FILENAME;
|
---|
2662 | break;
|
---|
2663 | case IDM_SORTSIZE:
|
---|
2664 | TreesortFlags |= SORT_SIZE;
|
---|
2665 | break;
|
---|
2666 | case IDM_SORTEASIZE:
|
---|
2667 | TreesortFlags |= SORT_EASIZE;
|
---|
2668 | break;
|
---|
2669 | case IDM_SORTFIRST:
|
---|
2670 | TreesortFlags |= SORT_FIRSTEXTENSION;
|
---|
2671 | break;
|
---|
2672 | case IDM_SORTLAST:
|
---|
2673 | TreesortFlags |= SORT_LASTEXTENSION;
|
---|
2674 | break;
|
---|
2675 | case IDM_SORTLWDATE:
|
---|
2676 | TreesortFlags |= SORT_LWDATE;
|
---|
2677 | break;
|
---|
2678 | case IDM_SORTLADATE:
|
---|
2679 | TreesortFlags |= SORT_LADATE;
|
---|
2680 | break;
|
---|
2681 | case IDM_SORTCRDATE:
|
---|
2682 | TreesortFlags |= SORT_CRDATE;
|
---|
2683 | break;
|
---|
2684 | case IDM_SORTDIRSFIRST:
|
---|
2685 | if (TreesortFlags & SORT_DIRSFIRST)
|
---|
2686 | TreesortFlags &= (~SORT_DIRSFIRST);
|
---|
2687 | else {
|
---|
2688 | TreesortFlags |= SORT_DIRSFIRST;
|
---|
2689 | TreesortFlags &= (~SORT_DIRSLAST);
|
---|
2690 | }
|
---|
2691 | break;
|
---|
2692 | case IDM_SORTDIRSLAST:
|
---|
2693 | if (TreesortFlags & SORT_DIRSLAST)
|
---|
2694 | TreesortFlags &= (~SORT_DIRSLAST);
|
---|
2695 | else {
|
---|
2696 | TreesortFlags |= SORT_DIRSLAST;
|
---|
2697 | TreesortFlags &= (~SORT_DIRSFIRST);
|
---|
2698 | }
|
---|
2699 | break;
|
---|
2700 | case IDM_SORTREVERSE:
|
---|
2701 | if (TreesortFlags & SORT_REVERSE)
|
---|
2702 | TreesortFlags &= (~SORT_REVERSE);
|
---|
2703 | else
|
---|
2704 | TreesortFlags |= SORT_REVERSE;
|
---|
2705 | break;
|
---|
2706 | }
|
---|
2707 | PrfWriteProfileData(fmprof, appname, "TreeSort", &TreesortFlags,
|
---|
2708 | sizeof(INT));
|
---|
2709 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
|
---|
2710 | break;
|
---|
2711 |
|
---|
2712 | case IDM_COLLECT:
|
---|
2713 | case IDM_GREP:
|
---|
2714 | if (!Collector) {
|
---|
2715 |
|
---|
2716 | HWND hwndC;
|
---|
2717 | SWP swp;
|
---|
2718 |
|
---|
2719 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
2720 | !fAutoTile &&
|
---|
2721 | (!fExternalCollector && *(ULONG *) realappname == FM3UL))
|
---|
2722 | GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
|
---|
2723 | hwndC = StartCollector((fExternalCollector ||
|
---|
2724 | *(ULONG *) realappname != FM3UL) ?
|
---|
2725 | HWND_DESKTOP : dcd->hwndParent, 4);
|
---|
2726 | if (hwndC) {
|
---|
2727 | if (!ParentIsDesktop(hwnd,
|
---|
2728 | dcd->hwndParent) &&
|
---|
2729 | !fAutoTile &&
|
---|
2730 | (!fExternalCollector && *(ULONG *) realappname == FM3UL))
|
---|
2731 | WinSetWindowPos(hwndC,
|
---|
2732 | HWND_TOP,
|
---|
2733 | swp.x,
|
---|
2734 | swp.y,
|
---|
2735 | swp.cx,
|
---|
2736 | swp.cy,
|
---|
2737 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
|
---|
2738 | else if (!ParentIsDesktop(hwnd,
|
---|
2739 | dcd->hwndParent) &&
|
---|
2740 | fAutoTile && *(ULONG *) realappname == FM3UL)
|
---|
2741 | TileChildren(dcd->hwndParent, TRUE);
|
---|
2742 | }
|
---|
2743 | WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
|
---|
2744 | DosSleep(100);//05 Aug 07 GKY 250
|
---|
2745 | }
|
---|
2746 | else
|
---|
2747 | StartCollector(dcd->hwndParent, 4);
|
---|
2748 | if (SHORT1FROMMP(mp1) == IDM_GREP) {
|
---|
2749 | PCNRITEM pci = NULL;
|
---|
2750 |
|
---|
2751 | pci = WinSendMsg(hwnd,
|
---|
2752 | CM_QUERYRECORDEMPHASIS,
|
---|
2753 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
---|
2754 | if (pci && (INT) pci != -1)
|
---|
2755 | PostMsg(Collector, WM_COMMAND,
|
---|
2756 | MPFROM2SHORT(UM_GREP, 0), MPFROMP(pci->pszFileName));
|
---|
2757 | else
|
---|
2758 | PostMsg(Collector, WM_COMMAND,
|
---|
2759 | MPFROM2SHORT(IDM_GREP, 0), MPVOID);
|
---|
2760 | }
|
---|
2761 | else
|
---|
2762 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
|
---|
2763 | break;
|
---|
2764 |
|
---|
2765 | case IDM_COLLECTOR:
|
---|
2766 | DosSleep(32);//05 Aug 07 GKY 64
|
---|
2767 | {
|
---|
2768 | CHAR **list;
|
---|
2769 |
|
---|
2770 | list = BuildList(hwnd);
|
---|
2771 | if (list) {
|
---|
2772 | if (Collector) {
|
---|
2773 | if (!PostMsg(Collector, WM_COMMAND,
|
---|
2774 | MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
|
---|
2775 | FreeList(list);
|
---|
2776 | }
|
---|
2777 | else
|
---|
2778 | FreeList(list);
|
---|
2779 | }
|
---|
2780 | }
|
---|
2781 | break;
|
---|
2782 |
|
---|
2783 | case IDM_COLLAPSEALL:
|
---|
2784 | WinSendMsg(hwnd, CM_COLLAPSETREE, MPVOID, MPVOID);
|
---|
2785 | break;
|
---|
2786 |
|
---|
2787 | case IDM_COLLAPSE:
|
---|
2788 | case IDM_EXPAND:
|
---|
2789 | {
|
---|
2790 | PCNRITEM pci = NULL;
|
---|
2791 |
|
---|
2792 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2793 | if (pci && (INT) pci != -1) {
|
---|
2794 | if (pci->flags & RECFLAGS_UNDERENV)
|
---|
2795 | break;
|
---|
2796 | PostMsg(dcd->hwndObject, UM_EXPAND, mp1, MPFROMP(pci));
|
---|
2797 | }
|
---|
2798 | }
|
---|
2799 | break;
|
---|
2800 |
|
---|
2801 | case IDM_UPDATE:
|
---|
2802 | {
|
---|
2803 | PCNRITEM pci = (PCNRITEM)CurrentRecord(hwnd);
|
---|
2804 | if (pci && (INT)pci != -1) {
|
---|
2805 | struct
|
---|
2806 | {
|
---|
2807 | ULONG serial;
|
---|
2808 | CHAR volumelength;
|
---|
2809 | CHAR volumelabel[CCHMAXPATH];
|
---|
2810 | }
|
---|
2811 | volser;
|
---|
2812 | INT x = toupper(*pci->pszFileName) - 'A';
|
---|
2813 | CHAR FileSystem[CCHMAXPATH], szBuf[CCHMAXPATH];
|
---|
2814 |
|
---|
2815 | UINT driveflag = driveflags[x];
|
---|
2816 | if (pci->attrFile & FILE_DIRECTORY) {
|
---|
2817 | if (pci->flags & RECFLAGS_UNDERENV)
|
---|
2818 | break;
|
---|
2819 | DosRequestMutexSem(hmtxScanning, SEM_INDEFINITE_WAIT);
|
---|
2820 | DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
|
---|
2821 | UnFlesh(hwnd, pci);
|
---|
2822 | // Check if drive type might need update
|
---|
2823 | if ((driveflag & (DRIVE_INVALID | DRIVE_NOPRESCAN)) ||
|
---|
2824 | (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno)) {
|
---|
2825 | DriveFlagsOne(x, FileSystem, &volser);
|
---|
2826 | driveflag = driveflags[x];
|
---|
2827 | if (driveflag & DRIVE_INVALID)
|
---|
2828 | pci->rc.hptrIcon = hptrDunno;
|
---|
2829 | else if (strlen(pci->pszFileName) < 4) {
|
---|
2830 | SelectDriveIcon(pci);
|
---|
2831 | if (fShowFSTypeInTree || fShowDriveLabelInTree) {
|
---|
2832 | strcpy(szBuf, pci->pszFileName);
|
---|
2833 | strcat(szBuf, " [");
|
---|
2834 | strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
|
---|
2835 | strcat(szBuf, "]");
|
---|
2836 | pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
|
---|
2837 | pci->rc.pszIcon = pci->pszDisplayName;
|
---|
2838 | }
|
---|
2839 | }
|
---|
2840 | WinSendMsg(hwnd,
|
---|
2841 | CM_INVALIDATERECORD,
|
---|
2842 | MPFROMP(&pci),
|
---|
2843 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
|
---|
2844 | if (hwndMain)
|
---|
2845 | PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
|
---|
2846 | }
|
---|
2847 | if (~driveflag & DRIVE_INVALID)
|
---|
2848 | Flesh(hwnd, pci);
|
---|
2849 | DosPostEventSem(hevTreeCnrScanComplete);
|
---|
2850 | }
|
---|
2851 | }
|
---|
2852 | }
|
---|
2853 | break;
|
---|
2854 |
|
---|
2855 | case IDM_RESCAN:
|
---|
2856 | PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
|
---|
2857 | break;
|
---|
2858 |
|
---|
2859 | case IDM_RESORT:
|
---|
2860 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
|
---|
2861 | break;
|
---|
2862 |
|
---|
2863 | case IDM_TEXT:
|
---|
2864 | case IDM_MINIICONS:
|
---|
2865 | {
|
---|
2866 | CNRINFO cnri;
|
---|
2867 |
|
---|
2868 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
2869 | cnri.cb = sizeof(CNRINFO);
|
---|
2870 | WinSendMsg(hwnd,
|
---|
2871 | CM_QUERYCNRINFO,
|
---|
2872 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
2873 | if (SHORT1FROMMP(mp1) == IDM_MINIICONS) {
|
---|
2874 | if (cnri.flWindowAttr & CV_MINI)
|
---|
2875 | cnri.flWindowAttr &= (~CV_MINI);
|
---|
2876 | else
|
---|
2877 | cnri.flWindowAttr |= CV_MINI;
|
---|
2878 | }
|
---|
2879 | else {
|
---|
2880 | if (cnri.flWindowAttr & CV_TEXT) {
|
---|
2881 | cnri.flWindowAttr &= (~CV_TEXT);
|
---|
2882 | cnri.flWindowAttr |= CV_ICON;
|
---|
2883 | }
|
---|
2884 | else {
|
---|
2885 | cnri.flWindowAttr &= (~CV_ICON);
|
---|
2886 | cnri.flWindowAttr |= CV_TEXT;
|
---|
2887 | }
|
---|
2888 | }
|
---|
2889 | dcd->flWindowAttr = cnri.flWindowAttr;
|
---|
2890 | PrfWriteProfileData(fmprof,
|
---|
2891 | appname,
|
---|
2892 | "TreeflWindowAttr",
|
---|
2893 | &cnri.flWindowAttr, sizeof(ULONG));
|
---|
2894 | WinSendMsg(hwnd,
|
---|
2895 | CM_SETCNRINFO,
|
---|
2896 | MPFROMP(&cnri),
|
---|
2897 | MPFROMLONG(CMA_FLWINDOWATTR | CMA_TREEICON |
|
---|
2898 | CMA_SLTREEBITMAPORICON));
|
---|
2899 | }
|
---|
2900 | break;
|
---|
2901 |
|
---|
2902 | case IDM_SIZES:
|
---|
2903 | case IDM_DRVFLAGS:
|
---|
2904 | case IDM_SHOWALLFILES:
|
---|
2905 | case IDM_UNDELETE:
|
---|
2906 | case IDM_OPTIMIZE:
|
---|
2907 | case IDM_CHKDSK:
|
---|
2908 | case IDM_FORMAT:
|
---|
2909 | case IDM_MKDIR:
|
---|
2910 | case IDM_LOCK:
|
---|
2911 | case IDM_UNLOCK:
|
---|
2912 | case IDM_EJECT:
|
---|
2913 | case IDM_CLOSETRAY:
|
---|
2914 | {
|
---|
2915 | PCNRITEM pci;
|
---|
2916 |
|
---|
2917 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2918 | if (pci && (INT) pci != -1)
|
---|
2919 | CommonDriveCmd(hwnd, pci->pszFileName, SHORT1FROMMP(mp1));
|
---|
2920 | }
|
---|
2921 | break;
|
---|
2922 |
|
---|
2923 | case IDM_SAVETOLIST:
|
---|
2924 | WinDlgBox(HWND_DESKTOP,
|
---|
2925 | hwnd,
|
---|
2926 | SaveListDlgProc, FM3ModHandle, SAV_FRAME, MPFROMP(&hwnd));
|
---|
2927 | break;
|
---|
2928 |
|
---|
2929 | case IDM_DELETE:
|
---|
2930 | case IDM_PERMDELETE:
|
---|
2931 | case IDM_MOVE:
|
---|
2932 | case IDM_WPSMOVE:
|
---|
2933 | case IDM_WILDMOVE:
|
---|
2934 | case IDM_RENAME:
|
---|
2935 | {
|
---|
2936 | PCNRITEM pci;
|
---|
2937 |
|
---|
2938 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2939 | if (pci && (INT) pci != -1) {
|
---|
2940 | if (pci->flags & RECFLAGS_UNDERENV)
|
---|
2941 | break;
|
---|
2942 | }
|
---|
2943 | }
|
---|
2944 | // else intentional fallthru
|
---|
2945 | case IDM_ATTRS:
|
---|
2946 | case IDM_INFO:
|
---|
2947 | case IDM_COPY:
|
---|
2948 | case IDM_WPSCOPY:
|
---|
2949 | case IDM_WILDCOPY:
|
---|
2950 | case IDM_DOITYOURSELF:
|
---|
2951 | case IDM_OPENWINDOW:
|
---|
2952 | case IDM_OPENSETTINGS:
|
---|
2953 | case IDM_OPENDEFAULT:
|
---|
2954 | case IDM_OPENICON:
|
---|
2955 | case IDM_OPENDETAILS:
|
---|
2956 | case IDM_OPENTREE:
|
---|
2957 | case IDM_SHADOW:
|
---|
2958 | case IDM_SHADOW2:
|
---|
2959 | case IDM_COMPARE:
|
---|
2960 | case IDM_VIEW:
|
---|
2961 | case IDM_VIEWTEXT:
|
---|
2962 | case IDM_VIEWBINARY:
|
---|
2963 | case IDM_EDIT:
|
---|
2964 | case IDM_EDITTEXT:
|
---|
2965 | case IDM_EDITBINARY:
|
---|
2966 | case IDM_EAS:
|
---|
2967 | case IDM_SUBJECT:
|
---|
2968 | case IDM_APPENDTOCLIP:
|
---|
2969 | case IDM_SAVETOCLIP:
|
---|
2970 | case IDM_ARCHIVE:
|
---|
2971 | case IDM_MCIPLAY:
|
---|
2972 | case IDM_UUDECODE:
|
---|
2973 | {
|
---|
2974 | LISTINFO *li;
|
---|
2975 | ULONG action = UM_ACTION;
|
---|
2976 | # ifdef FORTIFY
|
---|
2977 | Fortify_EnterScope();
|
---|
2978 | # endif
|
---|
2979 | li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
|
---|
2980 | if (li) {
|
---|
2981 | li->type = SHORT1FROMMP(mp1);
|
---|
2982 | li->hwnd = hwnd;
|
---|
2983 | li->list = BuildList(hwnd);
|
---|
2984 | if (!li->list || !li->list[0]) {
|
---|
2985 | free(li);
|
---|
2986 | break;
|
---|
2987 | }
|
---|
2988 | if (IsRoot(li->list[0])) {
|
---|
2989 | switch (SHORT1FROMMP(mp1)) {
|
---|
2990 | case IDM_MOVE:
|
---|
2991 | case IDM_COPY:
|
---|
2992 | case IDM_WILDCOPY:
|
---|
2993 | case IDM_WILDMOVE:
|
---|
2994 | case IDM_WPSMOVE:
|
---|
2995 | case IDM_WPSCOPY:
|
---|
2996 | case IDM_RENAME:
|
---|
2997 | case IDM_DELETE:
|
---|
2998 | case IDM_PERMDELETE:
|
---|
2999 | mp1 = MPFROM2SHORT(IDM_INFO, SHORT2FROMMP(mp1));
|
---|
3000 | li->type = IDM_INFO;
|
---|
3001 | }
|
---|
3002 | }
|
---|
3003 | switch (SHORT1FROMMP(mp1)) {
|
---|
3004 | case IDM_APPENDTOCLIP:
|
---|
3005 | case IDM_SAVETOCLIP:
|
---|
3006 | case IDM_ARCHIVE:
|
---|
3007 | case IDM_DELETE:
|
---|
3008 | case IDM_PERMDELETE:
|
---|
3009 | case IDM_ATTRS:
|
---|
3010 | case IDM_SHADOW:
|
---|
3011 | case IDM_SHADOW2:
|
---|
3012 | case IDM_DOITYOURSELF:
|
---|
3013 | case IDM_EAS:
|
---|
3014 | case IDM_VIEW:
|
---|
3015 | case IDM_VIEWTEXT:
|
---|
3016 | case IDM_VIEWBINARY:
|
---|
3017 | case IDM_EDIT:
|
---|
3018 | case IDM_EDITTEXT:
|
---|
3019 | case IDM_EDITBINARY:
|
---|
3020 | case IDM_MCIPLAY:
|
---|
3021 | action = UM_MASSACTION;
|
---|
3022 | }
|
---|
3023 | if (li->type == IDM_DELETE)
|
---|
3024 | ignorereadonly = FALSE;
|
---|
3025 | if (SHORT1FROMMP(mp1) == IDM_SHADOW ||
|
---|
3026 | SHORT1FROMMP(mp1) == IDM_SHADOW2)
|
---|
3027 | *li->targetpath = 0;
|
---|
3028 | if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
|
---|
3029 | Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
|
---|
3030 | FreeListInfo(li);
|
---|
3031 | }
|
---|
3032 | }
|
---|
3033 | # ifdef FORTIFY
|
---|
3034 | Fortify_LeaveScope();
|
---|
3035 | # endif
|
---|
3036 | }
|
---|
3037 | break;
|
---|
3038 |
|
---|
3039 | default:
|
---|
3040 | if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
|
---|
3041 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
|
---|
3042 |
|
---|
3043 | INT x;
|
---|
3044 |
|
---|
3045 | if (!cmdloaded)
|
---|
3046 | load_commands();
|
---|
3047 | x = SHORT1FROMMP(mp1);// - IDM_COMMANDSTART;
|
---|
3048 | if (x >= 0) {
|
---|
3049 | //x++;
|
---|
3050 | RunCommand(hwnd, x);
|
---|
3051 | if (fUnHilite)
|
---|
3052 | UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
|
---|
3053 | }
|
---|
3054 | }
|
---|
3055 | break;
|
---|
3056 | }
|
---|
3057 | }
|
---|
3058 | return 0;
|
---|
3059 |
|
---|
3060 | case WM_SAVEAPPLICATION:
|
---|
3061 | if (dcd && !ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
3062 |
|
---|
3063 | SWP swp, swpP;
|
---|
3064 | INT ratio;
|
---|
3065 |
|
---|
3066 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
---|
3067 | if (!(swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE | SWP_HIDE))) {
|
---|
3068 | WinQueryWindowPos(dcd->hwndParent, &swpP);
|
---|
3069 | if (swp.cx) {
|
---|
3070 | ratio = (swpP.cx * 100) / swp.cx;
|
---|
3071 | if (ratio > 0)
|
---|
3072 | PrfWriteProfileData(fmprof, appname, "TreeWindowRatio",
|
---|
3073 | &ratio, sizeof(INT));
|
---|
3074 | }
|
---|
3075 | }
|
---|
3076 | }
|
---|
3077 | else if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
3078 |
|
---|
3079 | SWP swp;
|
---|
3080 |
|
---|
3081 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
---|
3082 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
|
---|
3083 | WinStoreWindowPos((CHAR *) FM2Str, "VTreeWindowPos", dcd->hwndFrame);
|
---|
3084 | }
|
---|
3085 | break;
|
---|
3086 |
|
---|
3087 | case UM_MINIMIZE:
|
---|
3088 | if (dcd && hwndMain) {
|
---|
3089 | fOkayMinimize = TRUE;
|
---|
3090 | if (dcd->hwndObject && !fDummy) {
|
---|
3091 | DosSleep(50);//05 Aug 07 GKY 100
|
---|
3092 | if (!fDummy) {
|
---|
3093 | fOkayMinimize = FALSE;
|
---|
3094 | WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
|
---|
3095 | dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0,
|
---|
3096 | SWP_MINIMIZE | SWP_DEACTIVATE);
|
---|
3097 | }
|
---|
3098 | }
|
---|
3099 | }
|
---|
3100 | return 0;
|
---|
3101 |
|
---|
3102 | case UM_MAXIMIZE:
|
---|
3103 | if (dcd || hwndMain)
|
---|
3104 | WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
|
---|
3105 | dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0, SWP_MAXIMIZE |
|
---|
3106 | SWP_SHOW);
|
---|
3107 | return 0;
|
---|
3108 |
|
---|
3109 | case UM_CLOSE:
|
---|
3110 | {
|
---|
3111 | HWND hwndParent = WinQueryWindow(WinQueryWindow(WinQueryWindow(hwnd,
|
---|
3112 | QW_PARENT),
|
---|
3113 | QW_PARENT), QW_PARENT);
|
---|
3114 |
|
---|
3115 | if (!mp1) {
|
---|
3116 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
3117 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
3118 | if (hwndParent && !ParentIsDesktop(hwnd, hwndParent))
|
---|
3119 | WinDestroyWindow(hwndParent);
|
---|
3120 | }
|
---|
3121 | else
|
---|
3122 | WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
3123 | QW_PARENT));
|
---|
3124 | }
|
---|
3125 | return 0;
|
---|
3126 |
|
---|
3127 | case WM_CLOSE:
|
---|
3128 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
|
---|
3129 | if (dcd)
|
---|
3130 | dcd->stopflag++;
|
---|
3131 | if (dcd && dcd->hwndObject) {
|
---|
3132 | // kill object window
|
---|
3133 | if (WinIsWindow((HAB) 0, dcd->hwndObject)) {
|
---|
3134 | if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
|
---|
3135 | WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
|
---|
3136 | }
|
---|
3137 | }
|
---|
3138 | else
|
---|
3139 | WinSendMsg(hwnd, UM_CLOSE, MPFROMLONG(1), MPVOID);
|
---|
3140 | return 0;
|
---|
3141 |
|
---|
3142 | case WM_DESTROY:
|
---|
3143 | # ifdef FORTIFY
|
---|
3144 | DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
|
---|
3145 | # endif
|
---|
3146 | if (TreeCnrMenu)
|
---|
3147 | WinDestroyWindow(TreeCnrMenu);
|
---|
3148 | if (DirMenu)
|
---|
3149 | WinDestroyWindow(DirMenu);
|
---|
3150 | if (FileMenu)
|
---|
3151 | WinDestroyWindow(FileMenu);
|
---|
3152 | TreeCnrMenu = FileMenu = DirMenu = (HWND) 0;
|
---|
3153 | EmptyCnr(hwnd);
|
---|
3154 | if (apphead) {
|
---|
3155 | APPNOTIFY *info, *next;
|
---|
3156 |
|
---|
3157 | info = apphead;
|
---|
3158 | while (info) {
|
---|
3159 | next = info->next;
|
---|
3160 | free(info);
|
---|
3161 | info = next;
|
---|
3162 | }
|
---|
3163 | apphead = apptail = NULL;
|
---|
3164 | }
|
---|
3165 | # ifdef FORTIFY
|
---|
3166 | Fortify_LeaveScope();
|
---|
3167 | # endif
|
---|
3168 | break; // WM_DESTROY
|
---|
3169 | } // switch
|
---|
3170 | if (dcd && dcd->oldproc){
|
---|
3171 | return dcd->oldproc(hwnd, msg, mp1, mp2);
|
---|
3172 | }
|
---|
3173 | else
|
---|
3174 | return PFNWPCnr(hwnd, msg, mp1, mp2);
|
---|
3175 | }
|
---|
3176 |
|
---|
3177 | /**
|
---|
3178 | * Start drive tree container
|
---|
3179 | * @returns tree handle or NULLHANDLE
|
---|
3180 | */
|
---|
3181 |
|
---|
3182 | HWND StartTreeCnr(HWND hwndParent, ULONG flags)
|
---|
3183 | {
|
---|
3184 | /**
|
---|
3185 | * bitmapped flags:
|
---|
3186 | * 0x00000001 = don't close app when window closes
|
---|
3187 | * 0x00000002 = no frame controls
|
---|
3188 | * 0x00000004 = no close or move button
|
---|
3189 | */
|
---|
3190 |
|
---|
3191 | HWND hwndFrame = NULLHANDLE;
|
---|
3192 | HWND hwndSysMenu = NULLHANDLE;
|
---|
3193 | HWND hwndClient;
|
---|
3194 | ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
|
---|
3195 | FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
|
---|
3196 | DIRCNRDATA *dcd;
|
---|
3197 |
|
---|
3198 | if (!hwndParent)
|
---|
3199 | hwndParent = HWND_DESKTOP;
|
---|
3200 | if (ParentIsDesktop(hwndParent, hwndParent))
|
---|
3201 | FrameFlags |= (FCF_TASKLIST | FCF_MENU);
|
---|
3202 | if (flags & 2)
|
---|
3203 | FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
|
---|
3204 | FCF_MINMAX | FCF_ICON));
|
---|
3205 | hwndFrame = WinCreateStdWindow(hwndParent,
|
---|
3206 | WS_VISIBLE,
|
---|
3207 | &FrameFlags,
|
---|
3208 | (CHAR *) WC_TREECONTAINER,
|
---|
3209 | NULL,
|
---|
3210 | WS_VISIBLE | fwsAnimate,
|
---|
3211 | FM3ModHandle, TREE_FRAME, &hwndClient);
|
---|
3212 | if (hwndParent != HWND_DESKTOP) {
|
---|
3213 | hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
|
---|
3214 | if (hwndSysMenu != NULLHANDLE)
|
---|
3215 | WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
|
---|
3216 | MPFROM2SHORT(SC_CLOSE, TRUE),
|
---|
3217 | MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
|
---|
3218 | if (!fFreeTree)
|
---|
3219 | WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
|
---|
3220 | MPFROM2SHORT(SC_MOVE, TRUE),
|
---|
3221 | MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
|
---|
3222 | }
|
---|
3223 | if (hwndFrame && hwndClient) {
|
---|
3224 | # ifdef FORTIFY
|
---|
3225 | Fortify_EnterScope();
|
---|
3226 | # endif
|
---|
3227 | dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
|
---|
3228 | if (!dcd) {
|
---|
3229 | Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_OUTOFMEMORY));
|
---|
3230 | PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
|
---|
3231 | hwndFrame = (HWND) 0;
|
---|
3232 | }
|
---|
3233 | else {
|
---|
3234 | SWP swp;
|
---|
3235 | WinQueryWindowPos(hwndFrame, &swp);
|
---|
3236 | if (*(ULONG *) realappname == FM3UL) {
|
---|
3237 | if (!WinCreateWindow(hwndFrame,
|
---|
3238 | (CHAR *) WC_TREEOPENBUTTON,
|
---|
3239 | "#303",
|
---|
3240 | WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | BS_BITMAP,
|
---|
3241 | ((swp.cx -
|
---|
3242 | WinQuerySysValue(HWND_DESKTOP,
|
---|
3243 | SV_CXMINMAXBUTTON)) -
|
---|
3244 | WinQuerySysValue(HWND_DESKTOP,
|
---|
3245 | SV_CXMINMAXBUTTON) / 2) -
|
---|
3246 | WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER),
|
---|
3247 | (swp.cy -
|
---|
3248 | WinQuerySysValue(HWND_DESKTOP,
|
---|
3249 | SV_CYMINMAXBUTTON)) -
|
---|
3250 | WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER),
|
---|
3251 | WinQuerySysValue(HWND_DESKTOP,
|
---|
3252 | SV_CXMINMAXBUTTON) / 2,
|
---|
3253 | WinQuerySysValue(HWND_DESKTOP,
|
---|
3254 | SV_CYMINMAXBUTTON), hwndFrame,
|
---|
3255 | HWND_TOP, IDM_OPENWINDOW, NULL, NULL)) {
|
---|
3256 | Win_Error(hwndFrame, hwndParent, pszSrcFile, __LINE__,
|
---|
3257 | PCSZ_WINCREATEWINDOW);
|
---|
3258 | }
|
---|
3259 | }
|
---|
3260 | else {
|
---|
3261 | if (!WinCreateWindow(hwndFrame,
|
---|
3262 | (CHAR *) WC_TREESTATUS,
|
---|
3263 | (CHAR *) GetPString(IDS_YOUAREHERETEXT),
|
---|
3264 | WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER,
|
---|
3265 | swp.x + 4 + WinQuerySysValue(HWND_DESKTOP,
|
---|
3266 | SV_CXSIZEBORDER),
|
---|
3267 | swp.cy - (22 + WinQuerySysValue(HWND_DESKTOP,
|
---|
3268 | SV_CYSIZEBORDER)),
|
---|
3269 | (swp.cx - 8) - (WinQuerySysValue(HWND_DESKTOP,
|
---|
3270 | SV_CXSIZEBORDER)
|
---|
3271 | * 2), 22, hwndFrame, HWND_TOP,
|
---|
3272 | MAIN_STATUS, NULL, NULL)) {
|
---|
3273 | Win_Error(hwndFrame, hwndParent, pszSrcFile, __LINE__,
|
---|
3274 | PCSZ_WINCREATEWINDOW);
|
---|
3275 | }
|
---|
3276 | }
|
---|
3277 | memset(dcd, 0, sizeof(DIRCNRDATA));
|
---|
3278 | dcd->size = sizeof(DIRCNRDATA);
|
---|
3279 | dcd->type = TREE_FRAME;
|
---|
3280 | dcd->dontclose = (flags & 1) != 0;
|
---|
3281 | dcd->hwndParent = hwndParent ? hwndParent : HWND_DESKTOP;
|
---|
3282 | dcd->hwndClient = hwndClient;
|
---|
3283 | dcd->hwndFrame = hwndFrame;
|
---|
3284 | {
|
---|
3285 | PFNWP oldproc;
|
---|
3286 |
|
---|
3287 | oldproc = WinSubclassWindow(hwndFrame, TreeFrameWndProc);
|
---|
3288 | WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
|
---|
3289 | oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR),
|
---|
3290 | (PFNWP) TreeTitleWndProc);
|
---|
3291 | WinSetWindowPtr(WinWindowFromID(hwndFrame, FID_TITLEBAR),
|
---|
3292 | QWL_USER, (PVOID) oldproc);
|
---|
3293 | }
|
---|
3294 | dcd->hwndCnr = WinCreateWindow(hwndClient,
|
---|
3295 | WC_CONTAINER,
|
---|
3296 | NULL,
|
---|
3297 | CCS_AUTOPOSITION | CCS_MINIICONS |
|
---|
3298 | CCS_MINIRECORDCORE,
|
---|
3299 | 0,
|
---|
3300 | 0,
|
---|
3301 | 0,
|
---|
3302 | 0,
|
---|
3303 | hwndClient,
|
---|
3304 | HWND_TOP, (ULONG) TREE_CNR, NULL, NULL);
|
---|
3305 | if (!dcd->hwndCnr) {
|
---|
3306 | Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
|
---|
3307 | PCSZ_WINCREATEWINDOW);
|
---|
3308 | PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
|
---|
3309 | free(dcd);
|
---|
3310 | dcd = NULL;
|
---|
3311 | hwndFrame = (HWND) 0;
|
---|
3312 | }
|
---|
3313 | else {
|
---|
3314 | WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
|
---|
3315 | if (ParentIsDesktop(hwndFrame, hwndParent)) {
|
---|
3316 | WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "VTree");
|
---|
3317 | FixSwitchList(hwndFrame, "VTree");
|
---|
3318 | }
|
---|
3319 | else {
|
---|
3320 | WinSetWindowText(hwndFrame, (CHAR *) GetPString(IDS_TREETEXT));
|
---|
3321 | WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR),
|
---|
3322 | (CHAR *) GetPString(IDS_TREETEXT));
|
---|
3323 | }
|
---|
3324 | dcd->oldproc = WinSubclassWindow(dcd->hwndCnr, TreeCnrWndProc);
|
---|
3325 | // fixme to document 01 test?
|
---|
3326 | if (dcd->oldproc == 0)
|
---|
3327 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
3328 | "WinSubclassWindow");
|
---|
3329 | if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
|
---|
3330 | WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
|
---|
3331 | }
|
---|
3332 | }
|
---|
3333 | # ifdef FORTIFY
|
---|
3334 | if (dcd)
|
---|
3335 | Fortify_ChangeScope(dcd, -1);
|
---|
3336 | Fortify_LeaveScope();
|
---|
3337 | if (dcd)
|
---|
3338 | Fortify_ChangeScope(dcd, +1);
|
---|
3339 | # endif
|
---|
3340 | }
|
---|
3341 | WinShowWindow(hwndFrame, FALSE);
|
---|
3342 | return hwndFrame;
|
---|
3343 | }
|
---|
3344 |
|
---|
3345 | #pragma alloc_text(TREECNR,TreeCnrWndProc,TreeObjWndProc,TreeClientWndProc)
|
---|
3346 | #pragma alloc_text(TREECNR,TreeFrameWndProc,TreeTitleWndProc,ShowTreeRec)
|
---|
3347 | #pragma alloc_text(TREECNR,TreeStatProc,OpenButtonProc)
|
---|
3348 | #pragma alloc_text(STARTUP,StartTreeCnr)
|
---|