source: trunk/dll/treecnr.c@ 1424

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

Show either file system type or drive label beside dirve letter in tree. (tickets 47 & 339)

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