source: trunk/dll/treecnr.c@ 1828

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

Comments for CS [1827}

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