source: trunk/dll/treecnr.c@ 1428

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

Improvement to status line 1 for selected drives (number of drives is shown at the beginning of the line if split status line is not selected); Comments for recent changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 87.8 KB
Line 
1
2/***********************************************************************
3
4 $Id: treecnr.c 1428 2009-06-07 23:09:55Z 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 || fShowSysType)
788 strcpy(FileSystem, "");
789 if (fShowLabel)
790 strcpy(szTmpLabel, "");
791 else
792 strcpy(szTmpLabel, volser.volumelabel);
793 if (fSplitStatus)
794 sprintf(s,
795 GetPString(fShowSysType ? IDS_TREESTATUSSTART1TEXT : fShowLabel
796 ? IDS_TREESTATUSSTART2TEXT : IDS_TREESTATUSSTARTTEXT),
797 toupper(*pci->pszFileName), FileSystem,
798 szTmpLabel, volser.serial, szFree);
799 else {
800 strcat(s, " [");
801 sprintf(&s[strlen(s)],
802 GetPString(fShowSysType ? IDS_TREESTATUSSTART1TEXT : fShowLabel
803 ? IDS_TREESTATUSSTART2TEXT : IDS_TREESTATUSSTARTTEXT),
804 toupper(*pci->pszFileName), FileSystem,
805 szTmpLabel, volser.serial, szFree);
806 strcat(s, "]");
807 }
808 if (!fMoreButtons) {
809 if (*dcd->mask.szMask ||
810 (dcd->mask.attrFile != ALLATTRS ||
811 ((fFilesInTree ||
812 (driveflags[toupper(*pci->pszFileName)] &
813 DRIVE_INCLUDEFILES)) ?
814 dcd->mask.antiattr :
815 (dcd->mask.antiattr &&
816 dcd->mask.antiattr != FILE_DIRECTORY)))) {
817 sprintf(&s[strlen(s)],
818 " (%s)",
819 (*dcd->mask.szMask) ?
820 dcd->mask.szMask : GetPString(IDS_ATTRTEXT));
821 }
822 }
823 }
824 }
825 else {
826 /* find root record and strip it */
827 pci = FindParentRecord(dcd->hwndCnr, pci);
828 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
829 UnFlesh(dcd->hwndCnr, pci);
830 }
831 }
832 }
833 if (dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
834 WinSetWindowText(hwndStatus, s);
835 }
836 return 0;
837
838 case UM_RESCAN:
839 /*
840 * populate container
841 */
842 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
843 if (!dcd)
844 Runtime_Error(pszSrcFile, __LINE__, NULL);
845 else {
846 while (StubbyScanCount != 0)
847 DosSleep(50);
848 RemoveCnrItems(dcd->hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
849 WinSendMsg(dcd->hwndCnr,
850 CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-1));
851 WinSendMsg(dcd->hwndCnr,
852 CM_SCROLLWINDOW,
853 MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(-1));
854 FillTreeCnr(dcd->hwndCnr, dcd->hwndParent);
855 if (fOkayMinimize) {
856 PostMsg(dcd->hwndCnr, UM_MINIMIZE, MPVOID, MPVOID);
857 fOkayMinimize = FALSE;
858 }
859 WinSendMsg(dcd->hwndCnr,
860 CM_INVALIDATERECORD,
861 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
862 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
863 }
864 return 0;
865
866 case UM_COMMAND:
867 if (mp1) {
868
869 LISTINFO *li = (LISTINFO *) mp1;
870
871 switch (li->type) {
872 case IDM_DOITYOURSELF:
873 case IDM_APPENDTOCLIP:
874 case IDM_SAVETOCLIP:
875 case IDM_ARCHIVE:
876 case IDM_VIEW:
877 case IDM_EDIT:
878 case IDM_OBJECT:
879 case IDM_SHADOW:
880 case IDM_SHADOW2:
881 case IDM_PRINT:
882 case IDM_ATTRS:
883 case IDM_DELETE:
884 case IDM_PERMDELETE:
885 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
886 return (MRESULT) TRUE;
887 default:
888 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
889 return (MRESULT) TRUE;
890 }
891 }
892 return 0;
893
894 case UM_MASSACTION:
895 if (mp1) {
896
897 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
898 if (!dcd)
899 Runtime_Error(pszSrcFile, __LINE__, NULL);
900 else {
901 WORKER *wk;
902# ifdef FORTIFY
903 Fortify_EnterScope();
904# endif
905 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
906 if (!wk)
907 FreeListInfo((LISTINFO *) mp1);
908 else {
909 wk->size = sizeof(WORKER);
910 wk->hwndCnr = dcd->hwndCnr;
911 wk->hwndParent = dcd->hwndParent;
912 wk->hwndFrame = dcd->hwndFrame;
913 wk->hwndClient = dcd->hwndClient;
914 wk->li = (LISTINFO *) mp1;
915 strcpy(wk->directory, dcd->directory);
916 if (xbeginthread(MassAction,
917 122880,
918 wk,
919 pszSrcFile,
920 __LINE__) == -1)
921 {
922 free(wk);
923 FreeListInfo((LISTINFO *) mp1);
924 }
925 }
926# ifdef FORTIFY
927 Fortify_LeaveScope();
928# endif
929 }
930 }
931 return 0;
932
933 case UM_ACTION:
934# ifdef FORTIFY
935 Fortify_EnterScope();
936# endif
937 if (mp1) {
938# ifdef FORTIFY
939 Fortify_BecomeOwner(mp1);
940# endif
941 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
942 if (!dcd)
943 Runtime_Error(pszSrcFile, __LINE__, NULL);
944 else {
945 WORKER *wk;
946 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
947 if (!wk)
948 FreeListInfo((LISTINFO *) mp1);
949 else {
950 wk->size = sizeof(WORKER);
951 wk->hwndCnr = dcd->hwndCnr;
952 wk->hwndParent = dcd->hwndParent;
953 wk->hwndFrame = dcd->hwndFrame;
954 wk->hwndClient = dcd->hwndClient;
955 wk->li = (LISTINFO *) mp1;
956 strcpy(wk->directory, dcd->directory);
957 if (xbeginthread(Action,
958 122880,
959 wk,
960 pszSrcFile,
961 __LINE__) == -1)
962 {
963 free(wk);
964 FreeListInfo((LISTINFO *) mp1);
965 }
966 }
967 }
968 }
969# ifdef FORTIFY
970 Fortify_LeaveScope();
971# endif
972 return 0;
973
974 case WM_CLOSE:
975 WinDestroyWindow(hwnd);
976 break;
977
978 case WM_DESTROY:
979 hwndTree = (HWND) 0;
980 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
981 if (dcd) {
982 WinSendMsg(dcd->hwndCnr,
983 UM_CLOSE, MPFROMLONG(dcd->dontclose != FALSE), MPVOID);
984 free(dcd);
985# ifdef FORTIFY
986 Fortify_LeaveScope();
987# endif
988 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
989 }
990 DosPostEventSem(CompactSem);
991 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
992 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
993 break;
994 }
995 return WinDefWindowProc(hwnd, msg, mp1, mp2);
996}
997
998MRESULT EXPENTRY TreeCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
999{
1000 static APPNOTIFY *apphead = NULL, *apptail = NULL;
1001 DIRCNRDATA *dcd = INSTDATA(hwnd);
1002 PCNRITEM pci;
1003
1004 switch (msg) {
1005 case DM_PRINTOBJECT:
1006 return MRFROMLONG(DRR_TARGET);
1007
1008 case DM_DISCARDOBJECT:
1009 if (dcd)
1010 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1011 else
1012 return MRFROMLONG(DRR_TARGET);
1013
1014 case WM_CHAR:
1015 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1016 if (SHORT1FROMMP(mp1) & KC_KEYUP)
1017 return (MRESULT) TRUE;
1018 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1019 switch (SHORT2FROMMP(mp2)) {
1020 case VK_INSERT:
1021 if ((shiftstate & KC_CTRL) == KC_CTRL)
1022 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
1023 break;
1024 case VK_DELETE:
1025 if ((shiftstate & KC_CTRL) == KC_CTRL)
1026 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
1027 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
1028 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
1029 else
1030 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
1031 break;
1032 } // switch
1033 }
1034
1035 if (SearchContainer(hwnd, msg, mp1, mp2))
1036 return (MRESULT)TRUE; // Avoid default handler
1037
1038 break; // Let default handler see key
1039
1040 case WM_MOUSEMOVE:
1041 case WM_BUTTON1UP:
1042 case WM_BUTTON2UP:
1043 case WM_BUTTON3UP:
1044 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1045 break;
1046
1047 case UM_TIMER:
1048 if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent) &&
1049 hwndStatus2) {
1050 FILEFINDBUF3L ffb;
1051 ULONG nm = 1;
1052 HDIR hdir = HDIR_CREATE;
1053
1054 if (*SwapperDat) {
1055 if (!xDosFindFirst(SwapperDat,
1056 &hdir,
1057 FILE_NORMAL | FILE_HIDDEN |
1058 FILE_SYSTEM | FILE_ARCHIVED | FILE_READONLY,
1059 &ffb, sizeof(ffb), &nm, FIL_STANDARDL)) {
1060 CHAR tb[39], tm[39], tpm[39], s[163];
1061 ULONG amem;
1062
1063 priority_bumped();
1064 DosFindClose(hdir);
1065 if (!DosQuerySysInfo(QSV_TOTAVAILMEM,
1066 QSV_TOTAVAILMEM,
1067 (PVOID) & amem, sizeof(amem))) {
1068 CommaFmtULL(tpm, sizeof(tpm), amem, 'M');
1069 }
1070 else
1071 *tpm = 0;
1072 if (!Dos16MemAvail(&amem))
1073 CommaFmtULL(tm, sizeof(tm), amem, 'M');
1074 else
1075 *tm = 0;
1076 CommaFmtULL(tb, sizeof(tb), ffb.cbFile, 'M');
1077 sprintf(s, " %s %s%s%s%s%s",
1078 GetPString(IDS_SWAPFILETEXT),
1079 tb,
1080 *tm ? GetPString(IDS_TREEMEMTEXT) : NullStr,
1081 tm, *tpm ? "/" : NullStr, tpm);
1082 WinSetWindowText(hwndStatus2, s);
1083 }
1084 else
1085 WinSetWindowText(hwndStatus2, NullStr);
1086 }
1087 else
1088 WinSetWindowText(hwndStatus2, NullStr);
1089 }
1090 if (msg == UM_TIMER)
1091 return 0;
1092 break;
1093
1094 case WM_PRESPARAMCHANGED:
1095 PresParamChanged(hwnd, PCSZ_TREECNR, mp1, mp2);
1096 break;
1097
1098 case UM_FILESMENU:
1099 {
1100 HWND menuHwnd = (HWND) 0;
1101 FSALLOCATE fsa;
1102
1103 pci = (PCNRITEM) CurrentRecord(hwnd);
1104 if (pci && (INT) pci != -1) {
1105 if (IsRoot(pci->pszFileName) || !DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
1106 FSIL_ALLOC, &fsa,
1107 sizeof(FSALLOCATE)))
1108 menuHwnd = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
1109 else {
1110 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
1111// WinEnableMenuItem(DirMenu,
1112// IDM_TREE,
1113// FALSE);
1114 }
1115 if (!(pci->attrFile & FILE_DIRECTORY))
1116 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
1117 }
1118 return MRFROMLONG(menuHwnd);
1119 }
1120
1121 case UM_COMPARE:
1122 if (dcd && mp1 && mp2) {
1123
1124 COMPARE *cmp;
1125 CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
1126
1127 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1128 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1129 if (cmp) {
1130 cmp->size = sizeof(COMPARE);
1131 strcpy(cmp->leftdir, leftdir);
1132 strcpy(cmp->rightdir, rightdir);
1133 cmp->hwndParent = dcd->hwndParent;
1134 cmp->dcd.hwndParent = dcd->hwndParent;
1135 WinDlgBox(HWND_DESKTOP,
1136 HWND_DESKTOP,
1137 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1138 }
1139 }
1140 }
1141 return 0;
1142
1143 case UM_UPDATERECORDLIST:
1144 if (dcd && mp1)
1145 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1146 return 0;
1147
1148 case UM_UPDATERECORD:
1149 if (dcd && mp1) {
1150 CHAR *filename;
1151 filename = mp1;
1152 if (filename) {
1153 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1154 }
1155 }
1156 return 0;
1157
1158 case WM_SETFOCUS:
1159 if (dcd && hwndStatus && mp2) {
1160 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1161 if (hwndMain)
1162 PostMsg(hwndMain, UM_ADVISEFOCUS, MPFROMLONG(dcd->hwndFrame), MPVOID);
1163 }
1164 break;
1165
1166 case UM_RESCAN:
1167 if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1168 /*
1169 * put name of our window on status line
1170 */
1171
1172 PCNRITEM pci = NULL;
1173 CHAR str[CCHMAXPATH + 6];
1174
1175 if (fAutoView && hwndMain) {
1176 pci = WinSendMsg(hwnd,
1177 CM_QUERYRECORDEMPHASIS,
1178 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1179 if (pci && (INT) pci != -1 && fComments &&
1180 !(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW))
1181 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1182 else
1183 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1184 }
1185 if (!fAutoView || !hwndMain)
1186 pci = (PCNRITEM) WinSendMsg(hwnd,
1187 CM_QUERYRECORDEMPHASIS,
1188 MPFROMLONG(CMA_FIRST),
1189 MPFROMSHORT(CRA_CURSORED));
1190 if ((INT) pci == -1)
1191 pci = NULL;
1192 if (pci) {
1193 if (*(ULONG *) realappname == FM3UL) {
1194 sprintf(str, "%s %s", GetPString(IDS_DTTEXT), pci->pszFileName);
1195 WinSetWindowText(dcd->hwndFrame, str);
1196 WinSetWindowText(WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR),
1197 str);
1198 }
1199 else
1200 WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
1201 MAIN_STATUS), pci->pszFileName);
1202 if (fMoreButtons && hwndName) {
1203 CHAR szDate[DATE_BUF_BYTES];
1204
1205 DateFormat(szDate, pci->date);
1206 WinSetWindowText(hwndName, pci->pszFileName);
1207 sprintf(str, "%s %02u%s%02u%s%02u", szDate,
1208 pci->time.hours, TimeSeparator,
1209 pci->time.minutes, TimeSeparator, pci->time.seconds);
1210 WinSetWindowText(hwndDate, str);
1211 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1212 }
1213 }
1214 PostMsg(dcd->hwndObject, UM_RESCAN2, MPFROMP(pci), MPVOID);
1215 if (hwndStatus2)
1216 PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID);
1217 }
1218 return 0;
1219
1220 case UM_SETUP2:
1221 {
1222 PCNRITEM pci = (PCNRITEM) mp1;
1223
1224 if (pci)
1225 NotifyError(pci->pszFileName, (ULONG) mp2);
1226 }
1227 return 0;
1228
1229 case UM_SETUP:
1230# ifdef FORTIFY
1231 // Balance WM_DESTROY
1232 Fortify_EnterScope();
1233# endif
1234
1235 if (!dcd) {
1236 Runtime_Error(pszSrcFile, __LINE__, NULL);
1237 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1238 return 0;
1239 }
1240 else {
1241 if (!dcd->hwndObject) {
1242 /*
1243 * first time through -- set things up
1244 */
1245 CNRINFO cnri;
1246
1247# ifdef FORTIFY
1248 Fortify_EnterScope();
1249# endif
1250
1251 RestorePresParams(hwnd, PCSZ_TREECNR);
1252 memset(&cnri, 0, sizeof(CNRINFO));
1253 cnri.cb = sizeof(CNRINFO);
1254 WinSendMsg(hwnd,
1255 CM_QUERYCNRINFO,
1256 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1257 cnri.cyLineSpacing = 0;
1258 cnri.cxTreeIndent = 12;
1259 cnri.pSortRecord = (PVOID) SortTreeCnr;
1260 cnri.flWindowAttr &= (~(CV_NAME | CV_DETAIL | CV_TEXT));
1261 cnri.flWindowAttr |= (CV_TREE | CA_TREELINE | CV_ICON | CV_MINI);
1262 {
1263 ULONG size = sizeof(ULONG);
1264
1265 PrfQueryProfileData(fmprof,
1266 appname,
1267 "TreeflWindowAttr",
1268 (PVOID) & cnri.flWindowAttr, &size);
1269 size = sizeof(MASK);
1270 *dcd->mask.prompt = 0;
1271 if (!*dcd->mask.szMask && !dcd->mask.attrFile) {
1272 if (PrfQueryProfileSize(fmprof,
1273 appname, "TreeFilter", &size) && size) {
1274 PrfQueryProfileData(fmprof,
1275 appname, "TreeFilter", &dcd->mask, &size);
1276 SetMask(NULL, &dcd->mask);
1277 }
1278 else
1279 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1280 FILE_ARCHIVED | FILE_DIRECTORY |
1281 FILE_HIDDEN | FILE_SYSTEM);
1282 }
1283 dcd->mask.attrFile |= FILE_DIRECTORY;
1284 }
1285 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
1286 cnri.flWindowAttr |= CV_FLOW;
1287 dcd->flWindowAttr = cnri.flWindowAttr;
1288 WinSendMsg(hwnd,
1289 CM_SETCNRINFO,
1290 MPFROMP(&cnri),
1291 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1292 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1293 if (xbeginthread(MakeObjWin,
1294 327680,
1295 dcd,
1296 pszSrcFile,
1297 __LINE__) == -1)
1298 {
1299 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1300 }
1301 else
1302 DosSleep(1);
1303# ifdef FORTIFY
1304 Fortify_LeaveScope();
1305# endif
1306 }
1307 }
1308 return 0;
1309
1310 case WM_BUTTON3CLICK:
1311 case WM_CHORD:
1312 {
1313 PCNRITEM pci = NULL;
1314 QUERYRECFROMRECT pqr;
1315 NOTIFYRECORDENTER nr;
1316 BOOL tbool = fDCOpens;
1317 RECTL rectl;
1318 POINTL ptl;
1319
1320 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1321 if (msg == WM_CHORD) {
1322 if (!WinQueryPointerPos(HWND_DESKTOP, &ptl))
1323 break;
1324 WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
1325 }
1326 else {
1327 ptl.x = SHORT1FROMMP(mp1);
1328 ptl.y = SHORT2FROMMP(mp1);
1329 }
1330 memset(&rectl, 0, sizeof(rectl));
1331 memset(&pqr, 0, sizeof(pqr));
1332 pqr.cb = sizeof(pqr);
1333 pqr.rect.xLeft = ptl.x - 1;
1334 pqr.rect.xRight = ptl.x + 1;
1335 pqr.rect.yTop = ptl.y + 1;
1336 pqr.rect.yBottom = ptl.y - 1;
1337 pqr.fsSearch = CMA_PARTIAL;
1338 pci = (PCNRITEM) WinSendMsg(hwnd,
1339 CM_QUERYRECORDFROMRECT,
1340 MPFROMLONG(CMA_FIRST), MPFROMP(&pqr));
1341 if (!pci || (INT) pci == -1)
1342 break; //Probable B3 click on white space
1343 else {
1344 memset(&nr, 0, sizeof(nr));
1345 nr.hwndCnr = hwnd;
1346 nr.pRecord = (PRECORDCORE) pci;
1347 fDCOpens = TRUE;
1348 WinSendMsg(hwnd,
1349 WM_CONTROL,
1350 MPFROM2SHORT(WinQueryWindowUShort(hwnd,
1351 QWS_ID),
1352 CN_ENTER), MPFROMP(&nr));
1353 PostMsg(hwnd, UM_RESTOREDC, MPFROMLONG(tbool), MPVOID);
1354 }
1355 }
1356 break;
1357
1358 case UM_RESTOREDC:
1359 fDCOpens = (BOOL) mp1;
1360 return 0;
1361
1362 case WM_CONTROL:
1363 DosError(FERR_DISABLEHARDERR);
1364 if (dcd) {
1365 switch (SHORT2FROMMP(mp1)) {
1366 case CN_BEGINEDIT:
1367 case CN_REALLOCPSZ:
1368 case CN_ENDEDIT:
1369 {
1370 MRESULT mre;
1371
1372 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
1373 if (mre != (MRESULT) - 1)
1374 return mre;
1375 }
1376 break;
1377
1378 case CN_DRAGLEAVE:
1379 if (mp2) {
1380
1381 PDRAGINFO pDInfo;
1382
1383 // fixme to know why - seems superfluous
1384 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
1385 DrgAccessDraginfo(pDInfo);
1386 DrgFreeDraginfo(pDInfo);
1387 }
1388 return 0;
1389
1390 case CN_DROPHELP:
1391 if (mp2) {
1392
1393 PDRAGINFO pDInfo;
1394 PCNRITEM pci;
1395 ULONG numitems;
1396 USHORT usOperation;
1397
1398 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
1399 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
1400 if (!DrgAccessDraginfo(pDInfo)) {
1401 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
1402 GetPString(IDS_DROPERRORTEXT));
1403 }
1404 else {
1405 numitems = DrgQueryDragitemCount(pDInfo);
1406 usOperation = pDInfo->usOperation;
1407 if (usOperation == DO_DEFAULT)
1408 usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
1409 FreeDragInfoData(hwnd, pDInfo);
1410 saymsg(MB_ENTER | MB_ICONASTERISK,
1411 hwnd,
1412 GetPString(IDS_DROPHELPHDRTEXT),
1413 GetPString(IDS_DROPHELPTEXT),
1414 numitems,
1415 &"s"[numitems == 1L],
1416 pci ? NullStr : GetPString(IDS_NOTEXT),
1417 pci ? NullStr : " ",
1418 pci ? pci->pszFileName : NullStr,
1419 pci ? " " : NullStr,
1420 GetPString((usOperation == DO_MOVE) ?
1421 IDS_MOVETEXT :
1422 (usOperation == DO_LINK) ?
1423 IDS_LINKTEXT : IDS_COPYTEXT));
1424 }
1425 }
1426 return 0;
1427
1428 case CN_DRAGAFTER:
1429 case CN_DRAGOVER:
1430 if (mp2) {
1431
1432 PDRAGITEM pDItem;
1433 PDRAGINFO pDInfo;
1434 PCNRITEM pci;
1435 USHORT uso;
1436
1437 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
1438 if (!DrgAccessDraginfo(pDInfo)) {
1439 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
1440 PCSZ_DRGACCESSDRAGINFO);
1441 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
1442 }
1443 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
1444 if ((INT) pci == -1)
1445 pci = NULL;
1446 if (pci && (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODROP))) {
1447 DrgFreeDraginfo(pDInfo);
1448 return MRFROM2SHORT(DOR_NODROP, 0);
1449 }
1450 if (!WinIsWindowEnabled(dcd->hwndFrame)) {
1451 DrgFreeDraginfo(pDInfo);
1452 return MRFROM2SHORT(DOR_NODROP, 0);
1453 }
1454 if (pci) {
1455 uso = pDInfo->usOperation;
1456 if (uso == DO_DEFAULT)
1457 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
1458 if (!(pci->attrFile & FILE_DIRECTORY)) {
1459 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
1460 DrgFreeDraginfo(pDInfo);
1461 return (MRFROM2SHORT(DOR_NODROP, 0));
1462 }
1463 if (uso != DO_LINK &&
1464 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
1465 DRIVE_NOTWRITEABLE)) {
1466
1467 ARC_TYPE *info;
1468
1469 if (!fQuickArcFind &&
1470 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
1471 DRIVE_SLOW))
1472 info = find_type(pci->pszFileName, NULL);
1473 else
1474 info = quick_find_type(pci->pszFileName, NULL);
1475 if (!info || ((uso == DO_MOVE && !info->move) ||
1476 (uso == DO_COPY && !info->create))) {
1477 DrgFreeDraginfo(pDInfo);
1478 return (MRFROM2SHORT(DOR_NODROP, 0));
1479 }
1480 }
1481 }
1482 }
1483 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
1484 0); /* Index to DRAGITEM */
1485 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
1486 DRM_OS2FILE, /* mechanisms and data */
1487 NULL) || DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE)) { /* formats */
1488 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
1489 if (!pci || (INT) pci == -1)
1490 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
1491 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
1492 DRIVE_NOTWRITEABLE)
1493 return MRFROM2SHORT(DOR_DROP, DO_LINK);
1494 if (toupper(*pci->pszFileName) < 'C')
1495 return MRFROM2SHORT(DOR_DROP, DO_COPY);
1496 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
1497 ((fCopyDefault) ? DO_COPY : DO_MOVE));
1498 }
1499 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
1500 }
1501 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
1502
1503 case CN_INITDRAG:
1504 {
1505 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
1506 PCNRITEM pci;
1507
1508 if (!pcd) {
1509 Runtime_Error(pszSrcFile, __LINE__, NULL);
1510 break;
1511 }
1512 else {
1513 pci = (PCNRITEM) pcd->pRecord;
1514 if (!pci || (INT) pci == -1) {
1515 Runtime_Error(pszSrcFile, __LINE__, NULL);
1516 break;
1517 }
1518 if (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODRAG)) {
1519 Runtime_Error(pszSrcFile, __LINE__, "drag not allowed");
1520 break;
1521 }
1522 if (hwndStatus2) {
1523 WinSetWindowText(hwndStatus2, (IsRoot(pci->pszFileName)) ?
1524 GetPString(IDS_DRAGROOTTEXT) :
1525 (pci->attrFile & FILE_DIRECTORY) ?
1526 GetPString(IDS_DRAGDIRTEXT) :
1527 GetPString(IDS_DRAGFILETEXT));
1528 }
1529 DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE);
1530 if (hwndStatus2) {
1531 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1532 }
1533 }
1534 }
1535 return 0;
1536
1537 case CN_DROP:
1538 {
1539 LISTINFO *li;
1540 ULONG action = UM_ACTION;
1541
1542 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
1543 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
1544 if (li) {
1545 if (!*li->targetpath) {
1546 if (li->list[0])
1547 PMMkDir(dcd->hwndParent, li->list[0], FALSE);
1548 FreeListInfo(li);
1549 return 0;
1550 }
1551 if (li->list && li->list[0] && IsRoot(li->list[0]))
1552 li->type = DO_LINK;
1553 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
1554
1555 CHECKLIST cl;
1556
1557 memset(&cl, 0, sizeof(cl));
1558 cl.size = sizeof(cl);
1559 cl.flags = li->type;
1560 cl.list = li->list;
1561 cl.cmd = li->type;
1562 cl.prompt = li->targetpath;
1563 li->type = WinDlgBox(HWND_DESKTOP,
1564 dcd->hwndParent,
1565 DropListProc,
1566 FM3ModHandle, DND_FRAME, MPFROMP(&cl));
1567 if (li->type == DID_ERROR)
1568 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,
1569 GetPString(IDS_DRAGDROPDIALOGTEXT));
1570 if (!li->type) {
1571 FreeListInfo(li);
1572 return 0;
1573 }
1574 li->list = cl.list;
1575 if (!li->list || !li->list[0]) {
1576 FreeListInfo(li);
1577 return 0;
1578 }
1579 }
1580 switch (li->type) {
1581 case DO_LINK:
1582 if (fLinkSetsIcon) {
1583 li->type = IDM_SETICON;
1584 action = UM_MASSACTION;
1585 }
1586 else
1587 li->type = IDM_COMPARE;
1588 break;
1589 case DND_EXTRACT:
1590 if (*li->targetpath && !IsFile(li->targetpath))
1591 li->type = IDM_EXTRACT;
1592 break;
1593 case DND_MOVE:
1594 li->type = IDM_MOVE;
1595 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1596 action = UM_MASSACTION;
1597 li->type = IDM_ARCHIVEM;
1598 }
1599 break;
1600 case DND_WILDMOVE:
1601 li->type = IDM_WILDMOVE;
1602 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1603 action = UM_MASSACTION;
1604 li->type = IDM_ARCHIVEM;
1605 }
1606 break;
1607 case DND_OBJECT:
1608 li->type = IDM_OBJECT;
1609 action = UM_MASSACTION;
1610 break;
1611 case DND_SHADOW:
1612 li->type = IDM_SHADOW;
1613 action = UM_MASSACTION;
1614 break;
1615 case DND_COMPARE:
1616 li->type = IDM_COMPARE;
1617 break;
1618 case DND_SETICON:
1619 action = UM_MASSACTION;
1620 li->type = IDM_SETICON;
1621 break;
1622 case DND_COPY:
1623 li->type = IDM_COPY;
1624 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1625 action = UM_MASSACTION;
1626 li->type = IDM_ARCHIVE;
1627 }
1628 break;
1629 case DND_WILDCOPY:
1630 li->type = IDM_WILDCOPY;
1631 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1632 action = UM_MASSACTION;
1633 li->type = IDM_ARCHIVE;
1634 }
1635 break;
1636 default:
1637 if (*li->arcname && li->info) {
1638 action = UM_MASSACTION;
1639 li->type = (li->type == DO_MOVE) ?
1640 IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
1641 }
1642 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
1643 action = UM_MASSACTION;
1644 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
1645 }
1646 else
1647 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
1648 break;
1649 }
1650 if (!li->list || !li->list[0])
1651 FreeListInfo(li);
1652 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
1653 FreeListInfo(li);
1654 else {
1655
1656 USHORT usop = 0;
1657
1658 switch (li->type) {
1659 case IDM_COPY:
1660 case IDM_WILDCOPY:
1661 usop = DO_COPY;
1662 break;
1663 case IDM_MOVE:
1664 case IDM_WILDMOVE:
1665 case IDM_ARCHIVEM:
1666 usop = DO_MOVE;
1667 break;
1668 }
1669 if (usop)
1670 return MRFROM2SHORT(DOR_DROP, usop);
1671 }
1672 }
1673 }
1674 return 0;
1675
1676 case CN_EMPHASIS:
1677 if (!fDummy) {
1678
1679 PNOTIFYRECORDEMPHASIS pre = mp2;
1680
1681 if (pre->fEmphasisMask & CRA_SELECTED) {
1682 if (pre->pRecord->flRecordAttr & CRA_SELECTED) {
1683 if (((PCNRITEM) (pre->pRecord))->attrFile & FILE_DIRECTORY) {
1684 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1685 if (fFollowTree &&
1686 !(driveflags
1687 [toupper(*((PCNRITEM) pre->pRecord)->pszFileName) -
1688 'A'] & DRIVE_INVALID)) {
1689 if (!LastDir && !ParentIsDesktop(hwnd, dcd->hwndParent))
1690 LastDir = FindDirCnr(dcd->hwndParent);
1691 if (LastDir) {
1692
1693 NOTIFYRECORDENTER pri;
1694 BOOL tbool = fDCOpens;
1695
1696 fDCOpens = FALSE;
1697 memset(&pri, 0, sizeof(pri));
1698 pri.hwndCnr = hwnd;
1699 pri.fKey = FALSE;
1700 pri.pRecord = pre->pRecord;
1701 WinSendMsg(hwnd,
1702 WM_CONTROL,
1703 MPFROM2SHORT(SHORT1FROMMP(mp1),
1704 CN_ENTER), MPFROMP(&pri));
1705 fDCOpens = tbool;
1706 }
1707 }
1708 if (*(ULONG *) realappname != FM3UL)
1709 WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
1710 MAIN_STATUS),
1711 ((PCNRITEM) (pre->pRecord))->pszFileName);
1712 }
1713 }
1714 }
1715 }
1716 break;
1717
1718 case CN_CONTEXTMENU:
1719 {
1720 PCNRITEM pci = (PCNRITEM) mp2;
1721 BOOL wasFollowing;
1722
1723 //DosEnterCritSec(); //GKY 11-28-08
1724 wasFollowing = fFollowTree;
1725 fFollowTree = FALSE;
1726 //DosExitCritSec();
1727 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
1728 WinSendMsg(hwnd,
1729 CM_SETRECORDEMPHASIS,
1730 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
1731 MarkAll(hwnd, FALSE, FALSE, TRUE);
1732 if (!(pci->attrFile & FILE_DIRECTORY))
1733 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
1734 else if (!IsRoot(pci->pszFileName))
1735 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
1736 else
1737 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
1738 }
1739 else {
1740 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP);
1741 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
1742 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1743 MPFROM2SHORT(TRUE, CRA_SOURCE));
1744 dcd->cnremphasized = TRUE;
1745 }
1746 }
1747 if (dcd->hwndLastMenu) {
1748 if (dcd->hwndLastMenu == DirMenu)
1749 WinEnableMenuItem(DirMenu, IDM_TREE, FALSE);
1750 if (dcd->hwndLastMenu == TreeCnrMenu) {
1751 if (dcd->flWindowAttr & CV_MINI)
1752 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
1753 }
1754 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
1755 if (dcd->cnremphasized) {
1756 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1757 MPFROM2SHORT(FALSE, CRA_SOURCE));
1758 dcd->cnremphasized = FALSE;
1759 }
1760 if (dcd->hwndLastMenu != TreeCnrMenu)
1761 MarkAll(hwnd, TRUE, FALSE, TRUE);
1762 }
1763 }
1764 //DosEnterCritSec(); //GKY 11-28-08
1765 fFollowTree = wasFollowing;
1766 //DosExitCritSec();
1767 }
1768 break;
1769
1770 case CN_ENTER:
1771 if (mp2) {
1772 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
1773
1774 PostMsg(hwnd, UM_ENTER, MPFROMP(pci), MPVOID);
1775 }
1776 break;
1777
1778 case CN_COLLAPSETREE:
1779 case CN_EXPANDTREE:
1780 {
1781 PCNRITEM pci = (PCNRITEM) mp2;
1782
1783 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
1784 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
1785
1786 struct
1787 {
1788 ULONG serial;
1789 CHAR volumelength;
1790 CHAR volumelabel[CCHMAXPATH];
1791 }
1792 volser;
1793
1794 memset(&volser, 0, sizeof(volser));
1795 DosError(FERR_DISABLEHARDERR);
1796 if (!DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
1797 FSIL_VOLSER, &volser,
1798 (ULONG) sizeof(volser))) {
1799 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
1800 !volser.serial ||
1801 driveserial[toupper(*pci->pszFileName) - 'A'] !=
1802 volser.serial)
1803 UnFlesh(hwnd, pci);
1804 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
1805 (!volser.serial ||
1806 driveserial[toupper(*pci->pszFileName) - 'A'] !=
1807 volser.serial)) {
1808 if (Flesh(hwnd, pci) &&
1809 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
1810 !dcd->suspendview && fTopDir)
1811 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
1812 }
1813 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
1814 }
1815 else {
1816 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
1817 UnFlesh(hwnd, pci);
1818 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1819 if (!fAlertBeepOff)
1820 DosBeep(250, 100);
1821 }
1822 }
1823 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
1824 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
1825 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
1826 }
1827 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
1828 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
1829 }
1830 }
1831 break;
1832 } // switch WM_CONTROL
1833 }
1834 return 0;
1835
1836 case UM_ACTION:
1837 if (mp1) {
1838
1839 LISTINFO *li = mp1;
1840 ULONG action = (ULONG) mp2;
1841
1842 if (!li->list || !li->list[0] ||
1843 !PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
1844 FreeListInfo(li);
1845 }
1846 return 0;
1847
1848 case UM_SHOWME:
1849 if (mp1 && dcd) {
1850 CHAR *dir = xstrdup((CHAR *)mp1, pszSrcFile, __LINE__);
1851
1852 if (dir) {
1853 if (!PostMsg(dcd->hwndObject, UM_SHOWME, MPFROMP(dir), MPVOID))
1854 free(dir);
1855 }
1856 }
1857 return 0;
1858
1859 case UM_TOPDIR:
1860 if (mp1) {
1861
1862 PCNRITEM pci = (PCNRITEM) mp1;
1863
1864 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1865 }
1866 return 0;
1867
1868 case UM_ENTER:
1869 {
1870 FILEFINDBUF3 ffb;
1871 HDIR hDir = HDIR_CREATE;
1872 ULONG nm = 1;
1873 APIRET status;
1874 BOOL IsOk = FALSE;
1875 ULONG ulDriveNum, ulDriveMap;
1876 PCNRITEM pciP, pciL, pci;
1877 ULONG fl = SWP_ACTIVATE;
1878
1879 if (fFollowTree)
1880 fl = 0;
1881 SetShiftState();
1882 pci = (PCNRITEM) mp1;
1883 if (pci &&
1884 (INT) pci != -1 &&
1885 !(pci->rc.flRecordAttr & CRA_INUSE) &&
1886 !(pci->flags & RECFLAGS_ENV) && IsFullName(pci->pszFileName)) {
1887 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_INVALID) {
1888 if (!fAlertBeepOff)
1889 DosBeep(50, 100);
1890 if (hwndStatus)
1891 WinSetWindowText(hwndStatus, GetPString(IDS_RESCANSUGTEXT));
1892 return 0;
1893 }
1894 DosError(FERR_DISABLEHARDERR);
1895 if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) {
1896 if (!(ulDriveMap & 1 << (toupper(*pci->pszFileName) - 'A'))) {
1897 pciL = pciP = pci;
1898 for (;;) {
1899 pciP = WinSendMsg(hwnd,
1900 CM_QUERYRECORD,
1901 MPFROMP(pciL),
1902 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
1903 if (pciP && (INT) pciP != -1)
1904 pciL = pciP;
1905 else {
1906 pciP = pciL;
1907 break;
1908 }
1909 } // for
1910 RemoveCnrItems(hwnd, pciP, 1, CMA_FREE | CMA_INVALIDATE);
1911 return 0;
1912 }
1913 }
1914 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
1915 (DRIVE_REMOVABLE | DRIVE_NOPRESCAN)) {
1916
1917 struct
1918 {
1919 ULONG serial;
1920 CHAR volumelength;
1921 CHAR volumelabel[CCHMAXPATH];
1922 }
1923 volser;
1924
1925 pciL = pciP = pci;
1926 for (;;) {
1927 pciP = WinSendMsg(hwnd,
1928 CM_QUERYRECORD,
1929 MPFROMP(pciL),
1930 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
1931 if (pciP && (INT) pciP != -1)
1932 pciL = pciP;
1933 else {
1934 pciP = pciL;
1935 break;
1936 }
1937 }
1938 if ((driveflags[toupper(*pci->pszFileName) - 'A'] &
1939 DRIVE_NOPRESCAN) ||
1940 (toupper(*pci->pszFileName) > 'B' &&
1941 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
1942 DRIVE_CDROM))) {
1943
1944 INT removable, x = (INT) (toupper(*pci->pszFileName) - 'A');
1945 ULONG drvtype;
1946 CHAR FileSystem[CCHMAXPATH];
1947
1948 DosError(FERR_DISABLEHARDERR);
1949 removable = CheckDrive(toupper(*pciP->pszFileName),
1950 FileSystem, &drvtype);
1951 if (removable != -1) {
1952 driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN |
1953 DRIVE_NOLOADICONS | DRIVE_NOLOADSUBJS |
1954 DRIVE_NOLOADLONGS | DRIVE_INCLUDEFILES |
1955 DRIVE_SLOW | DRIVE_NOSTATS |
1956 DRIVE_WRITEVERIFYOFF);
1957
1958 if (removable == 1)
1959 driveflags[x] |= DRIVE_REMOVABLE;
1960 if (drvtype & DRIVE_REMOTE)
1961 driveflags[x] |= DRIVE_REMOTE;
1962 if (!strcmp(FileSystem, CBSIFS)) {
1963 driveflags[x] |= DRIVE_ZIPSTREAM;
1964 driveflags[x] &= (~DRIVE_REMOTE);
1965 }
1966 if(!strcmp(FileSystem,NDFS32)) {
1967 driveflags[x] |= DRIVE_VIRTUAL;
1968 driveflags[x] &= (~DRIVE_REMOTE);
1969 }
1970 if(!strcmp(FileSystem,RAMFS)) {
1971 driveflags[x] |= DRIVE_RAMDISK;
1972 driveflags[x] &= (~DRIVE_REMOTE);
1973 }
1974 if (!strcmp(FileSystem, CDFS) || !strcmp(FileSystem, ISOFS))
1975 driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE | DRIVE_CDROM);
1976 if(!strcmp(FileSystem,NTFS))
1977 driveflags[x] |= DRIVE_NOTWRITEABLE;
1978 if (strcmp(FileSystem, HPFS) &&
1979 strcmp(FileSystem, JFS) &&
1980 strcmp(FileSystem, CDFS) &&
1981 strcmp(FileSystem, ISOFS) &&
1982 strcmp(FileSystem, RAMFS) &&
1983 strcmp(FileSystem, FAT32) &&
1984 strcmp(FileSystem, NDFS32) &&
1985 strcmp(FileSystem, NTFS) &&
1986 strcmp(FileSystem, HPFS386)) {
1987 driveflags[x] |= DRIVE_NOLONGNAMES;
1988 }
1989 SelectDriveIcon(pciP);
1990 WinSendMsg(hwnd,
1991 CM_INVALIDATERECORD,
1992 MPFROMP(&pciP),
1993 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
1994 if (hwndMain)
1995 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
1996 }
1997 }
1998 memset(&volser, 0, sizeof(volser));
1999 DosError(FERR_DISABLEHARDERR);
2000 status = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
2001 FSIL_VOLSER, &volser,
2002 (ULONG) sizeof(volser));
2003 if (!status) {
2004 if (!volser.serial ||
2005 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2006 volser.serial) {
2007 UnFlesh(hwnd, pciP);
2008 Flesh(hwnd, pciP);
2009 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
2010 }
2011 pciL = WinSendMsg(hwnd,
2012 CM_QUERYRECORD,
2013 MPFROMP(pciP),
2014 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
2015 if (!pciL)
2016 Flesh(hwnd, pciP);
2017 }
2018 else {
2019 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
2020 UnFlesh(hwnd, pci);
2021 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2022 PostMsg(hwnd, UM_SETUP2, MPFROMP(pci), MPFROMLONG(status));
2023 return 0;
2024 }
2025 }
2026 status = 0;
2027 IsOk = (IsRoot(pci->pszFileName) &&
2028 IsValidDrive(toupper(*pci->pszFileName)));
2029 if (!IsOk) {
2030 DosError(FERR_DISABLEHARDERR);
2031 status = DosFindFirst(pci->pszFileName, &hDir,
2032 FILE_NORMAL | FILE_DIRECTORY |
2033 FILE_ARCHIVED | FILE_READONLY |
2034 FILE_HIDDEN | FILE_SYSTEM,
2035 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
2036 priority_bumped();
2037 }
2038 if (!status) {
2039 if (!IsOk)
2040 DosFindClose(hDir);
2041 if (IsOk || (ffb.attrFile & FILE_DIRECTORY)) {
2042 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT)) {
2043 PostMsg(hwnd,
2044 WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
2045 return 0;
2046 }
2047 if ((shiftstate & (KC_CTRL | KC_SHIFT)) == (KC_CTRL | KC_SHIFT)) {
2048 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
2049 return 0;
2050 }
2051 if (!(shiftstate & (KC_CTRL | KC_SHIFT))) {
2052 if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
2053 if (FindDirCnrByName(pci->pszFileName, TRUE))
2054 return 0;
2055 }
2056 }
2057 if ((shiftstate & KC_CTRL) ||
2058 (!(shiftstate & KC_SHIFT) &&
2059 ParentIsDesktop(hwnd, dcd->hwndParent) && fVTreeOpensWPS)) {
2060
2061 ULONG size = sizeof(ULONG), flWindowAttr = CV_ICON;
2062 CHAR s[33];
2063
2064 strcpy(s, PCSZ_ICON);
2065 PrfQueryProfileData(fmprof,
2066 appname,
2067 "DirflWindowAttr",
2068 (PVOID) & flWindowAttr, &size);
2069 if (flWindowAttr & CV_DETAIL) {
2070 if (IsRoot(pci->pszFileName))
2071 strcpy(s, PCSZ_TREE);
2072 else
2073 strcpy(s, Details);
2074 }
2075 OpenObject(pci->pszFileName, s, dcd->hwndFrame);
2076 return 0;
2077 }
2078 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2079 !fDCOpens && !LastDir && !(shiftstate & KC_SHIFT))
2080 LastDir = FindDirCnr(dcd->hwndParent);
2081 if (LastDir && !fDCOpens && !(shiftstate & KC_SHIFT)) {
2082 WinSendMsg(LastDir,
2083 UM_SETDIR, MPFROMP(pci->pszFileName), MPVOID);
2084 WinSetWindowPos(WinQueryWindow(WinQueryWindow(LastDir,
2085 QW_PARENT),
2086 QW_PARENT),
2087 HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | fl);
2088 }
2089 else
2090 OpenDirCnr(hwnd,
2091 dcd->hwndParent,
2092 dcd->hwndFrame, FALSE, pci->pszFileName);
2093 }
2094 else {
2095 if (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
2096 DRIVE_INCLUDEFILES))
2097 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE);
2098 else {
2099
2100 SWP swp;
2101
2102 WinQueryWindowPos(dcd->hwndFrame, &swp);
2103 DefaultViewKeys(hwnd,
2104 dcd->hwndFrame,
2105 dcd->hwndParent, &swp, pci->pszFileName);
2106 }
2107 }
2108 }
2109 else {
2110 if (!IsRoot(pci->pszFileName)) {
2111 NotifyError(pci->pszFileName, status);
2112 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE);
2113 }
2114 }
2115 }
2116 else if (!pci)
2117 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
2118 if (fFollowTree)
2119 WinSetFocus(HWND_DESKTOP, hwnd);
2120 }
2121 return 0;
2122
2123 case WM_MENUEND:
2124 if (dcd) {
2125
2126 HWND hwndMenu = (HWND) mp2;
2127
2128 if (hwndMenu == TreeCnrMenu || hwndMenu == TreeMenu ||
2129 hwndMenu == DirMenu) {
2130 MarkAll(hwnd, TRUE, FALSE, TRUE);
2131 if (dcd->cnremphasized) {
2132 WinSendMsg(hwnd,
2133 CM_SETRECORDEMPHASIS,
2134 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2135 dcd->cnremphasized = FALSE;
2136 }
2137 }
2138 }
2139 break;
2140
2141 case UM_OPENWINDOWFORME:
2142 if (dcd) {
2143 if (mp1 && !IsFile((CHAR *)mp1))
2144 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
2145 }
2146 return 0;
2147
2148 case MM_PORTHOLEINIT:
2149 if (dcd) {
2150 switch (SHORT1FROMMP(mp1)) {
2151 case 0:
2152 case 1:
2153 {
2154 ULONG wmsg;
2155
2156 wmsg = ((SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU);
2157 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
2158 wmsg, MPVOID, MPVOID), mp1, mp2);
2159 }
2160 break;
2161 }
2162 }
2163 break;
2164
2165 case UM_INITMENU:
2166 case WM_INITMENU:
2167 if (dcd) {
2168
2169 switch (SHORT1FROMMP(mp1)) {
2170 case IDM_FILESMENU:
2171 {
2172 PCNRITEM pci;
2173
2174 pci = (PCNRITEM) CurrentRecord(hwnd);
2175 if (pci && (INT) pci != -1) {
2176 BOOL rdy;
2177 BOOL writeable;
2178 BOOL removable;
2179 BOOL local;
2180 BOOL underenv;
2181 CHAR chDrvU;
2182 CHAR szDrv[CCHMAXPATH];
2183
2184 strcpy(szDrv, pci->pszFileName);
2185 chDrvU = *pci->pszFileName;
2186 chDrvU = toupper(chDrvU);
2187 MakeValidDir(szDrv);
2188 rdy = *szDrv == chDrvU; // Drive not ready if MakeValidDir changes drive letter
2189 removable = rdy
2190 && (driveflags[chDrvU - 'A'] & DRIVE_REMOVABLE) != 0;
2191 writeable = rdy
2192 && !(driveflags[chDrvU - 'A'] & DRIVE_NOTWRITEABLE);
2193 local = rdy && (!(driveflags[chDrvU - 'A'] & (DRIVE_REMOTE | DRIVE_VIRTUAL)));
2194 underenv = (pci->flags & RECFLAGS_UNDERENV) != 0;
2195
2196 CopyPresParams((HWND) mp2, hwndMainMenu);
2197 WinEnableMenuItem((HWND) mp2, IDM_INFO, rdy);
2198
2199 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, writeable);
2200 WinEnableMenuItem((HWND) mp2, IDM_EAS, writeable);
2201 WinEnableMenuItem((HWND) mp2, IDM_SUBJECT, writeable);
2202 WinEnableMenuItem((HWND) mp2, IDM_DRVFLAGS, 1); // fixme to allow if not ready
2203
2204 WinEnableMenuItem((HWND) mp2, IDM_ARCHIVE, rdy);
2205
2206 WinEnableMenuItem((HWND) mp2, IDM_UPDATE, !underenv);
2207 WinEnableMenuItem((HWND) mp2, IDM_EXPANDSUBMENU, !underenv);
2208 WinEnableMenuItem((HWND) mp2, IDM_EXPAND, !underenv);
2209 WinEnableMenuItem((HWND) mp2, IDM_COLLAPSE, !underenv);
2210
2211 WinEnableMenuItem((HWND) mp2, IDM_SIZES, rdy);
2212 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, writeable);
2213 WinEnableMenuItem((HWND) mp2, IDM_SHOWALLFILES, rdy);
2214 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, writeable);
2215
2216 WinEnableMenuItem((HWND) mp2, IDM_CHKDSK, writeable && local);
2217 WinEnableMenuItem((HWND) mp2, IDM_FORMAT, writeable && local);
2218 WinEnableMenuItem((HWND) mp2, IDM_OPTIMIZE, writeable && local);
2219 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONSMENU, local);
2220 WinEnableMenuItem((HWND) mp2, IDM_PARTITION, fMiniLVM);
2221 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONDF, fDFSee);
2222 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVMG, fLVMGui);
2223 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONFD, fFDisk);
2224
2225 WinEnableMenuItem((HWND) mp2, IDM_DETACH, !local);
2226
2227 WinEnableMenuItem((HWND) mp2, IDM_EJECT, removable);
2228
2229 WinEnableMenuItem((HWND) mp2, IDM_LOCK, removable);
2230 WinEnableMenuItem((HWND) mp2, IDM_UNLOCK, removable);
2231
2232 WinEnableMenuItem((HWND) mp2, IDM_DELETE, !underenv && writeable);
2233 WinEnableMenuItem((HWND) mp2, IDM_PERMDELETE, !underenv
2234 && writeable);
2235 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, !underenv
2236 && writeable);
2237 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, !underenv
2238 && writeable);
2239 WinEnableMenuItem((HWND) mp2, IDM_RENAME, !underenv && writeable);
2240
2241 }
2242 }
2243 break;
2244
2245 case IDM_VIEWSMENU:
2246 WinCheckMenuItem((HWND) mp2,
2247 IDM_MINIICONS, ((dcd->flWindowAttr & CV_MINI) != 0));
2248 CopyPresParams((HWND) mp2, hwndMainMenu);
2249 WinEnableMenuItem((HWND) mp2, IDM_RESELECT, FALSE);
2250 WinEnableMenuItem((HWND) mp2, IDM_PARTITION, fMiniLVM);
2251 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONDF, fDFSee);
2252 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVMG, fLVMGui);
2253 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONFD, fFDisk);
2254 break;
2255
2256 case IDM_COMMANDSMENU:
2257 SetupCommandMenu((HWND) mp2, hwnd);
2258 CopyPresParams((HWND) mp2, hwndMainMenu);
2259 break;
2260
2261 case IDM_SORTSUBMENU:
2262 SetSortChecks((HWND) mp2, TreesortFlags);
2263 CopyPresParams((HWND) mp2, hwndMainMenu);
2264 break;
2265
2266 case IDM_WINDOWSMENU:
2267 SetupWinList((HWND) mp2,
2268 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
2269 CopyPresParams((HWND) mp2, hwndMainMenu);
2270 break;
2271 }
2272 dcd->hwndLastMenu = (HWND) mp2;
2273 }
2274 if (msg == WM_INITMENU)
2275 break;
2276 return 0;
2277
2278 case UM_COMMAND:
2279 if (!mp1)
2280 Runtime_Error(pszSrcFile, __LINE__, NULL);
2281 else {
2282 if (!dcd) {
2283 Runtime_Error(pszSrcFile, __LINE__, NULL);
2284 FreeListInfo((LISTINFO *) mp1);
2285 }
2286 else {
2287 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
2288 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
2289 FreeListInfo((LISTINFO *) mp1);
2290 }
2291 else
2292 return (MRESULT) TRUE;
2293 }
2294 }
2295 return 0;
2296
2297 case UM_LOADFILE:
2298 if (dcd && mp2) {
2299
2300 HWND hwnd;
2301
2302 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
2303 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
2304 (CHAR *)mp2, dcd->hwndFrame);
2305 else
2306 hwnd = StartMLEEditor(dcd->hwndParent,
2307 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
2308 free((CHAR *)mp2);
2309 return MRFROMLONG(hwnd);
2310 }
2311 return 0;
2312
2313 case UM_FIXCNRMLE:
2314 case UM_FIXEDITNAME:
2315 return CommonCnrProc(hwnd, msg, mp1, mp2);
2316
2317 case UM_NOTIFY:
2318 if (mp2)
2319 Notify((CHAR *)mp2);
2320 return 0;
2321
2322 case UM_FILTER:
2323 if (dcd) {
2324
2325 BOOL tempsusp = dcd->suspendview;
2326
2327 if (mp1) {
2328 //DosEnterCritSec(); // GKY 11-30-08 moved to SetMask
2329 SetMask((CHAR *)mp1, &dcd->mask);
2330 //DosExitCritSec();
2331 }
2332 dcd->suspendview = TRUE;
2333 dcd->mask.attrFile |= FILE_DIRECTORY;
2334 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2335 dcd->suspendview = tempsusp;
2336 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2337 }
2338 return 0;
2339
2340 case UM_DRIVECMD:
2341 if (mp1)
2342 ShowTreeRec(hwnd, (CHAR *)mp1, FALSE, TRUE);
2343 return 0;
2344
2345 case WM_APPTERMINATENOTIFY:
2346 {
2347 APPNOTIFY *info;
2348 PCNRITEM pci;
2349 CHAR s[] = " :\\";
2350
2351 if (!mp2) {
2352 if (hwndMain)
2353 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
2354 }
2355 info = apphead;
2356 while (info) {
2357 if (info->happ == (HAPP) mp1) {
2358 *s = info->device;
2359 pci = FindCnrRecord(hwnd, s, NULL, FALSE, FALSE, TRUE);
2360 if (pci && (INT) pci != -1) {
2361 driveserial[info->device - 'A'] = -1;
2362 DriveFlagsOne(info->device - 'A');
2363 if (driveflags[info->device - 'A'] &
2364 (DRIVE_INVALID | DRIVE_IGNORE))
2365 RemoveCnrItems(hwnd, pci, 1, CMA_FREE);
2366 else
2367 Flesh(hwnd, pci);
2368 }
2369 if (info->prev)
2370 info->prev->next = info->next;
2371 if (info->next)
2372 info->next->prev = info->prev;
2373 if (apphead == info)
2374 apphead = info->next;
2375 if (apptail == info)
2376 apptail = info->prev;
2377 free(info);
2378 break;
2379 }
2380 info = info->next;
2381 }
2382 }
2383 break;
2384
2385 case WM_COMMAND:
2386 DosError(FERR_DISABLEHARDERR);
2387 if (dcd) {
2388 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2389 return 0;
2390 switch (SHORT1FROMMP(mp1)) {
2391 case IDM_SETTARGET:
2392 SetTargetDir(hwnd, FALSE);
2393 break;
2394
2395 case IDM_DETACH:
2396 {
2397 CHAR d[3] = " :";
2398 PCNRITEM pci;
2399 PROGDETAILS pgd;
2400 CHAR params[368], *p;
2401 HAPP happ;
2402
2403 pci = (PCNRITEM) CurrentRecord(hwnd);
2404 if (pci && (INT) pci != -1 && isalpha(*pci->pszFileName)) {
2405 *d = toupper(*pci->pszFileName);
2406 p = GetCmdSpec(FALSE);
2407 memset(&pgd, 0, sizeof(pgd));
2408 pgd.Length = sizeof(pgd);
2409 pgd.progt.progc = PROG_WINDOWABLEVIO;
2410 pgd.progt.fbVisible = SHE_VISIBLE;
2411 pgd.pszTitle = (PSZ)GetPString(IDS_DETACHREQUESTTEXT);
2412 pgd.pszExecutable = p;
2413 pgd.pszParameters = params;
2414 pgd.pszStartupDir = NULL;
2415 pgd.pszIcon = NULL;
2416 pgd.pszEnvironment = NULL;
2417 pgd.swpInitial.hwndInsertBehind = HWND_TOP;
2418 pgd.swpInitial.hwnd = hwnd;
2419 pgd.swpInitial.fl = SWP_SHOW | SWP_ACTIVATE;
2420 sprintf(params, "/C NET USE %s /D", d);
2421 happ = WinStartApp(hwnd, &pgd, pgd.pszParameters,
2422 NULL, SAF_MAXIMIZED);
2423 if (!happ) {
2424 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, hwnd,
2425 GetPString(IDS_ERRORTEXT),
2426 GetPString(IDS_CANTSTARTTEXT), p, params);
2427 }
2428 else {
2429 APPNOTIFY *info;
2430
2431 info = xmallocz(sizeof(APPNOTIFY), pszSrcFile, __LINE__);
2432 if (info) {
2433 info->happ = happ;
2434 info->device = *d;
2435 if (!apphead)
2436 apphead = info;
2437 else {
2438 apptail->next = info;
2439 info->prev = apptail;
2440 }
2441 apptail = info;
2442 }
2443 }
2444 }
2445 }
2446 break;
2447
2448 case IDM_REMAP:
2449 WinDlgBox(HWND_DESKTOP, hwnd, RemapDlgProc,
2450 FM3ModHandle, MAP_FRAME, NULL);
2451 break;
2452
2453 case IDM_CONTEXTMENU:
2454 {
2455 PCNRITEM pci;
2456
2457 pci = (PCNRITEM) CurrentRecord(hwnd);
2458 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
2459 MPFROMP(pci));
2460 }
2461 break;
2462
2463 case IDM_FINDINTREE:
2464 {
2465 PSZ pszTempDir;
2466 PCNRITEM pci;
2467
2468 pci = (PCNRITEM) CurrentRecord(hwnd);
2469 if (pci && (INT) pci != -1) {
2470 pszTempDir = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
2471 if (pszTempDir)
2472 MakeValidDir(pszTempDir);
2473 }
2474 else
2475 pszTempDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
2476 if (pszTempDir) {
2477 if (WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2478 WalkAllDlgProc,
2479 FM3ModHandle, WALK_FRAME, MPFROMP(pszTempDir))) {
2480 if (!WinSendMsg(hwnd, UM_SHOWME, MPFROMP(pszTempDir), MPFROMLONG(1)))
2481 free(pszTempDir);
2482 }
2483 else
2484 free(pszTempDir);
2485 }
2486 }
2487 break;
2488
2489 case IDM_BEGINEDIT:
2490 OpenEdit(hwnd);
2491 break;
2492
2493 case IDM_ENDEDIT:
2494 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
2495 break;
2496
2497 case IDM_FILTER:
2498 {
2499 BOOL empty = FALSE;
2500 PCNRITEM pci;
2501
2502 pci = (PCNRITEM) CurrentRecord(hwnd);
2503 if (!*dcd->mask.szMask)
2504 empty = TRUE;
2505 dcd->mask.fIsTree = TRUE;
2506 *dcd->mask.prompt = 0;
2507 if (pci && (INT) pci != -1)
2508 dcd->mask.fFilesIncluded =
2509 ((driveflags[toupper(*pci->pszFileName) - 'A'] &
2510 DRIVE_INCLUDEFILES) != 0);
2511 else
2512 dcd->mask.fFilesIncluded = FALSE;
2513 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2514 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2515 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2516 else if (empty)
2517 *dcd->mask.szMask = 0;
2518 PrfWriteProfileData(fmprof, appname, "TreeFilter", &dcd->mask,
2519 sizeof(MASK));
2520 }
2521 break;
2522
2523 case IDM_SHOWSORT:
2524 QuickPopup(hwnd, dcd, CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP),
2525 IDM_SORTSUBMENU);
2526 break;
2527
2528 case IDM_SHOWSELECT:
2529 QuickPopup(hwnd, dcd, CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP),
2530 IDM_SELECTSUBMENU);
2531 break;
2532
2533 case IDM_TREECNRVIEWSETTINGS:
2534 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
2535 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_TREECNRVIEWSETTINGS), mp2);
2536 else {
2537 WinDlgBox(HWND_DESKTOP,
2538 hwnd,
2539 CfgDlgProc,
2540 FM3ModHandle,
2541 CFG_FRAME,
2542 MPFROMLONG(IDM_TREECNRVIEWSETTINGS));
2543 }
2544 break;
2545
2546 case IDM_WALKDIR:
2547 case IDM_OPENWALK:
2548 {
2549 CHAR newpath[CCHMAXPATH];
2550 PCNRITEM pci;
2551
2552 pci = (PCNRITEM) CurrentRecord(hwnd);
2553 if (pci && (INT) pci != -1) {
2554 strcpy(newpath, pci->pszFileName);
2555 MakeValidDir(newpath);
2556 }
2557 else
2558 strcpy(newpath, pFM2SaveDirectory);
2559 if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkAllDlgProc,
2560 FM3ModHandle, WALK_FRAME,
2561 MPFROMP(newpath)) || !*newpath)
2562 break;
2563 WinSendMsg(hwnd, UM_OPENWINDOWFORME, MPFROMP(newpath), MPVOID);
2564 }
2565 break;
2566
2567 case IDM_HELP:
2568 if (hwndHelp) {
2569 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
2570 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
2571 else
2572 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
2573 }
2574 break;
2575
2576 case IDM_PARTITION:
2577 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2578 NULL, NULL,
2579 "%s", PCSZ_MINILVMEXE);
2580 break;
2581
2582 case IDM_PARTITIONDF:
2583 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2584 NULL, NULL,
2585 "%s", PCSZ_DFSOS2EXE);
2586 break;
2587
2588 case IDM_PARTITIONLVMG:
2589 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2590 NULL, NULL,
2591 "%s", PCSZ_LVMGUICMD);
2592 break;
2593
2594 case IDM_PARTITIONFD:
2595 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2596 NULL, NULL,
2597 "%s", PCSZ_FDISKPMEXE);
2598 break;
2599
2600 case IDM_REFRESHREMOVABLES:
2601 runemf2(SEPARATE | WINDOWED | BACKGROUND | MINIMIZED | WAIT,
2602 HWND_DESKTOP, pszSrcFile, __LINE__, NULL, NULL,
2603 "%s %s", PCSZ_LVMEXE, "/RediscoverPRM");
2604 PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
2605 break;
2606
2607 case IDM_SORTNAME:
2608 case IDM_SORTFILENAME:
2609 case IDM_SORTSIZE:
2610 case IDM_SORTEASIZE:
2611 case IDM_SORTFIRST:
2612 case IDM_SORTLAST:
2613 case IDM_SORTLWDATE:
2614 case IDM_SORTLADATE:
2615 case IDM_SORTCRDATE:
2616 TreesortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
2617 case IDM_SORTDIRSFIRST:
2618 case IDM_SORTDIRSLAST:
2619 case IDM_SORTREVERSE:
2620 switch (SHORT1FROMMP(mp1)) {
2621 case IDM_SORTFILENAME:
2622 TreesortFlags |= SORT_FILENAME;
2623 break;
2624 case IDM_SORTSIZE:
2625 TreesortFlags |= SORT_SIZE;
2626 break;
2627 case IDM_SORTEASIZE:
2628 TreesortFlags |= SORT_EASIZE;
2629 break;
2630 case IDM_SORTFIRST:
2631 TreesortFlags |= SORT_FIRSTEXTENSION;
2632 break;
2633 case IDM_SORTLAST:
2634 TreesortFlags |= SORT_LASTEXTENSION;
2635 break;
2636 case IDM_SORTLWDATE:
2637 TreesortFlags |= SORT_LWDATE;
2638 break;
2639 case IDM_SORTLADATE:
2640 TreesortFlags |= SORT_LADATE;
2641 break;
2642 case IDM_SORTCRDATE:
2643 TreesortFlags |= SORT_CRDATE;
2644 break;
2645 case IDM_SORTDIRSFIRST:
2646 if (TreesortFlags & SORT_DIRSFIRST)
2647 TreesortFlags &= (~SORT_DIRSFIRST);
2648 else {
2649 TreesortFlags |= SORT_DIRSFIRST;
2650 TreesortFlags &= (~SORT_DIRSLAST);
2651 }
2652 break;
2653 case IDM_SORTDIRSLAST:
2654 if (TreesortFlags & SORT_DIRSLAST)
2655 TreesortFlags &= (~SORT_DIRSLAST);
2656 else {
2657 TreesortFlags |= SORT_DIRSLAST;
2658 TreesortFlags &= (~SORT_DIRSFIRST);
2659 }
2660 break;
2661 case IDM_SORTREVERSE:
2662 if (TreesortFlags & SORT_REVERSE)
2663 TreesortFlags &= (~SORT_REVERSE);
2664 else
2665 TreesortFlags |= SORT_REVERSE;
2666 break;
2667 }
2668 PrfWriteProfileData(fmprof, appname, "TreeSort", &TreesortFlags,
2669 sizeof(INT));
2670 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
2671 break;
2672
2673 case IDM_COLLECT:
2674 case IDM_GREP:
2675 if (!Collector) {
2676
2677 HWND hwndC;
2678 SWP swp;
2679
2680 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2681 !fAutoTile &&
2682 (!fExternalCollector && *(ULONG *) realappname == FM3UL))
2683 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2684 hwndC = StartCollector((fExternalCollector ||
2685 *(ULONG *) realappname != FM3UL) ?
2686 HWND_DESKTOP : dcd->hwndParent, 4);
2687 if (hwndC) {
2688 if (!ParentIsDesktop(hwnd,
2689 dcd->hwndParent) &&
2690 !fAutoTile &&
2691 (!fExternalCollector && *(ULONG *) realappname == FM3UL))
2692 WinSetWindowPos(hwndC,
2693 HWND_TOP,
2694 swp.x,
2695 swp.y,
2696 swp.cx,
2697 swp.cy,
2698 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
2699 else if (!ParentIsDesktop(hwnd,
2700 dcd->hwndParent) &&
2701 fAutoTile && *(ULONG *) realappname == FM3UL)
2702 TileChildren(dcd->hwndParent, TRUE);
2703 }
2704 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
2705 DosSleep(100);//05 Aug 07 GKY 250
2706 }
2707 else
2708 StartCollector(dcd->hwndParent, 4);
2709 if (SHORT1FROMMP(mp1) == IDM_GREP) {
2710 PCNRITEM pci = NULL;
2711
2712 pci = WinSendMsg(hwnd,
2713 CM_QUERYRECORDEMPHASIS,
2714 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
2715 if (pci && (INT) pci != -1)
2716 PostMsg(Collector, WM_COMMAND,
2717 MPFROM2SHORT(IDM_GREP, 0), MPFROMP(pci->pszFileName));
2718 else
2719 PostMsg(Collector, WM_COMMAND,
2720 MPFROM2SHORT(IDM_GREP, 0), MPVOID);
2721 }
2722 else
2723 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2724 break;
2725
2726 case IDM_COLLECTOR:
2727 DosSleep(32);//05 Aug 07 GKY 64
2728 {
2729 CHAR **list;
2730
2731 list = BuildList(hwnd);
2732 if (list) {
2733 if (Collector) {
2734 if (!PostMsg(Collector, WM_COMMAND,
2735 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2736 FreeList(list);
2737 }
2738 else
2739 FreeList(list);
2740 }
2741 }
2742 break;
2743
2744 case IDM_COLLAPSEALL:
2745 WinSendMsg(hwnd, CM_COLLAPSETREE, MPVOID, MPVOID);
2746 break;
2747
2748 case IDM_COLLAPSE:
2749 case IDM_EXPAND:
2750 {
2751 PCNRITEM pci = NULL;
2752
2753 pci = (PCNRITEM) CurrentRecord(hwnd);
2754 if (pci && (INT) pci != -1) {
2755 if (pci->flags & RECFLAGS_UNDERENV)
2756 break;
2757 PostMsg(dcd->hwndObject, UM_EXPAND, mp1, MPFROMP(pci));
2758 }
2759 }
2760 break;
2761
2762 case IDM_UPDATE:
2763 {
2764 PCNRITEM pci = (PCNRITEM)CurrentRecord(hwnd);
2765 if (pci && (INT)pci != -1) {
2766 UINT driveflag = driveflags[toupper(*pci->pszFileName) - 'A'];
2767 if (pci->attrFile & FILE_DIRECTORY) {
2768 if (pci->flags & RECFLAGS_UNDERENV)
2769 break;
2770 UnFlesh(hwnd, pci);
2771 // Check if drive type might need update
2772 if ((driveflag & (DRIVE_INVALID | DRIVE_NOPRESCAN)) ||
2773 (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno))
2774 {
2775 driveflags[toupper(*pci->pszFileName) - 'A'] &=
2776 (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
2777 DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | DRIVE_NOSTATS |
2778 DRIVE_WRITEVERIFYOFF);
2779 DriveFlagsOne(toupper(*pci->pszFileName) - 'A');
2780 driveflag = driveflags[toupper(*pci->pszFileName) - 'A'];
2781 if (driveflag & DRIVE_INVALID)
2782 pci->rc.hptrIcon = hptrDunno;
2783 else {
2784 SelectDriveIcon(pci);
2785 }
2786 WinSendMsg(hwnd,
2787 CM_INVALIDATERECORD,
2788 MPFROMP(&pci),
2789 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2790 if (hwndMain)
2791 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
2792 }
2793 if (~driveflag & DRIVE_INVALID)
2794 Flesh(hwnd, pci);
2795 }
2796 }
2797 }
2798 break;
2799
2800 case IDM_RESCAN:
2801 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
2802 break;
2803
2804 case IDM_RESORT:
2805 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
2806 break;
2807
2808 case IDM_TEXT:
2809 case IDM_MINIICONS:
2810 {
2811 CNRINFO cnri;
2812
2813 memset(&cnri, 0, sizeof(CNRINFO));
2814 cnri.cb = sizeof(CNRINFO);
2815 WinSendMsg(hwnd,
2816 CM_QUERYCNRINFO,
2817 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
2818 if (SHORT1FROMMP(mp1) == IDM_MINIICONS) {
2819 if (cnri.flWindowAttr & CV_MINI)
2820 cnri.flWindowAttr &= (~CV_MINI);
2821 else
2822 cnri.flWindowAttr |= CV_MINI;
2823 }
2824 else {
2825 if (cnri.flWindowAttr & CV_TEXT) {
2826 cnri.flWindowAttr &= (~CV_TEXT);
2827 cnri.flWindowAttr |= CV_ICON;
2828 }
2829 else {
2830 cnri.flWindowAttr &= (~CV_ICON);
2831 cnri.flWindowAttr |= CV_TEXT;
2832 }
2833 }
2834 dcd->flWindowAttr = cnri.flWindowAttr;
2835 PrfWriteProfileData(fmprof,
2836 appname,
2837 "TreeflWindowAttr",
2838 &cnri.flWindowAttr, sizeof(ULONG));
2839 WinSendMsg(hwnd,
2840 CM_SETCNRINFO,
2841 MPFROMP(&cnri),
2842 MPFROMLONG(CMA_FLWINDOWATTR | CMA_TREEICON |
2843 CMA_SLTREEBITMAPORICON));
2844 }
2845 break;
2846
2847 case IDM_SIZES:
2848 case IDM_DRVFLAGS:
2849 case IDM_SHOWALLFILES:
2850 case IDM_UNDELETE:
2851 case IDM_OPTIMIZE:
2852 case IDM_CHKDSK:
2853 case IDM_FORMAT:
2854 case IDM_MKDIR:
2855 case IDM_LOCK:
2856 case IDM_UNLOCK:
2857 case IDM_EJECT:
2858 case IDM_CLOSETRAY:
2859 {
2860 PCNRITEM pci;
2861
2862 pci = (PCNRITEM) CurrentRecord(hwnd);
2863 if (pci && (INT) pci != -1)
2864 CommonDriveCmd(hwnd, pci->pszFileName, SHORT1FROMMP(mp1));
2865 }
2866 break;
2867
2868 case IDM_SAVETOLIST:
2869 WinDlgBox(HWND_DESKTOP,
2870 hwnd,
2871 SaveListDlgProc, FM3ModHandle, SAV_FRAME, MPFROMP(&hwnd));
2872 break;
2873
2874 case IDM_DELETE:
2875 case IDM_PERMDELETE:
2876 case IDM_MOVE:
2877 case IDM_WPSMOVE:
2878 case IDM_WILDMOVE:
2879 case IDM_RENAME:
2880 {
2881 PCNRITEM pci;
2882
2883 pci = (PCNRITEM) CurrentRecord(hwnd);
2884 if (pci && (INT) pci != -1) {
2885 if (pci->flags & RECFLAGS_UNDERENV)
2886 break;
2887 }
2888 }
2889 /* else intentional fallthru */
2890 case IDM_ATTRS:
2891 case IDM_INFO:
2892 case IDM_COPY:
2893 case IDM_WPSCOPY:
2894 case IDM_WILDCOPY:
2895 case IDM_DOITYOURSELF:
2896 case IDM_OPENWINDOW:
2897 case IDM_OPENSETTINGS:
2898 case IDM_OPENDEFAULT:
2899 case IDM_OPENICON:
2900 case IDM_OPENDETAILS:
2901 case IDM_OPENTREE:
2902 case IDM_SHADOW:
2903 case IDM_SHADOW2:
2904 case IDM_COMPARE:
2905 case IDM_VIEW:
2906 case IDM_VIEWTEXT:
2907 case IDM_VIEWBINARY:
2908 case IDM_EDIT:
2909 case IDM_EDITTEXT:
2910 case IDM_EDITBINARY:
2911 case IDM_EAS:
2912 case IDM_SUBJECT:
2913 case IDM_APPENDTOCLIP:
2914 case IDM_SAVETOCLIP:
2915 case IDM_ARCHIVE:
2916 case IDM_MCIPLAY:
2917 case IDM_UUDECODE:
2918 {
2919 LISTINFO *li;
2920 ULONG action = UM_ACTION;
2921# ifdef FORTIFY
2922 Fortify_EnterScope();
2923# endif
2924 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2925 if (li) {
2926 li->type = SHORT1FROMMP(mp1);
2927 li->hwnd = hwnd;
2928 li->list = BuildList(hwnd);
2929 if (!li->list || !li->list[0]) {
2930 free(li);
2931 break;
2932 }
2933 if (IsRoot(li->list[0])) {
2934 switch (SHORT1FROMMP(mp1)) {
2935 case IDM_MOVE:
2936 case IDM_COPY:
2937 case IDM_WILDCOPY:
2938 case IDM_WILDMOVE:
2939 case IDM_WPSMOVE:
2940 case IDM_WPSCOPY:
2941 case IDM_RENAME:
2942 case IDM_DELETE:
2943 case IDM_PERMDELETE:
2944 mp1 = MPFROM2SHORT(IDM_INFO, SHORT2FROMMP(mp1));
2945 li->type = IDM_INFO;
2946 }
2947 }
2948 switch (SHORT1FROMMP(mp1)) {
2949 case IDM_APPENDTOCLIP:
2950 case IDM_SAVETOCLIP:
2951 case IDM_ARCHIVE:
2952 case IDM_DELETE:
2953 case IDM_PERMDELETE:
2954 case IDM_ATTRS:
2955 case IDM_SHADOW:
2956 case IDM_SHADOW2:
2957 case IDM_DOITYOURSELF:
2958 case IDM_EAS:
2959 case IDM_VIEW:
2960 case IDM_VIEWTEXT:
2961 case IDM_VIEWBINARY:
2962 case IDM_EDIT:
2963 case IDM_EDITTEXT:
2964 case IDM_EDITBINARY:
2965 case IDM_MCIPLAY:
2966 action = UM_MASSACTION;
2967 }
2968 if (SHORT1FROMMP(mp1) == IDM_SHADOW ||
2969 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2970 *li->targetpath = 0;
2971 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2972 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
2973 FreeListInfo(li);
2974 }
2975 }
2976# ifdef FORTIFY
2977 Fortify_LeaveScope();
2978# endif
2979 }
2980 break;
2981
2982 default:
2983 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2984 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2985
2986 INT x;
2987
2988 if (!cmdloaded)
2989 load_commands();
2990 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2991 if (x >= 0) {
2992 x++;
2993 RunCommand(hwnd, x);
2994 if (fUnHilite)
2995 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2996 }
2997 }
2998 break;
2999 }
3000 }
3001 return 0;
3002
3003 case WM_SAVEAPPLICATION:
3004 if (dcd && !ParentIsDesktop(hwnd, dcd->hwndParent)) {
3005
3006 SWP swp, swpP;
3007 INT ratio;
3008
3009 WinQueryWindowPos(dcd->hwndFrame, &swp);
3010 if (!(swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE | SWP_HIDE))) {
3011 WinQueryWindowPos(dcd->hwndParent, &swpP);
3012 if (swp.cx) {
3013 ratio = (swpP.cx * 100) / swp.cx;
3014 if (ratio > 0)
3015 PrfWriteProfileData(fmprof, appname, "TreeWindowRatio",
3016 &ratio, sizeof(INT));
3017 }
3018 }
3019 }
3020 else if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3021
3022 SWP swp;
3023
3024 WinQueryWindowPos(dcd->hwndFrame, &swp);
3025 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3026 WinStoreWindowPos(FM2Str, "VTreeWindowPos", dcd->hwndFrame);
3027 }
3028 break;
3029
3030 case UM_MINIMIZE:
3031 if (dcd && hwndMain) {
3032 fOkayMinimize = TRUE;
3033 if (dcd->hwndObject && !fDummy) {
3034 DosSleep(50);//05 Aug 07 GKY 100
3035 if (!fDummy) {
3036 fOkayMinimize = FALSE;
3037 WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
3038 dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0,
3039 SWP_MINIMIZE | SWP_DEACTIVATE);
3040 }
3041 }
3042 }
3043 return 0;
3044
3045 case UM_MAXIMIZE:
3046 if (dcd || hwndMain)
3047 WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
3048 dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0, SWP_MAXIMIZE |
3049 SWP_SHOW);
3050 return 0;
3051
3052 case UM_CLOSE:
3053 {
3054 HWND hwndParent = WinQueryWindow(WinQueryWindow(WinQueryWindow(hwnd,
3055 QW_PARENT),
3056 QW_PARENT), QW_PARENT);
3057
3058 if (!mp1) {
3059 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
3060 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3061 if (hwndParent && !ParentIsDesktop(hwnd, hwndParent))
3062 WinDestroyWindow(hwndParent);
3063 }
3064 else
3065 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3066 QW_PARENT));
3067 }
3068 return 0;
3069
3070 case WM_CLOSE:
3071 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3072 if (dcd)
3073 dcd->stopflag++;
3074 if (dcd && dcd->hwndObject) {
3075 /* kill object window */
3076 if (WinIsWindow((HAB) 0, dcd->hwndObject)) {
3077 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3078 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
3079 }
3080 }
3081 else
3082 WinSendMsg(hwnd, UM_CLOSE, MPFROMLONG(1), MPVOID);
3083 return 0;
3084
3085 case WM_DESTROY:
3086# ifdef FORTIFY
3087 DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
3088# endif
3089 if (TreeCnrMenu)
3090 WinDestroyWindow(TreeCnrMenu);
3091 if (DirMenu)
3092 WinDestroyWindow(DirMenu);
3093 if (FileMenu)
3094 WinDestroyWindow(FileMenu);
3095 TreeCnrMenu = FileMenu = DirMenu = (HWND) 0;
3096 EmptyCnr(hwnd);
3097 if (apphead) {
3098 APPNOTIFY *info, *next;
3099 info = apphead;
3100 while (info) {
3101 next = info->next;
3102 free(info);
3103 info = next;
3104 }
3105 apphead = apptail = NULL;
3106 }
3107# ifdef FORTIFY
3108 Fortify_LeaveScope();
3109# endif
3110 break; // WM_DESTROY
3111 } // switch
3112 if (dcd && dcd->oldproc){
3113 return dcd->oldproc(hwnd, msg, mp1, mp2);
3114 }
3115 else
3116 return PFNWPCnr(hwnd, msg, mp1, mp2);
3117}
3118
3119HWND StartTreeCnr(HWND hwndParent, ULONG flags)
3120{
3121 /* bitmapped flags:
3122 * 0x00000001 = don't close app when window closes
3123 * 0x00000002 = no frame controls
3124 * 0x00000004 = no close or move button
3125 */
3126
3127 HWND hwndFrame = NULLHANDLE;
3128 HWND hwndSysMenu = NULLHANDLE;
3129 HWND hwndClient;
3130 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3131 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3132 DIRCNRDATA *dcd;
3133
3134 if (!hwndParent)
3135 hwndParent = HWND_DESKTOP;
3136 if (ParentIsDesktop(hwndParent, hwndParent))
3137 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3138 if (flags & 2)
3139 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3140 FCF_MINMAX | FCF_ICON));
3141 hwndFrame = WinCreateStdWindow(hwndParent,
3142 WS_VISIBLE,
3143 &FrameFlags,
3144 WC_TREECONTAINER,
3145 NULL,
3146 WS_VISIBLE | fwsAnimate,
3147 FM3ModHandle, TREE_FRAME, &hwndClient);
3148 if (hwndParent != HWND_DESKTOP) {
3149 hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
3150 if (hwndSysMenu != NULLHANDLE)
3151 WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
3152 MPFROM2SHORT(SC_CLOSE, TRUE),
3153 MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
3154 if (!fFreeTree)
3155 WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
3156 MPFROM2SHORT(SC_MOVE, TRUE),
3157 MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
3158 }
3159 if (hwndFrame && hwndClient) {
3160# ifdef FORTIFY
3161 Fortify_EnterScope();
3162# endif
3163 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3164 if (!dcd) {
3165 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_OUTOFMEMORY));
3166 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3167 hwndFrame = (HWND) 0;
3168 }
3169 else {
3170 SWP swp;
3171 WinQueryWindowPos(hwndFrame, &swp);
3172 if (*(ULONG *) realappname == FM3UL) {
3173 if (!WinCreateWindow(hwndFrame,
3174 WC_TREEOPENBUTTON,
3175 "#303",
3176 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | BS_BITMAP,
3177 ((swp.cx -
3178 WinQuerySysValue(HWND_DESKTOP,
3179 SV_CXMINMAXBUTTON)) -
3180 WinQuerySysValue(HWND_DESKTOP,
3181 SV_CXMINMAXBUTTON) / 2) -
3182 WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER),
3183 (swp.cy -
3184 WinQuerySysValue(HWND_DESKTOP,
3185 SV_CYMINMAXBUTTON)) -
3186 WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER),
3187 WinQuerySysValue(HWND_DESKTOP,
3188 SV_CXMINMAXBUTTON) / 2,
3189 WinQuerySysValue(HWND_DESKTOP,
3190 SV_CYMINMAXBUTTON), hwndFrame,
3191 HWND_TOP, IDM_OPENWINDOW, NULL, NULL)) {
3192 Win_Error(hwndFrame, hwndParent, pszSrcFile, __LINE__,
3193 PCSZ_WINCREATEWINDOW);
3194 }
3195 }
3196 else {
3197 if (!WinCreateWindow(hwndFrame,
3198 WC_TREESTATUS,
3199 GetPString(IDS_YOUAREHERETEXT),
3200 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER,
3201 swp.x + 4 + WinQuerySysValue(HWND_DESKTOP,
3202 SV_CXSIZEBORDER),
3203 swp.cy - (22 + WinQuerySysValue(HWND_DESKTOP,
3204 SV_CYSIZEBORDER)),
3205 (swp.cx - 8) - (WinQuerySysValue(HWND_DESKTOP,
3206 SV_CXSIZEBORDER)
3207 * 2), 22, hwndFrame, HWND_TOP,
3208 MAIN_STATUS, NULL, NULL)) {
3209 Win_Error(hwndFrame, hwndParent, pszSrcFile, __LINE__,
3210 PCSZ_WINCREATEWINDOW);
3211 }
3212 }
3213 memset(dcd, 0, sizeof(DIRCNRDATA));
3214 dcd->size = sizeof(DIRCNRDATA);
3215 dcd->type = TREE_FRAME;
3216 dcd->dontclose = ((flags & 1) != 0);
3217 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3218 dcd->hwndClient = hwndClient;
3219 dcd->hwndFrame = hwndFrame;
3220 {
3221 PFNWP oldproc;
3222
3223 oldproc = WinSubclassWindow(hwndFrame, TreeFrameWndProc);
3224 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3225 oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3226 (PFNWP) TreeTitleWndProc);
3227 WinSetWindowPtr(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3228 QWL_USER, (PVOID) oldproc);
3229 }
3230 dcd->hwndCnr = WinCreateWindow(hwndClient,
3231 WC_CONTAINER,
3232 NULL,
3233 CCS_AUTOPOSITION | CCS_MINIICONS |
3234 CCS_MINIRECORDCORE, //| WS_VISIBLE,
3235 0,
3236 0,
3237 0,
3238 0,
3239 hwndClient,
3240 HWND_TOP, (ULONG) TREE_CNR, NULL, NULL);
3241 if (!dcd->hwndCnr) {
3242 Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
3243 PCSZ_WINCREATEWINDOW);
3244 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3245 free(dcd);
3246 dcd = 0;
3247 hwndFrame = (HWND) 0;
3248 }
3249 else {
3250 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3251 if (ParentIsDesktop(hwndFrame, hwndParent)) {
3252 WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "VTree");
3253 FixSwitchList(hwndFrame, "VTree");
3254 }
3255 else {
3256 WinSetWindowText(hwndFrame, GetPString(IDS_TREETEXT));
3257 WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3258 GetPString(IDS_TREETEXT));
3259 }
3260 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr, TreeCnrWndProc);
3261 // fixme to document 01 test?
3262 if (dcd->oldproc == 0)
3263 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
3264 "WinSubclassWindow");
3265 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3266 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3267 }
3268 }
3269# ifdef FORTIFY
3270 if (dcd)
3271 Fortify_ChangeScope(dcd, -1);
3272 Fortify_LeaveScope();
3273 if (dcd)
3274 Fortify_ChangeScope(dcd, +1);
3275# endif
3276 }
3277 return hwndFrame;
3278}
3279
3280#pragma alloc_text(TREECNR,TreeCnrWndProc,TreeObjWndProc,TreeClientWndProc)
3281#pragma alloc_text(TREECNR,TreeFrameWndProc,TreeTitleWndProc,ShowTreeRec)
3282#pragma alloc_text(TREECNR,TreeStatProc,OpenButtonProc)
3283#pragma alloc_text(STARTUP,StartTreeCnr)
Note: See TracBrowser for help on using the repository browser.