source: trunk/dll/treecnr.c@ 1480

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

Fix failure to correctly check for large file support in FindSwapperDat fall back code minor streamling. Add LVM.EXE to partition submenu. Stop using xDosQueryAppType where the file name it is passed is already a local stack variable. Correct a typo in several file header comments.

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