source: trunk/dll/treecnr.c@ 1865

Last change on this file since 1865 was 1865, checked in by Steven Levine, 10 years ago

Correct WaitFleshWorkListEmpty typo that could corrupt heap
Protect some read-only strings from overwriting

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