source: trunk/dll/treecnr.c@ 1860

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

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