source: trunk/dll/treecnr.c@ 1360

Last change on this file since 1360 was 1360, checked in by Gregg Young, 17 years ago

Conditionally enable Refresh removable media and individual partition menu items based on availability of required tool in PATH. (Tickets 36 & 54)

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