source: trunk/dll/treecnr.c@ 1431

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

Changed 3 way button to radio buttons and added rescan on change to add systype/label to tree enhancement.

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