source: trunk/dll/treecnr.c@ 1673

Last change on this file since 1673 was 1673, checked in by Gregg Young, 13 years ago

Update to Doxygen comment style Ticket 55. Also some minor code cleanup.

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