source: trunk/dll/treecnr.c@ 1551

Last change on this file since 1551 was 1551, checked in by Gregg Young, 15 years ago

This code adds the semaphores to prevent a rescan from starting before the current one is finished; it fixes the double directory listing in the tree container and streamlines scanning. It update mapsym.pl to the latest version. Some code cleanup is included

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