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