source: trunk/dll/treecnr.c@ 1455

Last change on this file since 1455 was 1455, checked in by Steven Levine, 16 years ago

Blink thread LEDs while worker threads are working
Drop expermental code

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