source: trunk/dll/treecnr.c@ 1446

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

Fix problem with NOPRESCANDRIVES updating subdirectories with drive icon and full pathname. More streamlining of Tree container scan code

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