source: trunk/dll/treecnr.c@ 1868

Last change on this file since 1868 was 1868, checked in by Gregg Young, 10 years ago

Remove obsolete code fDontAsk?zip and fDummy

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