source: trunk/dll/treecnr.c@ 1447

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

Add an reposition semaphore releases for Tree scan code to avoid hangs; Bypass DosGetMessage for HIMEM builds.

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