source: trunk/dll/treecnr.c@ 1407

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

Remove comment that doesn't apply to treecnr.c

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