source: trunk/dll/treecnr.c@ 1434

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

Update show label or FS in tree to initialize as driveonly and fixed typo which caused rescan to fail after the value was changed. Renamed some variables.

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