source: trunk/dll/treecnr.c@ 1570

Last change on this file since 1570 was 1570, checked in by Gregg Young, 14 years ago

Added IdleIfNeeded to place load and free loops to idle priority when dealing with large numbers of items. Used SleepIfNeeded more places for a similar purpose.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 90.1 KB
Line 
1
2/***********************************************************************
3
4 $Id: treecnr.c 1570 2011-06-12 22:09:19Z gyoung $
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 //DosEnterCritSec(); // GKY 11-30-08 moved to SetMask
2332 SetMask((CHAR *)mp1, &dcd->mask);
2333 //DosExitCritSec();
2334 }
2335 dcd->suspendview = TRUE;
2336 dcd->mask.attrFile |= FILE_DIRECTORY;
2337 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2338 dcd->suspendview = (USHORT) tempsusp;
2339 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2340 //DbgMsg(pszSrcFile, __LINE__, "UM_RESCAN %p pci %s", hwnd, (CHAR *) mp1);
2341 }
2342 return 0;
2343
2344 case UM_DRIVECMD:
2345 if (mp1) {
2346 ShowTreeRec(hwnd, (CHAR *)mp1, FALSE, TRUE);
2347 PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
2348 }
2349 return 0;
2350
2351 case WM_APPTERMINATENOTIFY:
2352 {
2353 APPNOTIFY *info;
2354 PCNRITEM pci;
2355 CHAR s[] = " :\\";
2356
2357 if (!mp2) {
2358 if (hwndMain)
2359 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
2360 }
2361 info = apphead;
2362 while (info) {
2363 if (info->happ == (HAPP) mp1) {
2364 *s = info->device;
2365 pci = FindCnrRecord(hwnd, s, NULL, FALSE, FALSE, TRUE);
2366 if (pci && (INT) pci != -1) {
2367 INT x = info->device - 'A';
2368 CHAR FileSystem[CCHMAXPATH];
2369
2370 driveserial[x] = -1;
2371 DriveFlagsOne(x, FileSystem, NULL);
2372 if (driveflags[x] &
2373 (DRIVE_INVALID | DRIVE_IGNORE))
2374 RemoveCnrItems(hwnd, pci, 1, CMA_FREE);
2375 else
2376 Flesh(hwnd, pci);
2377 }
2378 if (info->prev)
2379 info->prev->next = info->next;
2380 if (info->next)
2381 info->next->prev = info->prev;
2382 if (apphead == info)
2383 apphead = info->next;
2384 if (apptail == info)
2385 apptail = info->prev;
2386 free(info);
2387 break;
2388 }
2389 info = info->next;
2390 }
2391 }
2392 break;
2393
2394 case WM_COMMAND:
2395 DosError(FERR_DISABLEHARDERR);
2396 if (dcd) {
2397 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2398 return 0;
2399 switch (SHORT1FROMMP(mp1)) {
2400 case IDM_SETTARGET:
2401 SetTargetDir(hwnd, FALSE);
2402 break;
2403
2404 case IDM_DETACH:
2405 {
2406 CHAR d[3] = " :";
2407 PCNRITEM pci;
2408 PROGDETAILS pgd;
2409 CHAR params[368], *p;
2410 HAPP happ;
2411
2412 pci = (PCNRITEM) CurrentRecord(hwnd);
2413 if (pci && (INT) pci != -1 && isalpha(*pci->pszFileName)) {
2414 *d = toupper(*pci->pszFileName);
2415 p = GetCmdSpec(FALSE);
2416 memset(&pgd, 0, sizeof(pgd));
2417 pgd.Length = sizeof(pgd);
2418 pgd.progt.progc = PROG_WINDOWABLEVIO;
2419 pgd.progt.fbVisible = SHE_VISIBLE;
2420 pgd.pszTitle = (PSZ)GetPString(IDS_DETACHREQUESTTEXT);
2421 pgd.pszExecutable = p;
2422 pgd.pszParameters = params;
2423 pgd.pszStartupDir = NULL;
2424 pgd.pszIcon = NULL;
2425 pgd.pszEnvironment = NULL;
2426 pgd.swpInitial.hwndInsertBehind = HWND_TOP;
2427 pgd.swpInitial.hwnd = hwnd;
2428 pgd.swpInitial.fl = SWP_SHOW | SWP_ACTIVATE;
2429 sprintf(params, "/C NET USE %s /D", d);
2430 happ = WinStartApp(hwnd, &pgd, pgd.pszParameters,
2431 NULL, SAF_MAXIMIZED);
2432 if (!happ) {
2433 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, hwnd,
2434 GetPString(IDS_ERRORTEXT),
2435 GetPString(IDS_CANTSTARTTEXT), p, params);
2436 }
2437 else {
2438 APPNOTIFY *info;
2439
2440 info = xmallocz(sizeof(APPNOTIFY), pszSrcFile, __LINE__);
2441 if (info) {
2442 info->happ = happ;
2443 info->device = *d;
2444 if (!apphead)
2445 apphead = info;
2446 else {
2447 apptail->next = info;
2448 info->prev = apptail;
2449 }
2450 apptail = info;
2451 }
2452 }
2453 }
2454 }
2455 break;
2456
2457 case IDM_REMAP:
2458 WinDlgBox(HWND_DESKTOP, hwnd, RemapDlgProc,
2459 FM3ModHandle, MAP_FRAME, NULL);
2460 break;
2461
2462 case IDM_CONTEXTMENU:
2463 {
2464 PCNRITEM pci;
2465
2466 pci = (PCNRITEM) CurrentRecord(hwnd);
2467 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
2468 MPFROMP(pci));
2469 }
2470 break;
2471
2472 case IDM_FINDINTREE:
2473 {
2474 PSZ pszTempDir;
2475 PCNRITEM pci;
2476
2477 pci = (PCNRITEM) CurrentRecord(hwnd);
2478 if (pci && (INT) pci != -1) {
2479 pszTempDir = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
2480 if (pszTempDir)
2481 MakeValidDir(pszTempDir);
2482 }
2483 else
2484 pszTempDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
2485 if (pszTempDir) {
2486 if (WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2487 WalkAllDlgProc,
2488 FM3ModHandle, WALK_FRAME, MPFROMP(pszTempDir))) {
2489 if (!WinSendMsg(hwnd, UM_SHOWME, MPFROMP(pszTempDir), MPFROMLONG(1)))
2490 free(pszTempDir);
2491 }
2492 else
2493 free(pszTempDir);
2494 }
2495 }
2496 break;
2497
2498 case IDM_BEGINEDIT:
2499 OpenEdit(hwnd);
2500 break;
2501
2502 case IDM_ENDEDIT:
2503 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
2504 break;
2505
2506 case IDM_FILTER:
2507 {
2508 BOOL empty = FALSE;
2509 PCNRITEM pci;
2510
2511 pci = (PCNRITEM) CurrentRecord(hwnd);
2512 if (!*dcd->mask.szMask)
2513 empty = TRUE;
2514 dcd->mask.fIsTree = TRUE;
2515 *dcd->mask.prompt = 0;
2516 if (pci && (INT) pci != -1)
2517 dcd->mask.fFilesIncluded =
2518 ((driveflags[toupper(*pci->pszFileName) - 'A'] &
2519 DRIVE_INCLUDEFILES) != 0);
2520 else
2521 dcd->mask.fFilesIncluded = FALSE;
2522 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2523 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2524 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2525 else if (empty)
2526 *dcd->mask.szMask = 0;
2527 PrfWriteProfileData(fmprof, appname, "TreeFilter", &dcd->mask,
2528 sizeof(MASK));
2529 }
2530 break;
2531
2532 case IDM_SHOWSORT:
2533 QuickPopup(hwnd, dcd, CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP),
2534 IDM_SORTSUBMENU);
2535 break;
2536
2537 case IDM_SHOWSELECT:
2538 QuickPopup(hwnd, dcd, CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP),
2539 IDM_SELECTSUBMENU);
2540 break;
2541
2542 case IDM_TREECNRVIEWSETTINGS:
2543 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
2544 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_TREECNRVIEWSETTINGS), mp2);
2545 else {
2546 WinDlgBox(HWND_DESKTOP,
2547 hwnd,
2548 CfgDlgProc,
2549 FM3ModHandle,
2550 CFG_FRAME,
2551 MPFROMLONG(IDM_TREECNRVIEWSETTINGS));
2552 }
2553 break;
2554
2555 case IDM_WALKDIR:
2556 case IDM_OPENWALK:
2557 {
2558 CHAR newpath[CCHMAXPATH];
2559 PCNRITEM pci;
2560
2561 pci = (PCNRITEM) CurrentRecord(hwnd);
2562 if (pci && (INT) pci != -1) {
2563 strcpy(newpath, pci->pszFileName);
2564 MakeValidDir(newpath);
2565 }
2566 else
2567 strcpy(newpath, pFM2SaveDirectory);
2568 if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkAllDlgProc,
2569 FM3ModHandle, WALK_FRAME,
2570 MPFROMP(newpath)) || !*newpath)
2571 break;
2572 WinSendMsg(hwnd, UM_OPENWINDOWFORME, MPFROMP(newpath), MPVOID);
2573 }
2574 break;
2575
2576 case IDM_HELP:
2577 if (hwndHelp) {
2578 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
2579 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
2580 else
2581 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
2582 }
2583 break;
2584
2585 case IDM_PARTITION:
2586 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2587 NULL, NULL,
2588 "%s", PCSZ_MINILVMEXE);
2589 break;
2590
2591 case IDM_PARTITIONDF:
2592 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2593 NULL, NULL,
2594 "%s", PCSZ_DFSOS2EXE);
2595 break;
2596
2597 case IDM_PARTITIONLVMG:
2598 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2599 NULL, NULL,
2600 "%s", PCSZ_LVMGUICMD);
2601 break;
2602
2603 case IDM_PARTITIONLVM:
2604 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2605 NULL, NULL,
2606 "%s", PCSZ_LVMEXE);
2607 break;
2608
2609 case IDM_PARTITIONFD:
2610 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2611 NULL, NULL,
2612 "%s", PCSZ_FDISKPMEXE);
2613 break;
2614
2615 case IDM_REFRESHREMOVABLES:
2616 runemf2(SEPARATE | WINDOWED | BACKGROUND | MINIMIZED | WAIT,
2617 HWND_DESKTOP, pszSrcFile, __LINE__, NULL, NULL,
2618 "%s %s", PCSZ_LVMEXE, "/RediscoverPRM");
2619 PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
2620 break;
2621
2622 case IDM_SORTNAME:
2623 case IDM_SORTFILENAME:
2624 case IDM_SORTSIZE:
2625 case IDM_SORTEASIZE:
2626 case IDM_SORTFIRST:
2627 case IDM_SORTLAST:
2628 case IDM_SORTLWDATE:
2629 case IDM_SORTLADATE:
2630 case IDM_SORTCRDATE:
2631 TreesortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
2632 case IDM_SORTDIRSFIRST:
2633 case IDM_SORTDIRSLAST:
2634 case IDM_SORTREVERSE:
2635 switch (SHORT1FROMMP(mp1)) {
2636 case IDM_SORTFILENAME:
2637 TreesortFlags |= SORT_FILENAME;
2638 break;
2639 case IDM_SORTSIZE:
2640 TreesortFlags |= SORT_SIZE;
2641 break;
2642 case IDM_SORTEASIZE:
2643 TreesortFlags |= SORT_EASIZE;
2644 break;
2645 case IDM_SORTFIRST:
2646 TreesortFlags |= SORT_FIRSTEXTENSION;
2647 break;
2648 case IDM_SORTLAST:
2649 TreesortFlags |= SORT_LASTEXTENSION;
2650 break;
2651 case IDM_SORTLWDATE:
2652 TreesortFlags |= SORT_LWDATE;
2653 break;
2654 case IDM_SORTLADATE:
2655 TreesortFlags |= SORT_LADATE;
2656 break;
2657 case IDM_SORTCRDATE:
2658 TreesortFlags |= SORT_CRDATE;
2659 break;
2660 case IDM_SORTDIRSFIRST:
2661 if (TreesortFlags & SORT_DIRSFIRST)
2662 TreesortFlags &= (~SORT_DIRSFIRST);
2663 else {
2664 TreesortFlags |= SORT_DIRSFIRST;
2665 TreesortFlags &= (~SORT_DIRSLAST);
2666 }
2667 break;
2668 case IDM_SORTDIRSLAST:
2669 if (TreesortFlags & SORT_DIRSLAST)
2670 TreesortFlags &= (~SORT_DIRSLAST);
2671 else {
2672 TreesortFlags |= SORT_DIRSLAST;
2673 TreesortFlags &= (~SORT_DIRSFIRST);
2674 }
2675 break;
2676 case IDM_SORTREVERSE:
2677 if (TreesortFlags & SORT_REVERSE)
2678 TreesortFlags &= (~SORT_REVERSE);
2679 else
2680 TreesortFlags |= SORT_REVERSE;
2681 break;
2682 }
2683 PrfWriteProfileData(fmprof, appname, "TreeSort", &TreesortFlags,
2684 sizeof(INT));
2685 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
2686 break;
2687
2688 case IDM_COLLECT:
2689 case IDM_GREP:
2690 if (!Collector) {
2691
2692 HWND hwndC;
2693 SWP swp;
2694
2695 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2696 !fAutoTile &&
2697 (!fExternalCollector && *(ULONG *) realappname == FM3UL))
2698 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2699 hwndC = StartCollector((fExternalCollector ||
2700 *(ULONG *) realappname != FM3UL) ?
2701 HWND_DESKTOP : dcd->hwndParent, 4);
2702 if (hwndC) {
2703 if (!ParentIsDesktop(hwnd,
2704 dcd->hwndParent) &&
2705 !fAutoTile &&
2706 (!fExternalCollector && *(ULONG *) realappname == FM3UL))
2707 WinSetWindowPos(hwndC,
2708 HWND_TOP,
2709 swp.x,
2710 swp.y,
2711 swp.cx,
2712 swp.cy,
2713 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
2714 else if (!ParentIsDesktop(hwnd,
2715 dcd->hwndParent) &&
2716 fAutoTile && *(ULONG *) realappname == FM3UL)
2717 TileChildren(dcd->hwndParent, TRUE);
2718 }
2719 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
2720 DosSleep(100);//05 Aug 07 GKY 250
2721 }
2722 else
2723 StartCollector(dcd->hwndParent, 4);
2724 if (SHORT1FROMMP(mp1) == IDM_GREP) {
2725 PCNRITEM pci = NULL;
2726
2727 pci = WinSendMsg(hwnd,
2728 CM_QUERYRECORDEMPHASIS,
2729 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
2730 if (pci && (INT) pci != -1)
2731 PostMsg(Collector, WM_COMMAND,
2732 MPFROM2SHORT(UM_GREP, 0), MPFROMP(pci->pszFileName));
2733 else
2734 PostMsg(Collector, WM_COMMAND,
2735 MPFROM2SHORT(IDM_GREP, 0), MPVOID);
2736 }
2737 else
2738 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2739 break;
2740
2741 case IDM_COLLECTOR:
2742 DosSleep(32);//05 Aug 07 GKY 64
2743 {
2744 CHAR **list;
2745
2746 list = BuildList(hwnd);
2747 if (list) {
2748 if (Collector) {
2749 if (!PostMsg(Collector, WM_COMMAND,
2750 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2751 FreeList(list);
2752 }
2753 else
2754 FreeList(list);
2755 }
2756 }
2757 break;
2758
2759 case IDM_COLLAPSEALL:
2760 WinSendMsg(hwnd, CM_COLLAPSETREE, MPVOID, MPVOID);
2761 break;
2762
2763 case IDM_COLLAPSE:
2764 case IDM_EXPAND:
2765 {
2766 PCNRITEM pci = NULL;
2767
2768 pci = (PCNRITEM) CurrentRecord(hwnd);
2769 if (pci && (INT) pci != -1) {
2770 if (pci->flags & RECFLAGS_UNDERENV)
2771 break;
2772 PostMsg(dcd->hwndObject, UM_EXPAND, mp1, MPFROMP(pci));
2773 }
2774 }
2775 break;
2776
2777 case IDM_UPDATE:
2778 {
2779 PCNRITEM pci = (PCNRITEM)CurrentRecord(hwnd);
2780 if (pci && (INT)pci != -1) {
2781 struct
2782 {
2783 ULONG serial;
2784 CHAR volumelength;
2785 CHAR volumelabel[CCHMAXPATH];
2786 }
2787 volser;
2788 INT x = toupper(*pci->pszFileName) - 'A';
2789 CHAR FileSystem[CCHMAXPATH], szBuf[CCHMAXPATH];
2790
2791 UINT driveflag = driveflags[x];
2792 if (pci->attrFile & FILE_DIRECTORY) {
2793 if (pci->flags & RECFLAGS_UNDERENV)
2794 break;
2795 DosRequestMutexSem(hmtxScanning, SEM_INDEFINITE_WAIT);
2796 DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
2797 UnFlesh(hwnd, pci);
2798 // Check if drive type might need update
2799 if ((driveflag & (DRIVE_INVALID | DRIVE_NOPRESCAN)) ||
2800 (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno)) {
2801 DriveFlagsOne(x, FileSystem, &volser);
2802 driveflag = driveflags[x];
2803 if (driveflag & DRIVE_INVALID)
2804 pci->rc.hptrIcon = hptrDunno;
2805 else if (strlen(pci->pszFileName) < 4) {
2806 SelectDriveIcon(pci);
2807 if (fShowFSTypeInTree || fShowDriveLabelInTree) {
2808 strcpy(szBuf, pci->pszFileName);
2809 strcat(szBuf, " [");
2810 strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
2811 strcat(szBuf, "]");
2812 pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
2813 pci->rc.pszIcon = pci->pszDisplayName;
2814 }
2815 }
2816 WinSendMsg(hwnd,
2817 CM_INVALIDATERECORD,
2818 MPFROMP(&pci),
2819 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2820 if (hwndMain)
2821 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
2822 }
2823 if (~driveflag & DRIVE_INVALID)
2824 Flesh(hwnd, pci);
2825 DosPostEventSem(hevTreeCnrScanComplete);
2826 }
2827 }
2828 }
2829 break;
2830
2831 case IDM_RESCAN:
2832 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
2833 break;
2834
2835 case IDM_RESORT:
2836 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
2837 break;
2838
2839 case IDM_TEXT:
2840 case IDM_MINIICONS:
2841 {
2842 CNRINFO cnri;
2843
2844 memset(&cnri, 0, sizeof(CNRINFO));
2845 cnri.cb = sizeof(CNRINFO);
2846 WinSendMsg(hwnd,
2847 CM_QUERYCNRINFO,
2848 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
2849 if (SHORT1FROMMP(mp1) == IDM_MINIICONS) {
2850 if (cnri.flWindowAttr & CV_MINI)
2851 cnri.flWindowAttr &= (~CV_MINI);
2852 else
2853 cnri.flWindowAttr |= CV_MINI;
2854 }
2855 else {
2856 if (cnri.flWindowAttr & CV_TEXT) {
2857 cnri.flWindowAttr &= (~CV_TEXT);
2858 cnri.flWindowAttr |= CV_ICON;
2859 }
2860 else {
2861 cnri.flWindowAttr &= (~CV_ICON);
2862 cnri.flWindowAttr |= CV_TEXT;
2863 }
2864 }
2865 dcd->flWindowAttr = cnri.flWindowAttr;
2866 PrfWriteProfileData(fmprof,
2867 appname,
2868 "TreeflWindowAttr",
2869 &cnri.flWindowAttr, sizeof(ULONG));
2870 WinSendMsg(hwnd,
2871 CM_SETCNRINFO,
2872 MPFROMP(&cnri),
2873 MPFROMLONG(CMA_FLWINDOWATTR | CMA_TREEICON |
2874 CMA_SLTREEBITMAPORICON));
2875 }
2876 break;
2877
2878 case IDM_SIZES:
2879 case IDM_DRVFLAGS:
2880 case IDM_SHOWALLFILES:
2881 case IDM_UNDELETE:
2882 case IDM_OPTIMIZE:
2883 case IDM_CHKDSK:
2884 case IDM_FORMAT:
2885 case IDM_MKDIR:
2886 case IDM_LOCK:
2887 case IDM_UNLOCK:
2888 case IDM_EJECT:
2889 case IDM_CLOSETRAY:
2890 {
2891 PCNRITEM pci;
2892
2893 pci = (PCNRITEM) CurrentRecord(hwnd);
2894 if (pci && (INT) pci != -1)
2895 CommonDriveCmd(hwnd, pci->pszFileName, SHORT1FROMMP(mp1));
2896 }
2897 break;
2898
2899 case IDM_SAVETOLIST:
2900 WinDlgBox(HWND_DESKTOP,
2901 hwnd,
2902 SaveListDlgProc, FM3ModHandle, SAV_FRAME, MPFROMP(&hwnd));
2903 break;
2904
2905 case IDM_DELETE:
2906 case IDM_PERMDELETE:
2907 case IDM_MOVE:
2908 case IDM_WPSMOVE:
2909 case IDM_WILDMOVE:
2910 case IDM_RENAME:
2911 {
2912 PCNRITEM pci;
2913
2914 pci = (PCNRITEM) CurrentRecord(hwnd);
2915 if (pci && (INT) pci != -1) {
2916 if (pci->flags & RECFLAGS_UNDERENV)
2917 break;
2918 }
2919 }
2920 /* else intentional fallthru */
2921 case IDM_ATTRS:
2922 case IDM_INFO:
2923 case IDM_COPY:
2924 case IDM_WPSCOPY:
2925 case IDM_WILDCOPY:
2926 case IDM_DOITYOURSELF:
2927 case IDM_OPENWINDOW:
2928 case IDM_OPENSETTINGS:
2929 case IDM_OPENDEFAULT:
2930 case IDM_OPENICON:
2931 case IDM_OPENDETAILS:
2932 case IDM_OPENTREE:
2933 case IDM_SHADOW:
2934 case IDM_SHADOW2:
2935 case IDM_COMPARE:
2936 case IDM_VIEW:
2937 case IDM_VIEWTEXT:
2938 case IDM_VIEWBINARY:
2939 case IDM_EDIT:
2940 case IDM_EDITTEXT:
2941 case IDM_EDITBINARY:
2942 case IDM_EAS:
2943 case IDM_SUBJECT:
2944 case IDM_APPENDTOCLIP:
2945 case IDM_SAVETOCLIP:
2946 case IDM_ARCHIVE:
2947 case IDM_MCIPLAY:
2948 case IDM_UUDECODE:
2949 {
2950 LISTINFO *li;
2951 ULONG action = UM_ACTION;
2952# ifdef FORTIFY
2953 Fortify_EnterScope();
2954# endif
2955 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2956 if (li) {
2957 li->type = SHORT1FROMMP(mp1);
2958 li->hwnd = hwnd;
2959 li->list = BuildList(hwnd);
2960 if (!li->list || !li->list[0]) {
2961 free(li);
2962 break;
2963 }
2964 if (IsRoot(li->list[0])) {
2965 switch (SHORT1FROMMP(mp1)) {
2966 case IDM_MOVE:
2967 case IDM_COPY:
2968 case IDM_WILDCOPY:
2969 case IDM_WILDMOVE:
2970 case IDM_WPSMOVE:
2971 case IDM_WPSCOPY:
2972 case IDM_RENAME:
2973 case IDM_DELETE:
2974 case IDM_PERMDELETE:
2975 mp1 = MPFROM2SHORT(IDM_INFO, SHORT2FROMMP(mp1));
2976 li->type = IDM_INFO;
2977 }
2978 }
2979 switch (SHORT1FROMMP(mp1)) {
2980 case IDM_APPENDTOCLIP:
2981 case IDM_SAVETOCLIP:
2982 case IDM_ARCHIVE:
2983 case IDM_DELETE:
2984 case IDM_PERMDELETE:
2985 case IDM_ATTRS:
2986 case IDM_SHADOW:
2987 case IDM_SHADOW2:
2988 case IDM_DOITYOURSELF:
2989 case IDM_EAS:
2990 case IDM_VIEW:
2991 case IDM_VIEWTEXT:
2992 case IDM_VIEWBINARY:
2993 case IDM_EDIT:
2994 case IDM_EDITTEXT:
2995 case IDM_EDITBINARY:
2996 case IDM_MCIPLAY:
2997 action = UM_MASSACTION;
2998 }
2999 if (SHORT1FROMMP(mp1) == IDM_SHADOW ||
3000 SHORT1FROMMP(mp1) == IDM_SHADOW2)
3001 *li->targetpath = 0;
3002 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
3003 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
3004 FreeListInfo(li);
3005 }
3006 }
3007# ifdef FORTIFY
3008 Fortify_LeaveScope();
3009# endif
3010 }
3011 break;
3012
3013 default:
3014 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
3015 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
3016
3017 INT x;
3018
3019 if (!cmdloaded)
3020 load_commands();
3021 x = SHORT1FROMMP(mp1);// - IDM_COMMANDSTART;
3022 if (x >= 0) {
3023 //x++;
3024 RunCommand(hwnd, x);
3025 if (fUnHilite)
3026 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
3027 }
3028 }
3029 break;
3030 }
3031 }
3032 return 0;
3033
3034 case WM_SAVEAPPLICATION:
3035 if (dcd && !ParentIsDesktop(hwnd, dcd->hwndParent)) {
3036
3037 SWP swp, swpP;
3038 INT ratio;
3039
3040 WinQueryWindowPos(dcd->hwndFrame, &swp);
3041 if (!(swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE | SWP_HIDE))) {
3042 WinQueryWindowPos(dcd->hwndParent, &swpP);
3043 if (swp.cx) {
3044 ratio = (swpP.cx * 100) / swp.cx;
3045 if (ratio > 0)
3046 PrfWriteProfileData(fmprof, appname, "TreeWindowRatio",
3047 &ratio, sizeof(INT));
3048 }
3049 }
3050 }
3051 else if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3052
3053 SWP swp;
3054
3055 WinQueryWindowPos(dcd->hwndFrame, &swp);
3056 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3057 WinStoreWindowPos((CHAR *) FM2Str, "VTreeWindowPos", dcd->hwndFrame);
3058 }
3059 break;
3060
3061 case UM_MINIMIZE:
3062 if (dcd && hwndMain) {
3063 fOkayMinimize = TRUE;
3064 if (dcd->hwndObject && !fDummy) {
3065 DosSleep(50);//05 Aug 07 GKY 100
3066 if (!fDummy) {
3067 fOkayMinimize = FALSE;
3068 WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
3069 dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0,
3070 SWP_MINIMIZE | SWP_DEACTIVATE);
3071 }
3072 }
3073 }
3074 return 0;
3075
3076 case UM_MAXIMIZE:
3077 if (dcd || hwndMain)
3078 WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
3079 dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0, SWP_MAXIMIZE |
3080 SWP_SHOW);
3081 return 0;
3082
3083 case UM_CLOSE:
3084 {
3085 HWND hwndParent = WinQueryWindow(WinQueryWindow(WinQueryWindow(hwnd,
3086 QW_PARENT),
3087 QW_PARENT), QW_PARENT);
3088
3089 if (!mp1) {
3090 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
3091 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3092 if (hwndParent && !ParentIsDesktop(hwnd, hwndParent))
3093 WinDestroyWindow(hwndParent);
3094 }
3095 else
3096 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3097 QW_PARENT));
3098 }
3099 return 0;
3100
3101 case WM_CLOSE:
3102 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3103 if (dcd)
3104 dcd->stopflag++;
3105 if (dcd && dcd->hwndObject) {
3106 /* kill object window */
3107 if (WinIsWindow((HAB) 0, dcd->hwndObject)) {
3108 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3109 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
3110 }
3111 }
3112 else
3113 WinSendMsg(hwnd, UM_CLOSE, MPFROMLONG(1), MPVOID);
3114 return 0;
3115
3116 case WM_DESTROY:
3117# ifdef FORTIFY
3118 DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
3119# endif
3120 if (TreeCnrMenu)
3121 WinDestroyWindow(TreeCnrMenu);
3122 if (DirMenu)
3123 WinDestroyWindow(DirMenu);
3124 if (FileMenu)
3125 WinDestroyWindow(FileMenu);
3126 TreeCnrMenu = FileMenu = DirMenu = (HWND) 0;
3127 EmptyCnr(hwnd);
3128 if (apphead) {
3129 APPNOTIFY *info, *next;
3130 info = apphead;
3131 while (info) {
3132 next = info->next;
3133 free(info);
3134 info = next;
3135 }
3136 apphead = apptail = NULL;
3137 }
3138# ifdef FORTIFY
3139 Fortify_LeaveScope();
3140# endif
3141 break; // WM_DESTROY
3142 } // switch
3143 if (dcd && dcd->oldproc){
3144 return dcd->oldproc(hwnd, msg, mp1, mp2);
3145 }
3146 else
3147 return PFNWPCnr(hwnd, msg, mp1, mp2);
3148}
3149
3150HWND StartTreeCnr(HWND hwndParent, ULONG flags)
3151{
3152 /* bitmapped flags:
3153 * 0x00000001 = don't close app when window closes
3154 * 0x00000002 = no frame controls
3155 * 0x00000004 = no close or move button
3156 */
3157
3158 HWND hwndFrame = NULLHANDLE;
3159 HWND hwndSysMenu = NULLHANDLE;
3160 HWND hwndClient;
3161 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3162 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3163 DIRCNRDATA *dcd;
3164
3165 if (!hwndParent)
3166 hwndParent = HWND_DESKTOP;
3167 if (ParentIsDesktop(hwndParent, hwndParent))
3168 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3169 if (flags & 2)
3170 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3171 FCF_MINMAX | FCF_ICON));
3172 hwndFrame = WinCreateStdWindow(hwndParent,
3173 WS_VISIBLE,
3174 &FrameFlags,
3175 (CHAR *) WC_TREECONTAINER,
3176 NULL,
3177 WS_VISIBLE | fwsAnimate,
3178 FM3ModHandle, TREE_FRAME, &hwndClient);
3179 if (hwndParent != HWND_DESKTOP) {
3180 hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
3181 if (hwndSysMenu != NULLHANDLE)
3182 WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
3183 MPFROM2SHORT(SC_CLOSE, TRUE),
3184 MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
3185 if (!fFreeTree)
3186 WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
3187 MPFROM2SHORT(SC_MOVE, TRUE),
3188 MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
3189 }
3190 if (hwndFrame && hwndClient) {
3191# ifdef FORTIFY
3192 Fortify_EnterScope();
3193# endif
3194 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3195 if (!dcd) {
3196 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_OUTOFMEMORY));
3197 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3198 hwndFrame = (HWND) 0;
3199 }
3200 else {
3201 SWP swp;
3202 WinQueryWindowPos(hwndFrame, &swp);
3203 if (*(ULONG *) realappname == FM3UL) {
3204 if (!WinCreateWindow(hwndFrame,
3205 (CHAR *) WC_TREEOPENBUTTON,
3206 "#303",
3207 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | BS_BITMAP,
3208 ((swp.cx -
3209 WinQuerySysValue(HWND_DESKTOP,
3210 SV_CXMINMAXBUTTON)) -
3211 WinQuerySysValue(HWND_DESKTOP,
3212 SV_CXMINMAXBUTTON) / 2) -
3213 WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER),
3214 (swp.cy -
3215 WinQuerySysValue(HWND_DESKTOP,
3216 SV_CYMINMAXBUTTON)) -
3217 WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER),
3218 WinQuerySysValue(HWND_DESKTOP,
3219 SV_CXMINMAXBUTTON) / 2,
3220 WinQuerySysValue(HWND_DESKTOP,
3221 SV_CYMINMAXBUTTON), hwndFrame,
3222 HWND_TOP, IDM_OPENWINDOW, NULL, NULL)) {
3223 Win_Error(hwndFrame, hwndParent, pszSrcFile, __LINE__,
3224 PCSZ_WINCREATEWINDOW);
3225 }
3226 }
3227 else {
3228 if (!WinCreateWindow(hwndFrame,
3229 (CHAR *) WC_TREESTATUS,
3230 (CHAR *) GetPString(IDS_YOUAREHERETEXT),
3231 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER,
3232 swp.x + 4 + WinQuerySysValue(HWND_DESKTOP,
3233 SV_CXSIZEBORDER),
3234 swp.cy - (22 + WinQuerySysValue(HWND_DESKTOP,
3235 SV_CYSIZEBORDER)),
3236 (swp.cx - 8) - (WinQuerySysValue(HWND_DESKTOP,
3237 SV_CXSIZEBORDER)
3238 * 2), 22, hwndFrame, HWND_TOP,
3239 MAIN_STATUS, NULL, NULL)) {
3240 Win_Error(hwndFrame, hwndParent, pszSrcFile, __LINE__,
3241 PCSZ_WINCREATEWINDOW);
3242 }
3243 }
3244 memset(dcd, 0, sizeof(DIRCNRDATA));
3245 dcd->size = sizeof(DIRCNRDATA);
3246 dcd->type = TREE_FRAME;
3247 dcd->dontclose = ((flags & 1) != 0);
3248 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3249 dcd->hwndClient = hwndClient;
3250 dcd->hwndFrame = hwndFrame;
3251 {
3252 PFNWP oldproc;
3253
3254 oldproc = WinSubclassWindow(hwndFrame, TreeFrameWndProc);
3255 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3256 oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3257 (PFNWP) TreeTitleWndProc);
3258 WinSetWindowPtr(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3259 QWL_USER, (PVOID) oldproc);
3260 }
3261 dcd->hwndCnr = WinCreateWindow(hwndClient,
3262 WC_CONTAINER,
3263 NULL,
3264 CCS_AUTOPOSITION | CCS_MINIICONS |
3265 CCS_MINIRECORDCORE,
3266 0,
3267 0,
3268 0,
3269 0,
3270 hwndClient,
3271 HWND_TOP, (ULONG) TREE_CNR, NULL, NULL);
3272 if (!dcd->hwndCnr) {
3273 Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
3274 PCSZ_WINCREATEWINDOW);
3275 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3276 free(dcd);
3277 dcd = 0;
3278 hwndFrame = (HWND) 0;
3279 }
3280 else {
3281 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3282 if (ParentIsDesktop(hwndFrame, hwndParent)) {
3283 WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "VTree");
3284 FixSwitchList(hwndFrame, "VTree");
3285 }
3286 else {
3287 WinSetWindowText(hwndFrame, (CHAR *) GetPString(IDS_TREETEXT));
3288 WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3289 (CHAR *) GetPString(IDS_TREETEXT));
3290 }
3291 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr, TreeCnrWndProc);
3292 // fixme to document 01 test?
3293 if (dcd->oldproc == 0)
3294 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
3295 "WinSubclassWindow");
3296 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3297 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3298 }
3299 }
3300# ifdef FORTIFY
3301 if (dcd)
3302 Fortify_ChangeScope(dcd, -1);
3303 Fortify_LeaveScope();
3304 if (dcd)
3305 Fortify_ChangeScope(dcd, +1);
3306# endif
3307 }
3308 return hwndFrame;
3309}
3310
3311#pragma alloc_text(TREECNR,TreeCnrWndProc,TreeObjWndProc,TreeClientWndProc)
3312#pragma alloc_text(TREECNR,TreeFrameWndProc,TreeTitleWndProc,ShowTreeRec)
3313#pragma alloc_text(TREECNR,TreeStatProc,OpenButtonProc)
3314#pragma alloc_text(STARTUP,StartTreeCnr)
Note: See TracBrowser for help on using the repository browser.