source: trunk/dll/treecnr.c@ 1444

Last change on this file since 1444 was 1444, checked in by Gregg Young, 16 years ago

Rework of drivebar to rescan all drives and refresh media buttons and menu items grey out inappropriate menu items. Streamline Tree scan code and use semaphores to serialize access. Add NOEASUPPORT and LOCALHD driveflag; .LONGNAME usage fixes; (Tickets 377-386)

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