source: trunk/dll/treecnr.c@ 1856

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

Rework Flesh/Stubby etc. to avoid running on thread 1
Should be ready for release after spurious traps resolved
DbgMsg calls retained - delete/disable before release

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