source: trunk/dll/treecnr.c@ 1572

Last change on this file since 1572 was 1572, checked in by Steven Levine, 14 years ago

Minor cleanup

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