source: trunk/dll/treecnr.c@ 1498

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

Changes to get FM2 to compile with the latest watcom 1.9 beta (mostly type casts of CHAR CONSTANT * to CHAR *). Changes to get the environment settings working everywhere again (broken by the change that moved commands to the INI); Added an environment size variable (set to 2048 which was the largest I found hard coded). Still need to find everywhere the environment size is set and use this variable.

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