source: trunk/dll/treecnr.c@ 1867

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

Rework ShowTreeRec to avoid retry failures
Rework WaitFleshWorkListEmpty to let PM do some work before returning to caller

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