source: trunk/dll/treecnr.c@ 1425

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

Changed status1 line for drives to show label/systype not shown in tree or both if nothing in tree; made changes to shorten string to better fit in the status window.

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