source: trunk/dll/treecnr.c@ 1871

Last change on this file since 1871 was 1871, checked in by Gregg Young, 10 years ago

Create CollapseAll and modify ExpandAll to reduce code overhead both to try and speed drive expansion. Change ExpandAll to allow it to loop in UM_EXPAND until until drive is completely expanded. Changes were need to work with Flesh, Stubby and UnFlesh being moved to a thread. Add code for Flesh to skip the directory entry added by Stubby (eliminate use of NULL/Nullstr pszFileNames by Stubby). Add code in Stubby to insert a complete container item. Add a flag to indicate when a directory needed to be Fleshed. Get expand and switch code to work with Flesh, UnFlesh and Stubby running on a thread. Loop and idle ExpandAll; Move tree expand to a thread; Have ShowTreeRec wait for the Flesh thread. Add a correction factor so directories don't get placed above the top of the tree container when a large drive has been expanded. Debug is mostly still in but all turned off.

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