source: trunk/dll/treecnr.c@ 1427

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

Fix issue with name duplication in tree container when drive tree is accessed before a recursive scan is performed (Ticket 362)

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