source: trunk/dll/treecnr.c@ 1858

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

Rework FlestWaitForWorkListEmpty to support wait for parents of path
Clean up some obsolete code

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