source: trunk/dll/treecnr.c@ 1877

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

Remove debug code

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