source: trunk/dll/treecnr.c@ 1796

Last change on this file since 1796 was 1796, checked in by Gregg Young, 11 years ago

Fix tree container mis-draws (stacked icons with RWS) The problem was magnified by RWS but I think the occasional extra blank directory or duplicating directories is related. Ticket 545

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