source: trunk/dll/treecnr.c@ 1394

Last change on this file since 1394 was 1394, checked in by Steven Levine, 17 years ago

Ticket 340: Convert GetPString to use STRINGTABLE.

Drop fm3dll.str and mkstr.exe from makefiles and wpi builders

Convert many functions to expect PCSZ arguments.
Correct walk, compare and dirsizes dialog setups to ignore saved dialog size
Drop copyright.c logic from makefile

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