source: trunk/dll/treecnr.c@ 1471

Last change on this file since 1471 was 1471, checked in by Steven Levine, 16 years ago

Remember last filter mask selection
Use Ctrl-click to select state or commonly used directory quicklist entry without activating.
Use Ctrl-click to select walk dialog user list entry without activating.
Avoid drivebar MB2 exception
Remember last seek and scan mask selection across runs
Avoid traps when changing tree container display style
Restore missing drives to drive list dropdown
Minor documentation updates

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