source: trunk/dll/treecnr.c@ 1400

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

Remainder of changes to rename commafmt.h/c (Ticket 28, 82); Additional strings moved to PCSZs in init.c (Ticket 6); Added WriteDetailsSwitches used it and LoadDetailsSwitches to consolidate inline code (Ticket 343, 344)

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