source: trunk/dll/treecnr.c@ 1551

Last change on this file since 1551 was 1551, checked in by Gregg Young, 15 years ago

This code adds the semaphores to prevent a rescan from starting before the current one is finished; it fixes the double directory listing in the tree container and streamlines scanning. It update mapsym.pl to the latest version. Some code cleanup is included

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