source: trunk/dll/treecnr.c@ 1857

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

Must test last change before committing. My bad.

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