source: trunk/dll/treecnr.c@ 1434

Last change on this file since 1434 was 1434, checked in by Gregg Young, 16 years ago

Update show label or FS in tree to initialize as driveonly and fixed typo which caused rescan to fail after the value was changed. Renamed some variables.

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