source: trunk/dll/treecnr.c@ 1674

Last change on this file since 1674 was 1674, checked in by Gregg Young, 13 years ago

Changed refresh removable media to query LVM directly to call Rediscover_PRMs (Ticket 472); Also added a tree rescan following volume detach.

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