source: trunk/dll/treecnr.c@ 1375

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

Updated history; comments minor code cleanup for recent changes

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