source: trunk/dll/treecnr.c@ 1865

Last change on this file since 1865 was 1865, checked in by Steven Levine, 10 years ago

Correct WaitFleshWorkListEmpty typo that could corrupt heap
Protect some read-only strings from overwriting

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