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