source: trunk/dll/treecnr.c@ 1675

Last change on this file since 1675 was 1675, checked in by Gregg Young, 13 years ago

Enhance traget directory drop to give the option of changing the directory or carrying out an operation to the current target; Added an error message for target=None; Added parameter to SetTargetDir. Ticket 373

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