source: trunk/dll/treecnr.c@ 1439

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

Changes to allow high mem loading of dll; Refactor .LONGNAME and .SUBJECT EA fetch to FetchCommonEAs. Add szFSType to FillInRecordFromFSA use to bypass EA scan and size formatting for tree container; Fix labels/FS type to work on scan on NOPRESCAN Drives; Fixed dbl directory names on restore of dir cnrs; (Tickets 47, 339, 363, 368, 369, 370)

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