source: trunk/dll/treecnr.c@ 1366

Last change on this file since 1366 was 1366, checked in by Gregg Young, 17 years ago

Seek and scan called from the dir or drive context menu opens seek and scan and provides the path to start the search from. (Ticket 167)

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