source: trunk/dll/treecnr.c@ 1456

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

Avoid crash on Ctrl-g from collector window

  • 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 1456 2009-09-15 07:13:40Z 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 if (dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
841 WinSetWindowText(hwndStatus, s);
842 }
843 return 0;
844
845 case UM_RESCAN:
846 /*
847 * populate container
848 */
849 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
850 if (!dcd)
851 Runtime_Error(pszSrcFile, __LINE__, NULL);
852 else {
853 RemoveCnrItems(dcd->hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
854 WinSendMsg(dcd->hwndCnr,
855 CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-1));
856 WinSendMsg(dcd->hwndCnr,
857 CM_SCROLLWINDOW,
858 MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(-1));
859 DosRequestMutexSem(hmtFillingTreeCnr, SEM_INDEFINITE_WAIT);
860 FillTreeCnr(dcd->hwndCnr, dcd->hwndParent);
861 if (fOkayMinimize) {
862 PostMsg(dcd->hwndCnr, UM_MINIMIZE, MPVOID, MPVOID);
863 fOkayMinimize = FALSE;
864 }
865 WinSendMsg(dcd->hwndCnr,
866 CM_INVALIDATERECORD,
867 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
868 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
869 }
870 return 0;
871
872 case UM_COMMAND:
873 if (mp1) {
874
875 LISTINFO *li = (LISTINFO *) mp1;
876
877 switch (li->type) {
878 case IDM_DOITYOURSELF:
879 case IDM_APPENDTOCLIP:
880 case IDM_SAVETOCLIP:
881 case IDM_ARCHIVE:
882 case IDM_VIEW:
883 case IDM_EDIT:
884 case IDM_OBJECT:
885 case IDM_SHADOW:
886 case IDM_SHADOW2:
887 case IDM_PRINT:
888 case IDM_ATTRS:
889 case IDM_DELETE:
890 case IDM_PERMDELETE:
891 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
892 return (MRESULT) TRUE;
893 default:
894 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
895 return (MRESULT) TRUE;
896 }
897 }
898 return 0;
899
900 case UM_MASSACTION:
901 if (mp1) {
902
903 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
904 if (!dcd)
905 Runtime_Error(pszSrcFile, __LINE__, NULL);
906 else {
907 WORKER *wk;
908# ifdef FORTIFY
909 Fortify_EnterScope();
910# endif
911 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
912 if (!wk)
913 FreeListInfo((LISTINFO *) mp1);
914 else {
915 wk->size = sizeof(WORKER);
916 wk->hwndCnr = dcd->hwndCnr;
917 wk->hwndParent = dcd->hwndParent;
918 wk->hwndFrame = dcd->hwndFrame;
919 wk->hwndClient = dcd->hwndClient;
920 wk->li = (LISTINFO *) mp1;
921 strcpy(wk->directory, dcd->directory);
922 if (xbeginthread(MassAction,
923 122880,
924 wk,
925 pszSrcFile,
926 __LINE__) == -1)
927 {
928 free(wk);
929 FreeListInfo((LISTINFO *) mp1);
930 }
931 }
932# ifdef FORTIFY
933 Fortify_LeaveScope();
934# endif
935 }
936 }
937 return 0;
938
939 case UM_ACTION:
940# ifdef FORTIFY
941 Fortify_EnterScope();
942# endif
943 if (mp1) {
944# ifdef FORTIFY
945 Fortify_BecomeOwner(mp1);
946# endif
947 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
948 if (!dcd)
949 Runtime_Error(pszSrcFile, __LINE__, NULL);
950 else {
951 WORKER *wk;
952 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
953 if (!wk)
954 FreeListInfo((LISTINFO *) mp1);
955 else {
956 wk->size = sizeof(WORKER);
957 wk->hwndCnr = dcd->hwndCnr;
958 wk->hwndParent = dcd->hwndParent;
959 wk->hwndFrame = dcd->hwndFrame;
960 wk->hwndClient = dcd->hwndClient;
961 wk->li = (LISTINFO *) mp1;
962 strcpy(wk->directory, dcd->directory);
963 if (xbeginthread(Action,
964 122880,
965 wk,
966 pszSrcFile,
967 __LINE__) == -1)
968 {
969 free(wk);
970 FreeListInfo((LISTINFO *) mp1);
971 }
972 }
973 }
974 }
975# ifdef FORTIFY
976 Fortify_LeaveScope();
977# endif
978 return 0;
979
980 case WM_CLOSE:
981 WinDestroyWindow(hwnd);
982 break;
983
984 case WM_DESTROY:
985 hwndTree = (HWND) 0;
986 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
987 if (dcd) {
988 WinSendMsg(dcd->hwndCnr,
989 UM_CLOSE, MPFROMLONG(dcd->dontclose != FALSE), MPVOID);
990 free(dcd);
991# ifdef FORTIFY
992 Fortify_LeaveScope();
993# endif
994 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
995 }
996 DosPostEventSem(CompactSem);
997 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
998 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
999 break;
1000 }
1001 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1002}
1003
1004MRESULT EXPENTRY TreeCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1005{
1006 static APPNOTIFY *apphead = NULL, *apptail = NULL;
1007 DIRCNRDATA *dcd = INSTDATA(hwnd);
1008 PCNRITEM pci;
1009
1010 switch (msg) {
1011 case DM_PRINTOBJECT:
1012 return MRFROMLONG(DRR_TARGET);
1013
1014 case DM_DISCARDOBJECT:
1015 if (dcd)
1016 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1017 else
1018 return MRFROMLONG(DRR_TARGET);
1019
1020 case WM_CHAR:
1021 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1022 if (SHORT1FROMMP(mp1) & KC_KEYUP)
1023 return (MRESULT) TRUE;
1024 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1025 switch (SHORT2FROMMP(mp2)) {
1026 case VK_INSERT:
1027 if ((shiftstate & KC_CTRL) == KC_CTRL)
1028 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
1029 break;
1030 case VK_DELETE:
1031 if ((shiftstate & KC_CTRL) == KC_CTRL)
1032 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
1033 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
1034 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
1035 else
1036 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
1037 break;
1038 } // switch
1039 }
1040
1041 if (SearchContainer(hwnd, msg, mp1, mp2))
1042 return (MRESULT)TRUE; // Avoid default handler
1043
1044 break; // Let default handler see key
1045
1046 case WM_MOUSEMOVE:
1047 case WM_BUTTON1UP:
1048 case WM_BUTTON2UP:
1049 case WM_BUTTON3UP:
1050 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1051 break;
1052
1053 case UM_TIMER:
1054 if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent) &&
1055 hwndStatus2) {
1056 FILEFINDBUF3L ffb;
1057 ULONG nm = 1;
1058 HDIR hdir = HDIR_CREATE;
1059
1060 if (*SwapperDat) {
1061 if (!xDosFindFirst(SwapperDat,
1062 &hdir,
1063 FILE_NORMAL | FILE_HIDDEN |
1064 FILE_SYSTEM | FILE_ARCHIVED | FILE_READONLY,
1065 &ffb, sizeof(ffb), &nm, FIL_STANDARDL)) {
1066 CHAR tb[39], tm[39], tpm[39], s[163];
1067 ULONG amem;
1068
1069 priority_bumped();
1070 DosFindClose(hdir);
1071 if (!DosQuerySysInfo(QSV_TOTAVAILMEM,
1072 QSV_TOTAVAILMEM,
1073 (PVOID) & amem, sizeof(amem))) {
1074 CommaFmtULL(tpm, sizeof(tpm), amem, 'M');
1075 }
1076 else
1077 *tpm = 0;
1078 if (!Dos16MemAvail(&amem))
1079 CommaFmtULL(tm, sizeof(tm), amem, 'M');
1080 else
1081 *tm = 0;
1082 CommaFmtULL(tb, sizeof(tb), ffb.cbFile, 'M');
1083 sprintf(s, " %s %s%s%s%s%s",
1084 GetPString(IDS_SWAPFILETEXT),
1085 tb,
1086 *tm ? GetPString(IDS_TREEMEMTEXT) : NullStr,
1087 tm, *tpm ? "/" : NullStr, tpm);
1088 WinSetWindowText(hwndStatus2, s);
1089 }
1090 else
1091 WinSetWindowText(hwndStatus2, NullStr);
1092 }
1093 else
1094 WinSetWindowText(hwndStatus2, NullStr);
1095 }
1096 // 13 Jul 09 SHL fixme to make sense
1097 if (msg == UM_TIMER)
1098 return 0;
1099 break;
1100
1101 case WM_PRESPARAMCHANGED:
1102 PresParamChanged(hwnd, PCSZ_TREECNR, mp1, mp2);
1103 break;
1104
1105 case UM_FILESMENU:
1106 {
1107 HWND menuHwnd = (HWND) 0;
1108 FSALLOCATE fsa;
1109
1110 pci = (PCNRITEM) CurrentRecord(hwnd);
1111 if (pci && (INT) pci != -1) {
1112 if (IsRoot(pci->pszFileName) || !DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
1113 FSIL_ALLOC, &fsa,
1114 sizeof(FSALLOCATE)))
1115 menuHwnd = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
1116 else {
1117 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
1118// WinEnableMenuItem(DirMenu,
1119// IDM_TREE,
1120// FALSE);
1121 }
1122 if (!(pci->attrFile & FILE_DIRECTORY))
1123 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
1124 }
1125 return MRFROMLONG(menuHwnd);
1126 }
1127
1128 case UM_COMPARE:
1129 if (dcd && mp1 && mp2) {
1130
1131 COMPARE *cmp;
1132 CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
1133
1134 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1135 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1136 if (cmp) {
1137 cmp->size = sizeof(COMPARE);
1138 strcpy(cmp->leftdir, leftdir);
1139 strcpy(cmp->rightdir, rightdir);
1140 cmp->hwndParent = dcd->hwndParent;
1141 cmp->dcd.hwndParent = dcd->hwndParent;
1142 WinDlgBox(HWND_DESKTOP,
1143 HWND_DESKTOP,
1144 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1145 }
1146 }
1147 }
1148 return 0;
1149
1150 case UM_UPDATERECORDLIST:
1151 if (dcd && mp1)
1152 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1153 return 0;
1154
1155 case UM_UPDATERECORD:
1156 if (dcd && mp1) {
1157 CHAR *filename;
1158 filename = mp1;
1159 if (filename) {
1160 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1161 }
1162 }
1163 return 0;
1164
1165 case WM_SETFOCUS:
1166 if (dcd && hwndStatus && mp2) {
1167 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1168 if (hwndMain)
1169 PostMsg(hwndMain, UM_ADVISEFOCUS, MPFROMLONG(dcd->hwndFrame), MPVOID);
1170 }
1171 break;
1172
1173 case UM_RESCAN:
1174 if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1175 /*
1176 * put name of our window on status line
1177 */
1178
1179 PCNRITEM pci = NULL;
1180 CHAR str[CCHMAXPATH + 6];
1181
1182 if (fAutoView && hwndMain) {
1183 pci = WinSendMsg(hwnd,
1184 CM_QUERYRECORDEMPHASIS,
1185 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1186 if (pci && (INT) pci != -1 && fComments &&
1187 !(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW))
1188 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1189 else
1190 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1191 }
1192 if (!fAutoView || !hwndMain)
1193 pci = (PCNRITEM) WinSendMsg(hwnd,
1194 CM_QUERYRECORDEMPHASIS,
1195 MPFROMLONG(CMA_FIRST),
1196 MPFROMSHORT(CRA_CURSORED));
1197 if ((INT) pci == -1)
1198 pci = NULL;
1199 if (pci) {
1200 if (*(ULONG *) realappname == FM3UL) {
1201 sprintf(str, "%s %s", GetPString(IDS_DTTEXT), pci->pszFileName);
1202 WinSetWindowText(dcd->hwndFrame, str);
1203 WinSetWindowText(WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR),
1204 str);
1205 }
1206 else
1207 WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
1208 MAIN_STATUS), pci->pszFileName);
1209 if (fMoreButtons && hwndName) {
1210 CHAR szDate[DATE_BUF_BYTES];
1211
1212 DateFormat(szDate, pci->date);
1213 WinSetWindowText(hwndName, pci->pszFileName);
1214 sprintf(str, "%s %02u%s%02u%s%02u", szDate,
1215 pci->time.hours, TimeSeparator,
1216 pci->time.minutes, TimeSeparator, pci->time.seconds);
1217 WinSetWindowText(hwndDate, str);
1218 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1219 }
1220 }
1221 PostMsg(dcd->hwndObject, UM_RESCAN2, MPFROMP(pci), MPVOID);
1222 if (hwndStatus2)
1223 PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID);
1224 }
1225 return 0;
1226
1227 case UM_SETUP2:
1228 {
1229 PCNRITEM pci = (PCNRITEM) mp1;
1230
1231 if (pci)
1232 NotifyError(pci->pszFileName, (ULONG) mp2);
1233 }
1234 return 0;
1235
1236 case UM_SETUP:
1237# ifdef FORTIFY
1238 // Balance WM_DESTROY
1239 Fortify_EnterScope();
1240# endif
1241
1242 if (!dcd) {
1243 Runtime_Error(pszSrcFile, __LINE__, NULL);
1244 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1245 return 0;
1246 }
1247 else {
1248 if (!dcd->hwndObject) {
1249 /*
1250 * first time through -- set things up
1251 */
1252 CNRINFO cnri;
1253
1254# ifdef FORTIFY
1255 Fortify_EnterScope();
1256# endif
1257
1258 RestorePresParams(hwnd, PCSZ_TREECNR);
1259 memset(&cnri, 0, sizeof(CNRINFO));
1260 cnri.cb = sizeof(CNRINFO);
1261 WinSendMsg(hwnd,
1262 CM_QUERYCNRINFO,
1263 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1264 cnri.cyLineSpacing = 0;
1265 cnri.cxTreeIndent = 12;
1266 cnri.pSortRecord = (PVOID) SortTreeCnr;
1267 cnri.flWindowAttr &= (~(CV_NAME | CV_DETAIL | CV_TEXT));
1268 cnri.flWindowAttr |= (CV_TREE | CA_TREELINE | CV_ICON | CV_MINI);
1269 {
1270 ULONG size = sizeof(ULONG);
1271
1272 PrfQueryProfileData(fmprof,
1273 appname,
1274 "TreeflWindowAttr",
1275 (PVOID) & cnri.flWindowAttr, &size);
1276 size = sizeof(MASK);
1277 *dcd->mask.prompt = 0;
1278 if (!*dcd->mask.szMask && !dcd->mask.attrFile) {
1279 if (PrfQueryProfileSize(fmprof,
1280 appname, "TreeFilter", &size) && size) {
1281 PrfQueryProfileData(fmprof,
1282 appname, "TreeFilter", &dcd->mask, &size);
1283 SetMask(NULL, &dcd->mask);
1284 }
1285 else
1286 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1287 FILE_ARCHIVED | FILE_DIRECTORY |
1288 FILE_HIDDEN | FILE_SYSTEM);
1289 }
1290 dcd->mask.attrFile |= FILE_DIRECTORY;
1291 }
1292 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
1293 cnri.flWindowAttr |= CV_FLOW;
1294 dcd->flWindowAttr = cnri.flWindowAttr;
1295 WinSendMsg(hwnd,
1296 CM_SETCNRINFO,
1297 MPFROMP(&cnri),
1298 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1299 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1300 if (xbeginthread(MakeObjWin,
1301 327680,
1302 dcd,
1303 pszSrcFile,
1304 __LINE__) == -1)
1305 {
1306 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1307 }
1308 else
1309 DosSleep(1);
1310# ifdef FORTIFY
1311 Fortify_LeaveScope();
1312# endif
1313 }
1314 }
1315 return 0;
1316
1317 case WM_BUTTON3CLICK:
1318 case WM_CHORD:
1319 {
1320 PCNRITEM pci = NULL;
1321 QUERYRECFROMRECT pqr;
1322 NOTIFYRECORDENTER nr;
1323 BOOL tbool = fDCOpens;
1324 RECTL rectl;
1325 POINTL ptl;
1326
1327 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1328 if (msg == WM_CHORD) {
1329 if (!WinQueryPointerPos(HWND_DESKTOP, &ptl))
1330 break;
1331 WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
1332 }
1333 else {
1334 ptl.x = SHORT1FROMMP(mp1);
1335 ptl.y = SHORT2FROMMP(mp1);
1336 }
1337 memset(&rectl, 0, sizeof(rectl));
1338 memset(&pqr, 0, sizeof(pqr));
1339 pqr.cb = sizeof(pqr);
1340 pqr.rect.xLeft = ptl.x - 1;
1341 pqr.rect.xRight = ptl.x + 1;
1342 pqr.rect.yTop = ptl.y + 1;
1343 pqr.rect.yBottom = ptl.y - 1;
1344 pqr.fsSearch = CMA_PARTIAL;
1345 pci = (PCNRITEM) WinSendMsg(hwnd,
1346 CM_QUERYRECORDFROMRECT,
1347 MPFROMLONG(CMA_FIRST), MPFROMP(&pqr));
1348 if (!pci || (INT) pci == -1)
1349 break; //Probable B3 click on white space
1350 else {
1351 memset(&nr, 0, sizeof(nr));
1352 nr.hwndCnr = hwnd;
1353 nr.pRecord = (PRECORDCORE) pci;
1354 fDCOpens = TRUE;
1355 WinSendMsg(hwnd,
1356 WM_CONTROL,
1357 MPFROM2SHORT(WinQueryWindowUShort(hwnd,
1358 QWS_ID),
1359 CN_ENTER), MPFROMP(&nr));
1360 PostMsg(hwnd, UM_RESTOREDC, MPFROMLONG(tbool), MPVOID);
1361 }
1362 }
1363 break;
1364
1365 case UM_RESTOREDC:
1366 fDCOpens = (BOOL) mp1;
1367 return 0;
1368
1369 case WM_CONTROL:
1370 DosError(FERR_DISABLEHARDERR);
1371 if (dcd) {
1372 switch (SHORT2FROMMP(mp1)) {
1373 case CN_BEGINEDIT:
1374 case CN_REALLOCPSZ:
1375 case CN_ENDEDIT:
1376 {
1377 MRESULT mre;
1378
1379 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
1380 if (mre != (MRESULT) - 1)
1381 return mre;
1382 }
1383 break;
1384
1385 case CN_DRAGLEAVE:
1386 if (mp2) {
1387
1388 PDRAGINFO pDInfo;
1389
1390 // fixme to know why - seems superfluous
1391 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
1392 DrgAccessDraginfo(pDInfo);
1393 DrgFreeDraginfo(pDInfo);
1394 }
1395 return 0;
1396
1397 case CN_DROPHELP:
1398 if (mp2) {
1399
1400 PDRAGINFO pDInfo;
1401 PCNRITEM pci;
1402 ULONG numitems;
1403 USHORT usOperation;
1404
1405 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
1406 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
1407 if (!DrgAccessDraginfo(pDInfo)) {
1408 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
1409 GetPString(IDS_DROPERRORTEXT));
1410 }
1411 else {
1412 numitems = DrgQueryDragitemCount(pDInfo);
1413 usOperation = pDInfo->usOperation;
1414 if (usOperation == DO_DEFAULT)
1415 usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
1416 FreeDragInfoData(hwnd, pDInfo);
1417 saymsg(MB_ENTER | MB_ICONASTERISK,
1418 hwnd,
1419 GetPString(IDS_DROPHELPHDRTEXT),
1420 GetPString(IDS_DROPHELPTEXT),
1421 numitems,
1422 &"s"[numitems == 1L],
1423 pci ? NullStr : GetPString(IDS_NOTEXT),
1424 pci ? NullStr : " ",
1425 pci ? pci->pszFileName : NullStr,
1426 pci ? " " : NullStr,
1427 GetPString((usOperation == DO_MOVE) ?
1428 IDS_MOVETEXT :
1429 (usOperation == DO_LINK) ?
1430 IDS_LINKTEXT : IDS_COPYTEXT));
1431 }
1432 }
1433 return 0;
1434
1435 case CN_DRAGAFTER:
1436 case CN_DRAGOVER:
1437 if (mp2) {
1438
1439 PDRAGITEM pDItem;
1440 PDRAGINFO pDInfo;
1441 PCNRITEM pci;
1442 USHORT uso;
1443
1444 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
1445 if (!DrgAccessDraginfo(pDInfo)) {
1446 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
1447 PCSZ_DRGACCESSDRAGINFO);
1448 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
1449 }
1450 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
1451 if ((INT) pci == -1)
1452 pci = NULL;
1453 if (pci && (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODROP))) {
1454 DrgFreeDraginfo(pDInfo);
1455 return MRFROM2SHORT(DOR_NODROP, 0);
1456 }
1457 if (!WinIsWindowEnabled(dcd->hwndFrame)) {
1458 DrgFreeDraginfo(pDInfo);
1459 return MRFROM2SHORT(DOR_NODROP, 0);
1460 }
1461 if (pci) {
1462 uso = pDInfo->usOperation;
1463 if (uso == DO_DEFAULT)
1464 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
1465 if (!(pci->attrFile & FILE_DIRECTORY)) {
1466 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
1467 DrgFreeDraginfo(pDInfo);
1468 return (MRFROM2SHORT(DOR_NODROP, 0));
1469 }
1470 if (uso != DO_LINK &&
1471 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
1472 DRIVE_NOTWRITEABLE)) {
1473
1474 ARC_TYPE *info;
1475
1476 if (!fQuickArcFind &&
1477 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
1478 DRIVE_SLOW))
1479 info = find_type(pci->pszFileName, NULL);
1480 else
1481 info = quick_find_type(pci->pszFileName, NULL);
1482 if (!info || ((uso == DO_MOVE && !info->move) ||
1483 (uso == DO_COPY && !info->create))) {
1484 DrgFreeDraginfo(pDInfo);
1485 return (MRFROM2SHORT(DOR_NODROP, 0));
1486 }
1487 }
1488 }
1489 }
1490 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
1491 0); /* Index to DRAGITEM */
1492 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
1493 DRM_OS2FILE, /* mechanisms and data */
1494 NULL) || DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE)) { /* formats */
1495 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
1496 if (!pci || (INT) pci == -1)
1497 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
1498 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
1499 DRIVE_NOTWRITEABLE)
1500 return MRFROM2SHORT(DOR_DROP, DO_LINK);
1501 if (toupper(*pci->pszFileName) < 'C')
1502 return MRFROM2SHORT(DOR_DROP, DO_COPY);
1503 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
1504 ((fCopyDefault) ? DO_COPY : DO_MOVE));
1505 }
1506 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
1507 }
1508 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
1509
1510 case CN_INITDRAG:
1511 {
1512 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
1513 PCNRITEM pci;
1514
1515 if (!pcd) {
1516 Runtime_Error(pszSrcFile, __LINE__, NULL);
1517 break;
1518 }
1519 else {
1520 pci = (PCNRITEM) pcd->pRecord;
1521 if (!pci || (INT) pci == -1) {
1522 Runtime_Error(pszSrcFile, __LINE__, NULL);
1523 break;
1524 }
1525 if (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODRAG)) {
1526 Runtime_Error(pszSrcFile, __LINE__, "drag not allowed");
1527 break;
1528 }
1529 if (hwndStatus2) {
1530 WinSetWindowText(hwndStatus2, (IsRoot(pci->pszFileName)) ?
1531 GetPString(IDS_DRAGROOTTEXT) :
1532 (pci->attrFile & FILE_DIRECTORY) ?
1533 GetPString(IDS_DRAGDIRTEXT) :
1534 GetPString(IDS_DRAGFILETEXT));
1535 }
1536 DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE);
1537 if (hwndStatus2) {
1538 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1539 }
1540 }
1541 }
1542 return 0;
1543
1544 case CN_DROP:
1545 {
1546 LISTINFO *li;
1547 ULONG action = UM_ACTION;
1548
1549 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
1550 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
1551 if (li) {
1552 if (!*li->targetpath) {
1553 if (li->list[0])
1554 PMMkDir(dcd->hwndParent, li->list[0], FALSE);
1555 FreeListInfo(li);
1556 return 0;
1557 }
1558 if (li->list && li->list[0] && IsRoot(li->list[0]))
1559 li->type = DO_LINK;
1560 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
1561
1562 CHECKLIST cl;
1563
1564 memset(&cl, 0, sizeof(cl));
1565 cl.size = sizeof(cl);
1566 cl.flags = li->type;
1567 cl.list = li->list;
1568 cl.cmd = li->type;
1569 cl.prompt = li->targetpath;
1570 li->type = WinDlgBox(HWND_DESKTOP,
1571 dcd->hwndParent,
1572 DropListProc,
1573 FM3ModHandle, DND_FRAME, MPFROMP(&cl));
1574 if (li->type == DID_ERROR)
1575 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,
1576 GetPString(IDS_DRAGDROPDIALOGTEXT));
1577 if (!li->type) {
1578 FreeListInfo(li);
1579 return 0;
1580 }
1581 li->list = cl.list;
1582 if (!li->list || !li->list[0]) {
1583 FreeListInfo(li);
1584 return 0;
1585 }
1586 }
1587 switch (li->type) {
1588 case DO_LINK:
1589 if (fLinkSetsIcon) {
1590 li->type = IDM_SETICON;
1591 action = UM_MASSACTION;
1592 }
1593 else
1594 li->type = IDM_COMPARE;
1595 break;
1596 case DND_EXTRACT:
1597 if (*li->targetpath && !IsFile(li->targetpath))
1598 li->type = IDM_EXTRACT;
1599 break;
1600 case DND_MOVE:
1601 li->type = IDM_MOVE;
1602 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1603 action = UM_MASSACTION;
1604 li->type = IDM_ARCHIVEM;
1605 }
1606 break;
1607 case DND_WILDMOVE:
1608 li->type = IDM_WILDMOVE;
1609 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1610 action = UM_MASSACTION;
1611 li->type = IDM_ARCHIVEM;
1612 }
1613 break;
1614 case DND_OBJECT:
1615 li->type = IDM_OBJECT;
1616 action = UM_MASSACTION;
1617 break;
1618 case DND_SHADOW:
1619 li->type = IDM_SHADOW;
1620 action = UM_MASSACTION;
1621 break;
1622 case DND_COMPARE:
1623 li->type = IDM_COMPARE;
1624 break;
1625 case DND_SETICON:
1626 action = UM_MASSACTION;
1627 li->type = IDM_SETICON;
1628 break;
1629 case DND_COPY:
1630 li->type = IDM_COPY;
1631 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1632 action = UM_MASSACTION;
1633 li->type = IDM_ARCHIVE;
1634 }
1635 break;
1636 case DND_WILDCOPY:
1637 li->type = IDM_WILDCOPY;
1638 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1639 action = UM_MASSACTION;
1640 li->type = IDM_ARCHIVE;
1641 }
1642 break;
1643 default:
1644 if (*li->arcname && li->info) {
1645 action = UM_MASSACTION;
1646 li->type = (li->type == DO_MOVE) ?
1647 IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
1648 }
1649 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
1650 action = UM_MASSACTION;
1651 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
1652 }
1653 else
1654 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
1655 break;
1656 }
1657 if (!li->list || !li->list[0])
1658 FreeListInfo(li);
1659 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
1660 FreeListInfo(li);
1661 else {
1662
1663 USHORT usop = 0;
1664
1665 switch (li->type) {
1666 case IDM_COPY:
1667 case IDM_WILDCOPY:
1668 usop = DO_COPY;
1669 break;
1670 case IDM_MOVE:
1671 case IDM_WILDMOVE:
1672 case IDM_ARCHIVEM:
1673 usop = DO_MOVE;
1674 break;
1675 }
1676 if (usop)
1677 return MRFROM2SHORT(DOR_DROP, usop);
1678 }
1679 }
1680 }
1681 return 0;
1682
1683 case CN_EMPHASIS:
1684 if (!fDummy) {
1685
1686 PNOTIFYRECORDEMPHASIS pre = mp2;
1687
1688 if (pre->fEmphasisMask & CRA_SELECTED) {
1689 if (pre->pRecord->flRecordAttr & CRA_SELECTED) {
1690 if (((PCNRITEM) (pre->pRecord))->attrFile & FILE_DIRECTORY) {
1691 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1692 if (fFollowTree &&
1693 !(driveflags
1694 [toupper(*((PCNRITEM) pre->pRecord)->pszFileName) -
1695 'A'] & DRIVE_INVALID)) {
1696 if (!LastDir && !ParentIsDesktop(hwnd, dcd->hwndParent))
1697 LastDir = FindDirCnr(dcd->hwndParent);
1698 if (LastDir) {
1699
1700 NOTIFYRECORDENTER pri;
1701 BOOL tbool = fDCOpens;
1702
1703 fDCOpens = FALSE;
1704 memset(&pri, 0, sizeof(pri));
1705 pri.hwndCnr = hwnd;
1706 pri.fKey = FALSE;
1707 pri.pRecord = pre->pRecord;
1708 WinSendMsg(hwnd,
1709 WM_CONTROL,
1710 MPFROM2SHORT(SHORT1FROMMP(mp1),
1711 CN_ENTER), MPFROMP(&pri));
1712 fDCOpens = tbool;
1713 }
1714 }
1715 if (*(ULONG *) realappname != FM3UL)
1716 WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
1717 MAIN_STATUS),
1718 ((PCNRITEM) (pre->pRecord))->pszFileName);
1719 }
1720 }
1721 }
1722 }
1723 break;
1724
1725 case CN_CONTEXTMENU:
1726 {
1727 PCNRITEM pci = (PCNRITEM) mp2;
1728 BOOL wasFollowing;
1729
1730 //DosEnterCritSec(); //GKY 11-28-08
1731 wasFollowing = fFollowTree;
1732 fFollowTree = FALSE;
1733 //DosExitCritSec();
1734 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
1735 WinSendMsg(hwnd,
1736 CM_SETRECORDEMPHASIS,
1737 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
1738 MarkAll(hwnd, FALSE, FALSE, TRUE);
1739 if (!(pci->attrFile & FILE_DIRECTORY))
1740 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
1741 else if (!IsRoot(pci->pszFileName))
1742 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
1743 else
1744 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
1745 }
1746 else {
1747 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP);
1748 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
1749 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1750 MPFROM2SHORT(TRUE, CRA_SOURCE));
1751 dcd->cnremphasized = TRUE;
1752 }
1753 }
1754 if (dcd->hwndLastMenu) {
1755 if (dcd->hwndLastMenu == DirMenu)
1756 WinEnableMenuItem(DirMenu, IDM_TREE, FALSE);
1757 if (dcd->hwndLastMenu == TreeCnrMenu) {
1758 if (dcd->flWindowAttr & CV_MINI)
1759 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
1760 }
1761 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
1762 if (dcd->cnremphasized) {
1763 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1764 MPFROM2SHORT(FALSE, CRA_SOURCE));
1765 dcd->cnremphasized = FALSE;
1766 }
1767 if (dcd->hwndLastMenu != TreeCnrMenu)
1768 MarkAll(hwnd, TRUE, FALSE, TRUE);
1769 }
1770 }
1771 //DosEnterCritSec(); //GKY 11-28-08
1772 fFollowTree = wasFollowing;
1773 //DosExitCritSec();
1774 }
1775 break;
1776
1777 case CN_ENTER:
1778 if (mp2) {
1779 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
1780
1781 PostMsg(hwnd, UM_ENTER, MPFROMP(pci), MPVOID);
1782 }
1783 break;
1784
1785 case CN_COLLAPSETREE:
1786 case CN_EXPANDTREE:
1787 {
1788 PCNRITEM pci = (PCNRITEM) mp2;
1789
1790 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
1791 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
1792
1793 struct
1794 {
1795 ULONG serial;
1796 CHAR volumelength;
1797 CHAR volumelabel[CCHMAXPATH];
1798 }
1799 volser;
1800
1801 memset(&volser, 0, sizeof(volser));
1802 DosError(FERR_DISABLEHARDERR);
1803 if (!DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
1804 FSIL_VOLSER, &volser,
1805 (ULONG) sizeof(volser))) {
1806 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
1807 !volser.serial ||
1808 driveserial[toupper(*pci->pszFileName) - 'A'] !=
1809 volser.serial)
1810 UnFlesh(hwnd, pci);
1811 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
1812 (!volser.serial ||
1813 driveserial[toupper(*pci->pszFileName) - 'A'] !=
1814 volser.serial)) {
1815 if (Flesh(hwnd, pci) &&
1816 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
1817 !dcd->suspendview && fTopDir) {
1818 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
1819 //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
1820 }
1821 }
1822 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
1823 }
1824 else {
1825 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
1826 UnFlesh(hwnd, pci);
1827 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1828 if (!fAlertBeepOff)
1829 DosBeep(250, 100);
1830 }
1831 }
1832 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
1833 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir){
1834 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
1835 //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
1836 }
1837 }
1838 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview){
1839 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
1840 //DbgMsg(pszSrcFile, __LINE__, "UM_FILTER %p pci %p", hwnd, pci);
1841 }
1842 }
1843 }
1844 break;
1845 } // switch WM_CONTROL
1846 }
1847 return 0;
1848
1849 case UM_ACTION:
1850 if (mp1) {
1851
1852 LISTINFO *li = mp1;
1853 ULONG action = (ULONG) mp2;
1854
1855 if (!li->list || !li->list[0] ||
1856 !PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
1857 FreeListInfo(li);
1858 }
1859 return 0;
1860
1861 case UM_SHOWME:
1862 if (mp1 && dcd) {
1863 CHAR *dir = xstrdup((CHAR *)mp1, pszSrcFile, __LINE__);
1864
1865 if (dir) {
1866 if (!PostMsg(dcd->hwndObject, UM_SHOWME, MPFROMP(dir), MPVOID))
1867 free(dir);
1868 }
1869 }
1870 return 0;
1871
1872 case UM_TOPDIR:
1873 if (mp1) {
1874
1875 PCNRITEM pci = (PCNRITEM) mp1;
1876
1877 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1878 }
1879 return 0;
1880
1881 case UM_ENTER:
1882 {
1883 FILEFINDBUF3 ffb;
1884 HDIR hDir = HDIR_CREATE;
1885 ULONG nm = 1;
1886 APIRET status;
1887 BOOL IsOk = FALSE;
1888 ULONG ulDriveNum, ulDriveMap;
1889 PCNRITEM pciP, pciL, pci;
1890 ULONG fl = SWP_ACTIVATE;
1891 INT x;
1892
1893 DosRequestMutexSem(hmtFillingTreeCnr, SEM_INDEFINITE_WAIT);
1894 if (fFollowTree)
1895 fl = 0;
1896 SetShiftState();
1897 pci = (PCNRITEM) mp1;
1898 if (pci &&
1899 (INT) pci != -1 &&
1900 !(pci->rc.flRecordAttr & CRA_INUSE) &&
1901 !(pci->flags & RECFLAGS_ENV) && IsFullName(pci->pszFileName)) {
1902 x = (INT) (toupper(*pci->pszFileName) - 'A');
1903 if (driveflags[x] & DRIVE_INVALID) {
1904 if (!fAlertBeepOff)
1905 DosBeep(50, 100);
1906 if (hwndStatus)
1907 WinSetWindowText(hwndStatus, GetPString(IDS_RESCANSUGTEXT));
1908 DosReleaseMutexSem(hmtFillingTreeCnr);
1909 return 0;
1910 }
1911 DosError(FERR_DISABLEHARDERR);
1912 if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) {
1913 if (!(ulDriveMap & 1 << x)) {
1914 pciL = pciP = pci;
1915 for (;;) {
1916 pciP = WinSendMsg(hwnd,
1917 CM_QUERYRECORD,
1918 MPFROMP(pciL),
1919 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
1920 if (pciP && (INT) pciP != -1)
1921 pciL = pciP;
1922 else {
1923 pciP = pciL;
1924 break;
1925 }
1926 } // for
1927 RemoveCnrItems(hwnd, pciP, 1, CMA_FREE | CMA_INVALIDATE);
1928 DosReleaseMutexSem(hmtFillingTreeCnr);
1929 return 0;
1930 }
1931 }
1932 if (driveflags[x] & (DRIVE_REMOVABLE | DRIVE_NOPRESCAN)) {
1933
1934 struct
1935 {
1936 ULONG serial;
1937 CHAR volumelength;
1938 CHAR volumelabel[CCHMAXPATH];
1939 }
1940 volser;
1941 CHAR FileSystem[CCHMAXPATH];
1942 CHAR szBuf[CCHMAXPATH];
1943
1944 pciL = pciP = pci;
1945 for (;;) {
1946 pciP = WinSendMsg(hwnd,
1947 CM_QUERYRECORD,
1948 MPFROMP(pciL),
1949 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
1950 if (pciP && (INT) pciP != -1)
1951 pciL = pciP;
1952 else {
1953 pciP = pciL;
1954 break;
1955 }
1956 }
1957 if ((driveflags[x] & DRIVE_NOPRESCAN) || (toupper(*pci->pszFileName) > 'B' &&
1958 !(driveflags[x] & DRIVE_CDROM))) {
1959 DriveFlagsOne(x, FileSystem, &volser);
1960 SelectDriveIcon(pciP);
1961 if (hwndMain)
1962 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
1963 }
1964 memset(&volser, 0, sizeof(volser));
1965 DosError(FERR_DISABLEHARDERR);
1966 status = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
1967 FSIL_VOLSER, &volser,
1968 (ULONG) sizeof(volser));
1969 if (!status) {
1970 if (!volser.serial || driveserial[x] != volser.serial) {
1971 UnFlesh(hwnd, pciP);
1972 Flesh(hwnd, pciP);
1973 driveserial[x] = volser.serial;
1974 }
1975 pciL = WinSendMsg(hwnd,
1976 CM_QUERYRECORD,
1977 MPFROMP(pciP),
1978 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
1979 if (!pciL)
1980 Flesh(hwnd, pciP);
1981 if ((fShowFSTypeInTree || fShowDriveLabelInTree) &&
1982 strlen(pciP->pszFileName) < 4) {
1983 strcpy(szBuf, pciP->pszFileName);
1984 strcat(szBuf, " [");
1985 strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
1986 strcat(szBuf, "]");
1987 pciP->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
1988 pciP->rc.pszIcon = pciP->pszDisplayName;
1989 }
1990 WinSendMsg(hwnd,
1991 CM_INVALIDATERECORD,
1992 MPFROMP(&pciP),
1993 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
1994 }
1995 else {
1996 driveserial[x] = -1;
1997 UnFlesh(hwnd, pci);
1998 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1999 PostMsg(hwnd, UM_SETUP2, MPFROMP(pci), MPFROMLONG(status));
2000 DosReleaseMutexSem(hmtFillingTreeCnr);
2001 return 0;
2002 }
2003 }
2004 status = 0;
2005 IsOk = (IsRoot(pci->pszFileName) &&
2006 IsValidDrive(toupper(*pci->pszFileName)));
2007 if (!IsOk) {
2008 DosError(FERR_DISABLEHARDERR);
2009 status = DosFindFirst(pci->pszFileName, &hDir,
2010 FILE_NORMAL | FILE_DIRECTORY |
2011 FILE_ARCHIVED | FILE_READONLY |
2012 FILE_HIDDEN | FILE_SYSTEM,
2013 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
2014 priority_bumped();
2015 }
2016 if (!status) {
2017 if (!IsOk)
2018 DosFindClose(hDir);
2019 if (IsOk || (ffb.attrFile & FILE_DIRECTORY)) {
2020 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT)) {
2021 PostMsg(hwnd,
2022 WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
2023 DosReleaseMutexSem(hmtFillingTreeCnr);
2024 return 0;
2025 }
2026 if ((shiftstate & (KC_CTRL | KC_SHIFT)) == (KC_CTRL | KC_SHIFT)) {
2027 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
2028 DosReleaseMutexSem(hmtFillingTreeCnr);
2029 return 0;
2030 }
2031 if (!(shiftstate & (KC_CTRL | KC_SHIFT))) {
2032 if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
2033 if (FindDirCnrByName(pci->pszFileName, TRUE)) {
2034 DosReleaseMutexSem(hmtFillingTreeCnr);
2035 return 0;
2036 }
2037 }
2038 }
2039 if ((shiftstate & KC_CTRL) ||
2040 (!(shiftstate & KC_SHIFT) &&
2041 ParentIsDesktop(hwnd, dcd->hwndParent) && fVTreeOpensWPS)) {
2042
2043 ULONG size = sizeof(ULONG), flWindowAttr = CV_ICON;
2044 CHAR s[33];
2045
2046 strcpy(s, PCSZ_ICON);
2047 PrfQueryProfileData(fmprof,
2048 appname,
2049 "DirflWindowAttr",
2050 (PVOID) & flWindowAttr, &size);
2051 if (flWindowAttr & CV_DETAIL) {
2052 if (IsRoot(pci->pszFileName))
2053 strcpy(s, PCSZ_TREE);
2054 else
2055 strcpy(s, Details);
2056 }
2057 OpenObject(pci->pszFileName, s, dcd->hwndFrame);
2058 DosReleaseMutexSem(hmtFillingTreeCnr);
2059 return 0;
2060 }
2061 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2062 !fDCOpens && !LastDir && !(shiftstate & KC_SHIFT))
2063 LastDir = FindDirCnr(dcd->hwndParent);
2064 if (LastDir && !fDCOpens && !(shiftstate & KC_SHIFT)) {
2065 WinSendMsg(LastDir,
2066 UM_SETDIR, MPFROMP(pci->pszFileName), MPVOID);
2067 WinSetWindowPos(WinQueryWindow(WinQueryWindow(LastDir,
2068 QW_PARENT),
2069 QW_PARENT),
2070 HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | fl);
2071 }
2072 else
2073 OpenDirCnr(hwnd,
2074 dcd->hwndParent,
2075 dcd->hwndFrame, FALSE, pci->pszFileName);
2076 }
2077 else {
2078 if (!(driveflags[x] & DRIVE_INCLUDEFILES))
2079 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE);
2080 else {
2081
2082 SWP swp;
2083
2084 WinQueryWindowPos(dcd->hwndFrame, &swp);
2085 DefaultViewKeys(hwnd,
2086 dcd->hwndFrame,
2087 dcd->hwndParent, &swp, pci->pszFileName);
2088 }
2089 }
2090 }
2091 else {
2092 if (!IsRoot(pci->pszFileName)) {
2093 NotifyError(pci->pszFileName, status);
2094 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE);
2095 }
2096 }
2097 }
2098 else if (!pci)
2099 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
2100 if (fFollowTree)
2101 WinSetFocus(HWND_DESKTOP, hwnd);
2102 DosReleaseMutexSem(hmtFillingTreeCnr);
2103 }
2104 return 0;
2105
2106 case WM_MENUEND:
2107 if (dcd) {
2108
2109 HWND hwndMenu = (HWND) mp2;
2110
2111 if (hwndMenu == TreeCnrMenu || hwndMenu == TreeMenu ||
2112 hwndMenu == DirMenu) {
2113 MarkAll(hwnd, TRUE, FALSE, TRUE);
2114 if (dcd->cnremphasized) {
2115 WinSendMsg(hwnd,
2116 CM_SETRECORDEMPHASIS,
2117 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2118 dcd->cnremphasized = FALSE;
2119 }
2120 }
2121 }
2122 break;
2123
2124 case UM_OPENWINDOWFORME:
2125 if (dcd) {
2126 if (mp1 && !IsFile((CHAR *)mp1))
2127 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
2128 }
2129 return 0;
2130
2131 case MM_PORTHOLEINIT:
2132 if (dcd) {
2133 switch (SHORT1FROMMP(mp1)) {
2134 case 0:
2135 case 1:
2136 {
2137 ULONG wmsg;
2138
2139 wmsg = ((SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU);
2140 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
2141 wmsg, MPVOID, MPVOID), mp1, mp2);
2142 }
2143 break;
2144 }
2145 }
2146 break;
2147
2148 case UM_INITMENU:
2149 case WM_INITMENU:
2150 if (dcd) {
2151
2152 switch (SHORT1FROMMP(mp1)) {
2153 case IDM_FILESMENU:
2154 {
2155 PCNRITEM pci;
2156
2157 pci = (PCNRITEM) CurrentRecord(hwnd);
2158 if (pci && (INT) pci != -1) {
2159 BOOL rdy;
2160 BOOL writeable;
2161 BOOL removable;
2162 BOOL local;
2163 BOOL underenv;
2164 CHAR chDrvU;
2165 CHAR szDrv[CCHMAXPATH];
2166
2167 strcpy(szDrv, pci->pszFileName);
2168 chDrvU = *pci->pszFileName;
2169 chDrvU = toupper(chDrvU);
2170 MakeValidDir(szDrv);
2171 rdy = *szDrv == chDrvU; // Drive not ready if MakeValidDir changes drive letter
2172 removable = rdy
2173 && (driveflags[chDrvU - 'A'] & DRIVE_REMOVABLE) != 0;
2174 writeable = rdy
2175 && !(driveflags[chDrvU - 'A'] & DRIVE_NOTWRITEABLE);
2176 local = rdy && (!(driveflags[chDrvU - 'A'] & (DRIVE_REMOTE | DRIVE_VIRTUAL)));
2177 underenv = (pci->flags & RECFLAGS_UNDERENV) != 0;
2178
2179 CopyPresParams((HWND) mp2, hwndMainMenu);
2180 WinEnableMenuItem((HWND) mp2, IDM_INFO, rdy);
2181
2182 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, writeable);
2183 WinEnableMenuItem((HWND) mp2, IDM_EAS, writeable);
2184 WinEnableMenuItem((HWND) mp2, IDM_SUBJECT, writeable);
2185 WinEnableMenuItem((HWND) mp2, IDM_DRVFLAGS, 1); // fixme to allow if not ready
2186
2187 WinEnableMenuItem((HWND) mp2, IDM_ARCHIVE, rdy);
2188
2189 WinEnableMenuItem((HWND) mp2, IDM_UPDATE, !underenv);
2190 WinEnableMenuItem((HWND) mp2, IDM_EXPANDSUBMENU, !underenv);
2191 WinEnableMenuItem((HWND) mp2, IDM_EXPAND, !underenv);
2192 WinEnableMenuItem((HWND) mp2, IDM_COLLAPSE, !underenv);
2193
2194 WinEnableMenuItem((HWND) mp2, IDM_SIZES, rdy);
2195 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, writeable);
2196 WinEnableMenuItem((HWND) mp2, IDM_SHOWALLFILES, rdy);
2197 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, writeable);
2198
2199 WinEnableMenuItem((HWND) mp2, IDM_CHKDSK, writeable && local);
2200 WinEnableMenuItem((HWND) mp2, IDM_FORMAT, writeable && local);
2201 WinEnableMenuItem((HWND) mp2, IDM_OPTIMIZE, writeable && local);
2202 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONSMENU, local);
2203 WinEnableMenuItem((HWND) mp2, IDM_PARTITION, fMiniLVM);
2204 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONDF, fDFSee);
2205 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVMG, fLVMGui);
2206 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONFD, fFDisk);
2207
2208 WinEnableMenuItem((HWND) mp2, IDM_DETACH, !local);
2209
2210 WinEnableMenuItem((HWND) mp2, IDM_EJECT, removable);
2211
2212 WinEnableMenuItem((HWND) mp2, IDM_LOCK, removable);
2213 WinEnableMenuItem((HWND) mp2, IDM_UNLOCK, removable);
2214
2215 WinEnableMenuItem((HWND) mp2, IDM_DELETE, !underenv && writeable);
2216 WinEnableMenuItem((HWND) mp2, IDM_PERMDELETE, !underenv
2217 && writeable);
2218 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, !underenv
2219 && writeable);
2220 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, !underenv
2221 && writeable);
2222 WinEnableMenuItem((HWND) mp2, IDM_RENAME, !underenv && writeable);
2223
2224 }
2225 }
2226 break;
2227
2228 case IDM_VIEWSMENU:
2229 WinCheckMenuItem((HWND) mp2,
2230 IDM_MINIICONS, ((dcd->flWindowAttr & CV_MINI) != 0));
2231 CopyPresParams((HWND) mp2, hwndMainMenu);
2232 WinEnableMenuItem((HWND) mp2, IDM_RESELECT, FALSE);
2233 WinEnableMenuItem((HWND) mp2, IDM_PARTITION, fMiniLVM);
2234 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONDF, fDFSee);
2235 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVMG, fLVMGui);
2236 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONFD, fFDisk);
2237 break;
2238
2239 case IDM_COMMANDSMENU:
2240 SetupCommandMenu((HWND) mp2, hwnd);
2241 CopyPresParams((HWND) mp2, hwndMainMenu);
2242 break;
2243
2244 case IDM_SORTSUBMENU:
2245 SetSortChecks((HWND) mp2, TreesortFlags);
2246 CopyPresParams((HWND) mp2, hwndMainMenu);
2247 break;
2248
2249 case IDM_WINDOWSMENU:
2250 SetupWinList((HWND) mp2,
2251 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
2252 CopyPresParams((HWND) mp2, hwndMainMenu);
2253 break;
2254 }
2255 dcd->hwndLastMenu = (HWND) mp2;
2256 }
2257 if (msg == WM_INITMENU)
2258 break;
2259 return 0;
2260
2261 case UM_COMMAND:
2262 if (!mp1)
2263 Runtime_Error(pszSrcFile, __LINE__, NULL);
2264 else {
2265 if (!dcd) {
2266 Runtime_Error(pszSrcFile, __LINE__, NULL);
2267 FreeListInfo((LISTINFO *) mp1);
2268 }
2269 else {
2270 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
2271 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
2272 FreeListInfo((LISTINFO *) mp1);
2273 }
2274 else
2275 return (MRESULT) TRUE;
2276 }
2277 }
2278 return 0;
2279
2280 case UM_LOADFILE:
2281 if (dcd && mp2) {
2282
2283 HWND hwnd;
2284
2285 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
2286 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
2287 (CHAR *)mp2, dcd->hwndFrame);
2288 else
2289 hwnd = StartMLEEditor(dcd->hwndParent,
2290 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
2291 free((CHAR *)mp2);
2292 return MRFROMLONG(hwnd);
2293 }
2294 return 0;
2295
2296 case UM_FIXCNRMLE:
2297 case UM_FIXEDITNAME:
2298 return CommonCnrProc(hwnd, msg, mp1, mp2);
2299
2300 case UM_NOTIFY:
2301 if (mp2)
2302 Notify((CHAR *)mp2);
2303 return 0;
2304
2305 case UM_FILTER:
2306 if (dcd) {
2307
2308 BOOL tempsusp = dcd->suspendview;
2309
2310 if (mp1) {
2311 //DosEnterCritSec(); // GKY 11-30-08 moved to SetMask
2312 SetMask((CHAR *)mp1, &dcd->mask);
2313 //DosExitCritSec();
2314 }
2315 dcd->suspendview = TRUE;
2316 dcd->mask.attrFile |= FILE_DIRECTORY;
2317 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2318 dcd->suspendview = tempsusp;
2319 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2320 //DbgMsg(pszSrcFile, __LINE__, "UM_RESCAN %p pci %s", hwnd, (CHAR *) mp1);
2321 }
2322 return 0;
2323
2324 case UM_DRIVECMD:
2325 if (mp1) {
2326 ShowTreeRec(hwnd, (CHAR *)mp1, FALSE, TRUE);
2327 PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
2328 }
2329 return 0;
2330
2331 case WM_APPTERMINATENOTIFY:
2332 {
2333 APPNOTIFY *info;
2334 PCNRITEM pci;
2335 CHAR s[] = " :\\";
2336
2337 if (!mp2) {
2338 if (hwndMain)
2339 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
2340 }
2341 info = apphead;
2342 while (info) {
2343 if (info->happ == (HAPP) mp1) {
2344 *s = info->device;
2345 pci = FindCnrRecord(hwnd, s, NULL, FALSE, FALSE, TRUE);
2346 if (pci && (INT) pci != -1) {
2347 INT x = info->device - 'A';
2348 CHAR FileSystem[CCHMAXPATH];
2349
2350 driveserial[x] = -1;
2351 DriveFlagsOne(x, FileSystem, NULL);
2352 if (driveflags[x] &
2353 (DRIVE_INVALID | DRIVE_IGNORE))
2354 RemoveCnrItems(hwnd, pci, 1, CMA_FREE);
2355 else
2356 Flesh(hwnd, pci);
2357 }
2358 if (info->prev)
2359 info->prev->next = info->next;
2360 if (info->next)
2361 info->next->prev = info->prev;
2362 if (apphead == info)
2363 apphead = info->next;
2364 if (apptail == info)
2365 apptail = info->prev;
2366 free(info);
2367 break;
2368 }
2369 info = info->next;
2370 }
2371 }
2372 break;
2373
2374 case WM_COMMAND:
2375 DosError(FERR_DISABLEHARDERR);
2376 if (dcd) {
2377 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2378 return 0;
2379 switch (SHORT1FROMMP(mp1)) {
2380 case IDM_SETTARGET:
2381 SetTargetDir(hwnd, FALSE);
2382 break;
2383
2384 case IDM_DETACH:
2385 {
2386 CHAR d[3] = " :";
2387 PCNRITEM pci;
2388 PROGDETAILS pgd;
2389 CHAR params[368], *p;
2390 HAPP happ;
2391
2392 pci = (PCNRITEM) CurrentRecord(hwnd);
2393 if (pci && (INT) pci != -1 && isalpha(*pci->pszFileName)) {
2394 *d = toupper(*pci->pszFileName);
2395 p = GetCmdSpec(FALSE);
2396 memset(&pgd, 0, sizeof(pgd));
2397 pgd.Length = sizeof(pgd);
2398 pgd.progt.progc = PROG_WINDOWABLEVIO;
2399 pgd.progt.fbVisible = SHE_VISIBLE;
2400 pgd.pszTitle = (PSZ)GetPString(IDS_DETACHREQUESTTEXT);
2401 pgd.pszExecutable = p;
2402 pgd.pszParameters = params;
2403 pgd.pszStartupDir = NULL;
2404 pgd.pszIcon = NULL;
2405 pgd.pszEnvironment = NULL;
2406 pgd.swpInitial.hwndInsertBehind = HWND_TOP;
2407 pgd.swpInitial.hwnd = hwnd;
2408 pgd.swpInitial.fl = SWP_SHOW | SWP_ACTIVATE;
2409 sprintf(params, "/C NET USE %s /D", d);
2410 happ = WinStartApp(hwnd, &pgd, pgd.pszParameters,
2411 NULL, SAF_MAXIMIZED);
2412 if (!happ) {
2413 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, hwnd,
2414 GetPString(IDS_ERRORTEXT),
2415 GetPString(IDS_CANTSTARTTEXT), p, params);
2416 }
2417 else {
2418 APPNOTIFY *info;
2419
2420 info = xmallocz(sizeof(APPNOTIFY), pszSrcFile, __LINE__);
2421 if (info) {
2422 info->happ = happ;
2423 info->device = *d;
2424 if (!apphead)
2425 apphead = info;
2426 else {
2427 apptail->next = info;
2428 info->prev = apptail;
2429 }
2430 apptail = info;
2431 }
2432 }
2433 }
2434 }
2435 break;
2436
2437 case IDM_REMAP:
2438 WinDlgBox(HWND_DESKTOP, hwnd, RemapDlgProc,
2439 FM3ModHandle, MAP_FRAME, NULL);
2440 break;
2441
2442 case IDM_CONTEXTMENU:
2443 {
2444 PCNRITEM pci;
2445
2446 pci = (PCNRITEM) CurrentRecord(hwnd);
2447 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
2448 MPFROMP(pci));
2449 }
2450 break;
2451
2452 case IDM_FINDINTREE:
2453 {
2454 PSZ pszTempDir;
2455 PCNRITEM pci;
2456
2457 pci = (PCNRITEM) CurrentRecord(hwnd);
2458 if (pci && (INT) pci != -1) {
2459 pszTempDir = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
2460 if (pszTempDir)
2461 MakeValidDir(pszTempDir);
2462 }
2463 else
2464 pszTempDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
2465 if (pszTempDir) {
2466 if (WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2467 WalkAllDlgProc,
2468 FM3ModHandle, WALK_FRAME, MPFROMP(pszTempDir))) {
2469 if (!WinSendMsg(hwnd, UM_SHOWME, MPFROMP(pszTempDir), MPFROMLONG(1)))
2470 free(pszTempDir);
2471 }
2472 else
2473 free(pszTempDir);
2474 }
2475 }
2476 break;
2477
2478 case IDM_BEGINEDIT:
2479 OpenEdit(hwnd);
2480 break;
2481
2482 case IDM_ENDEDIT:
2483 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
2484 break;
2485
2486 case IDM_FILTER:
2487 {
2488 BOOL empty = FALSE;
2489 PCNRITEM pci;
2490
2491 pci = (PCNRITEM) CurrentRecord(hwnd);
2492 if (!*dcd->mask.szMask)
2493 empty = TRUE;
2494 dcd->mask.fIsTree = TRUE;
2495 *dcd->mask.prompt = 0;
2496 if (pci && (INT) pci != -1)
2497 dcd->mask.fFilesIncluded =
2498 ((driveflags[toupper(*pci->pszFileName) - 'A'] &
2499 DRIVE_INCLUDEFILES) != 0);
2500 else
2501 dcd->mask.fFilesIncluded = FALSE;
2502 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2503 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2504 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2505 else if (empty)
2506 *dcd->mask.szMask = 0;
2507 PrfWriteProfileData(fmprof, appname, "TreeFilter", &dcd->mask,
2508 sizeof(MASK));
2509 }
2510 break;
2511
2512 case IDM_SHOWSORT:
2513 QuickPopup(hwnd, dcd, CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP),
2514 IDM_SORTSUBMENU);
2515 break;
2516
2517 case IDM_SHOWSELECT:
2518 QuickPopup(hwnd, dcd, CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP),
2519 IDM_SELECTSUBMENU);
2520 break;
2521
2522 case IDM_TREECNRVIEWSETTINGS:
2523 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
2524 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_TREECNRVIEWSETTINGS), mp2);
2525 else {
2526 WinDlgBox(HWND_DESKTOP,
2527 hwnd,
2528 CfgDlgProc,
2529 FM3ModHandle,
2530 CFG_FRAME,
2531 MPFROMLONG(IDM_TREECNRVIEWSETTINGS));
2532 }
2533 break;
2534
2535 case IDM_WALKDIR:
2536 case IDM_OPENWALK:
2537 {
2538 CHAR newpath[CCHMAXPATH];
2539 PCNRITEM pci;
2540
2541 pci = (PCNRITEM) CurrentRecord(hwnd);
2542 if (pci && (INT) pci != -1) {
2543 strcpy(newpath, pci->pszFileName);
2544 MakeValidDir(newpath);
2545 }
2546 else
2547 strcpy(newpath, pFM2SaveDirectory);
2548 if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkAllDlgProc,
2549 FM3ModHandle, WALK_FRAME,
2550 MPFROMP(newpath)) || !*newpath)
2551 break;
2552 WinSendMsg(hwnd, UM_OPENWINDOWFORME, MPFROMP(newpath), MPVOID);
2553 }
2554 break;
2555
2556 case IDM_HELP:
2557 if (hwndHelp) {
2558 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
2559 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
2560 else
2561 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
2562 }
2563 break;
2564
2565 case IDM_PARTITION:
2566 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2567 NULL, NULL,
2568 "%s", PCSZ_MINILVMEXE);
2569 break;
2570
2571 case IDM_PARTITIONDF:
2572 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2573 NULL, NULL,
2574 "%s", PCSZ_DFSOS2EXE);
2575 break;
2576
2577 case IDM_PARTITIONLVMG:
2578 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2579 NULL, NULL,
2580 "%s", PCSZ_LVMGUICMD);
2581 break;
2582
2583 case IDM_PARTITIONFD:
2584 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2585 NULL, NULL,
2586 "%s", PCSZ_FDISKPMEXE);
2587 break;
2588
2589 case IDM_REFRESHREMOVABLES:
2590 runemf2(SEPARATE | WINDOWED | BACKGROUND | MINIMIZED | WAIT,
2591 HWND_DESKTOP, pszSrcFile, __LINE__, NULL, NULL,
2592 "%s %s", PCSZ_LVMEXE, "/RediscoverPRM");
2593 PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
2594 break;
2595
2596 case IDM_SORTNAME:
2597 case IDM_SORTFILENAME:
2598 case IDM_SORTSIZE:
2599 case IDM_SORTEASIZE:
2600 case IDM_SORTFIRST:
2601 case IDM_SORTLAST:
2602 case IDM_SORTLWDATE:
2603 case IDM_SORTLADATE:
2604 case IDM_SORTCRDATE:
2605 TreesortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
2606 case IDM_SORTDIRSFIRST:
2607 case IDM_SORTDIRSLAST:
2608 case IDM_SORTREVERSE:
2609 switch (SHORT1FROMMP(mp1)) {
2610 case IDM_SORTFILENAME:
2611 TreesortFlags |= SORT_FILENAME;
2612 break;
2613 case IDM_SORTSIZE:
2614 TreesortFlags |= SORT_SIZE;
2615 break;
2616 case IDM_SORTEASIZE:
2617 TreesortFlags |= SORT_EASIZE;
2618 break;
2619 case IDM_SORTFIRST:
2620 TreesortFlags |= SORT_FIRSTEXTENSION;
2621 break;
2622 case IDM_SORTLAST:
2623 TreesortFlags |= SORT_LASTEXTENSION;
2624 break;
2625 case IDM_SORTLWDATE:
2626 TreesortFlags |= SORT_LWDATE;
2627 break;
2628 case IDM_SORTLADATE:
2629 TreesortFlags |= SORT_LADATE;
2630 break;
2631 case IDM_SORTCRDATE:
2632 TreesortFlags |= SORT_CRDATE;
2633 break;
2634 case IDM_SORTDIRSFIRST:
2635 if (TreesortFlags & SORT_DIRSFIRST)
2636 TreesortFlags &= (~SORT_DIRSFIRST);
2637 else {
2638 TreesortFlags |= SORT_DIRSFIRST;
2639 TreesortFlags &= (~SORT_DIRSLAST);
2640 }
2641 break;
2642 case IDM_SORTDIRSLAST:
2643 if (TreesortFlags & SORT_DIRSLAST)
2644 TreesortFlags &= (~SORT_DIRSLAST);
2645 else {
2646 TreesortFlags |= SORT_DIRSLAST;
2647 TreesortFlags &= (~SORT_DIRSFIRST);
2648 }
2649 break;
2650 case IDM_SORTREVERSE:
2651 if (TreesortFlags & SORT_REVERSE)
2652 TreesortFlags &= (~SORT_REVERSE);
2653 else
2654 TreesortFlags |= SORT_REVERSE;
2655 break;
2656 }
2657 PrfWriteProfileData(fmprof, appname, "TreeSort", &TreesortFlags,
2658 sizeof(INT));
2659 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
2660 break;
2661
2662 case IDM_COLLECT:
2663 case IDM_GREP:
2664 if (!Collector) {
2665
2666 HWND hwndC;
2667 SWP swp;
2668
2669 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2670 !fAutoTile &&
2671 (!fExternalCollector && *(ULONG *) realappname == FM3UL))
2672 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2673 hwndC = StartCollector((fExternalCollector ||
2674 *(ULONG *) realappname != FM3UL) ?
2675 HWND_DESKTOP : dcd->hwndParent, 4);
2676 if (hwndC) {
2677 if (!ParentIsDesktop(hwnd,
2678 dcd->hwndParent) &&
2679 !fAutoTile &&
2680 (!fExternalCollector && *(ULONG *) realappname == FM3UL))
2681 WinSetWindowPos(hwndC,
2682 HWND_TOP,
2683 swp.x,
2684 swp.y,
2685 swp.cx,
2686 swp.cy,
2687 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
2688 else if (!ParentIsDesktop(hwnd,
2689 dcd->hwndParent) &&
2690 fAutoTile && *(ULONG *) realappname == FM3UL)
2691 TileChildren(dcd->hwndParent, TRUE);
2692 }
2693 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
2694 DosSleep(100);//05 Aug 07 GKY 250
2695 }
2696 else
2697 StartCollector(dcd->hwndParent, 4);
2698 if (SHORT1FROMMP(mp1) == IDM_GREP) {
2699 PCNRITEM pci = NULL;
2700
2701 pci = WinSendMsg(hwnd,
2702 CM_QUERYRECORDEMPHASIS,
2703 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
2704 if (pci && (INT) pci != -1)
2705 PostMsg(Collector, WM_COMMAND,
2706 MPFROM2SHORT(UM_GREP, 0), MPFROMP(pci->pszFileName));
2707 else
2708 PostMsg(Collector, WM_COMMAND,
2709 MPFROM2SHORT(IDM_GREP, 0), MPVOID);
2710 }
2711 else
2712 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2713 break;
2714
2715 case IDM_COLLECTOR:
2716 DosSleep(32);//05 Aug 07 GKY 64
2717 {
2718 CHAR **list;
2719
2720 list = BuildList(hwnd);
2721 if (list) {
2722 if (Collector) {
2723 if (!PostMsg(Collector, WM_COMMAND,
2724 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2725 FreeList(list);
2726 }
2727 else
2728 FreeList(list);
2729 }
2730 }
2731 break;
2732
2733 case IDM_COLLAPSEALL:
2734 WinSendMsg(hwnd, CM_COLLAPSETREE, MPVOID, MPVOID);
2735 break;
2736
2737 case IDM_COLLAPSE:
2738 case IDM_EXPAND:
2739 {
2740 PCNRITEM pci = NULL;
2741
2742 pci = (PCNRITEM) CurrentRecord(hwnd);
2743 if (pci && (INT) pci != -1) {
2744 if (pci->flags & RECFLAGS_UNDERENV)
2745 break;
2746 PostMsg(dcd->hwndObject, UM_EXPAND, mp1, MPFROMP(pci));
2747 }
2748 }
2749 break;
2750
2751 case IDM_UPDATE:
2752 {
2753 PCNRITEM pci = (PCNRITEM)CurrentRecord(hwnd);
2754 if (pci && (INT)pci != -1) {
2755 struct
2756 {
2757 ULONG serial;
2758 CHAR volumelength;
2759 CHAR volumelabel[CCHMAXPATH];
2760 }
2761 volser;
2762 INT x = toupper(*pci->pszFileName) - 'A';
2763 CHAR FileSystem[CCHMAXPATH], szBuf[CCHMAXPATH];
2764
2765 UINT driveflag = driveflags[x];
2766 if (pci->attrFile & FILE_DIRECTORY) {
2767 if (pci->flags & RECFLAGS_UNDERENV)
2768 break;
2769 DosRequestMutexSem(hmtFillingTreeCnr, SEM_INDEFINITE_WAIT);
2770 UnFlesh(hwnd, pci);
2771 // Check if drive type might need update
2772 if ((driveflag & (DRIVE_INVALID | DRIVE_NOPRESCAN)) ||
2773 (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno)) {
2774 DriveFlagsOne(x, FileSystem, &volser);
2775 driveflag = driveflags[x];
2776 if (driveflag & DRIVE_INVALID)
2777 pci->rc.hptrIcon = hptrDunno;
2778 else if (strlen(pci->pszFileName) < 4) {
2779 SelectDriveIcon(pci);
2780 }
2781 if ((fShowFSTypeInTree || fShowDriveLabelInTree) &&
2782 strlen(pci->pszFileName) < 4) {
2783 strcpy(szBuf, pci->pszFileName);
2784 strcat(szBuf, " [");
2785 strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
2786 strcat(szBuf, "]");
2787 pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
2788 pci->rc.pszIcon = pci->pszDisplayName;
2789 }
2790 WinSendMsg(hwnd,
2791 CM_INVALIDATERECORD,
2792 MPFROMP(&pci),
2793 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2794 if (hwndMain)
2795 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
2796 }
2797 if (~driveflag & DRIVE_INVALID)
2798 Flesh(hwnd, pci);
2799 DosReleaseMutexSem(hmtFillingTreeCnr);
2800 }
2801 }
2802 }
2803 break;
2804
2805 case IDM_RESCAN:
2806 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
2807 break;
2808
2809 case IDM_RESORT:
2810 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
2811 break;
2812
2813 case IDM_TEXT:
2814 case IDM_MINIICONS:
2815 {
2816 CNRINFO cnri;
2817
2818 memset(&cnri, 0, sizeof(CNRINFO));
2819 cnri.cb = sizeof(CNRINFO);
2820 WinSendMsg(hwnd,
2821 CM_QUERYCNRINFO,
2822 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
2823 if (SHORT1FROMMP(mp1) == IDM_MINIICONS) {
2824 if (cnri.flWindowAttr & CV_MINI)
2825 cnri.flWindowAttr &= (~CV_MINI);
2826 else
2827 cnri.flWindowAttr |= CV_MINI;
2828 }
2829 else {
2830 if (cnri.flWindowAttr & CV_TEXT) {
2831 cnri.flWindowAttr &= (~CV_TEXT);
2832 cnri.flWindowAttr |= CV_ICON;
2833 }
2834 else {
2835 cnri.flWindowAttr &= (~CV_ICON);
2836 cnri.flWindowAttr |= CV_TEXT;
2837 }
2838 }
2839 dcd->flWindowAttr = cnri.flWindowAttr;
2840 PrfWriteProfileData(fmprof,
2841 appname,
2842 "TreeflWindowAttr",
2843 &cnri.flWindowAttr, sizeof(ULONG));
2844 WinSendMsg(hwnd,
2845 CM_SETCNRINFO,
2846 MPFROMP(&cnri),
2847 MPFROMLONG(CMA_FLWINDOWATTR | CMA_TREEICON |
2848 CMA_SLTREEBITMAPORICON));
2849 }
2850 break;
2851
2852 case IDM_SIZES:
2853 case IDM_DRVFLAGS:
2854 case IDM_SHOWALLFILES:
2855 case IDM_UNDELETE:
2856 case IDM_OPTIMIZE:
2857 case IDM_CHKDSK:
2858 case IDM_FORMAT:
2859 case IDM_MKDIR:
2860 case IDM_LOCK:
2861 case IDM_UNLOCK:
2862 case IDM_EJECT:
2863 case IDM_CLOSETRAY:
2864 {
2865 PCNRITEM pci;
2866
2867 pci = (PCNRITEM) CurrentRecord(hwnd);
2868 if (pci && (INT) pci != -1)
2869 CommonDriveCmd(hwnd, pci->pszFileName, SHORT1FROMMP(mp1));
2870 }
2871 break;
2872
2873 case IDM_SAVETOLIST:
2874 WinDlgBox(HWND_DESKTOP,
2875 hwnd,
2876 SaveListDlgProc, FM3ModHandle, SAV_FRAME, MPFROMP(&hwnd));
2877 break;
2878
2879 case IDM_DELETE:
2880 case IDM_PERMDELETE:
2881 case IDM_MOVE:
2882 case IDM_WPSMOVE:
2883 case IDM_WILDMOVE:
2884 case IDM_RENAME:
2885 {
2886 PCNRITEM pci;
2887
2888 pci = (PCNRITEM) CurrentRecord(hwnd);
2889 if (pci && (INT) pci != -1) {
2890 if (pci->flags & RECFLAGS_UNDERENV)
2891 break;
2892 }
2893 }
2894 /* else intentional fallthru */
2895 case IDM_ATTRS:
2896 case IDM_INFO:
2897 case IDM_COPY:
2898 case IDM_WPSCOPY:
2899 case IDM_WILDCOPY:
2900 case IDM_DOITYOURSELF:
2901 case IDM_OPENWINDOW:
2902 case IDM_OPENSETTINGS:
2903 case IDM_OPENDEFAULT:
2904 case IDM_OPENICON:
2905 case IDM_OPENDETAILS:
2906 case IDM_OPENTREE:
2907 case IDM_SHADOW:
2908 case IDM_SHADOW2:
2909 case IDM_COMPARE:
2910 case IDM_VIEW:
2911 case IDM_VIEWTEXT:
2912 case IDM_VIEWBINARY:
2913 case IDM_EDIT:
2914 case IDM_EDITTEXT:
2915 case IDM_EDITBINARY:
2916 case IDM_EAS:
2917 case IDM_SUBJECT:
2918 case IDM_APPENDTOCLIP:
2919 case IDM_SAVETOCLIP:
2920 case IDM_ARCHIVE:
2921 case IDM_MCIPLAY:
2922 case IDM_UUDECODE:
2923 {
2924 LISTINFO *li;
2925 ULONG action = UM_ACTION;
2926# ifdef FORTIFY
2927 Fortify_EnterScope();
2928# endif
2929 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2930 if (li) {
2931 li->type = SHORT1FROMMP(mp1);
2932 li->hwnd = hwnd;
2933 li->list = BuildList(hwnd);
2934 if (!li->list || !li->list[0]) {
2935 free(li);
2936 break;
2937 }
2938 if (IsRoot(li->list[0])) {
2939 switch (SHORT1FROMMP(mp1)) {
2940 case IDM_MOVE:
2941 case IDM_COPY:
2942 case IDM_WILDCOPY:
2943 case IDM_WILDMOVE:
2944 case IDM_WPSMOVE:
2945 case IDM_WPSCOPY:
2946 case IDM_RENAME:
2947 case IDM_DELETE:
2948 case IDM_PERMDELETE:
2949 mp1 = MPFROM2SHORT(IDM_INFO, SHORT2FROMMP(mp1));
2950 li->type = IDM_INFO;
2951 }
2952 }
2953 switch (SHORT1FROMMP(mp1)) {
2954 case IDM_APPENDTOCLIP:
2955 case IDM_SAVETOCLIP:
2956 case IDM_ARCHIVE:
2957 case IDM_DELETE:
2958 case IDM_PERMDELETE:
2959 case IDM_ATTRS:
2960 case IDM_SHADOW:
2961 case IDM_SHADOW2:
2962 case IDM_DOITYOURSELF:
2963 case IDM_EAS:
2964 case IDM_VIEW:
2965 case IDM_VIEWTEXT:
2966 case IDM_VIEWBINARY:
2967 case IDM_EDIT:
2968 case IDM_EDITTEXT:
2969 case IDM_EDITBINARY:
2970 case IDM_MCIPLAY:
2971 action = UM_MASSACTION;
2972 }
2973 if (SHORT1FROMMP(mp1) == IDM_SHADOW ||
2974 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2975 *li->targetpath = 0;
2976 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2977 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
2978 FreeListInfo(li);
2979 }
2980 }
2981# ifdef FORTIFY
2982 Fortify_LeaveScope();
2983# endif
2984 }
2985 break;
2986
2987 default:
2988 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2989 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2990
2991 INT x;
2992
2993 if (!cmdloaded)
2994 load_commands();
2995 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2996 if (x >= 0) {
2997 x++;
2998 RunCommand(hwnd, x);
2999 if (fUnHilite)
3000 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
3001 }
3002 }
3003 break;
3004 }
3005 }
3006 return 0;
3007
3008 case WM_SAVEAPPLICATION:
3009 if (dcd && !ParentIsDesktop(hwnd, dcd->hwndParent)) {
3010
3011 SWP swp, swpP;
3012 INT ratio;
3013
3014 WinQueryWindowPos(dcd->hwndFrame, &swp);
3015 if (!(swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE | SWP_HIDE))) {
3016 WinQueryWindowPos(dcd->hwndParent, &swpP);
3017 if (swp.cx) {
3018 ratio = (swpP.cx * 100) / swp.cx;
3019 if (ratio > 0)
3020 PrfWriteProfileData(fmprof, appname, "TreeWindowRatio",
3021 &ratio, sizeof(INT));
3022 }
3023 }
3024 }
3025 else if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3026
3027 SWP swp;
3028
3029 WinQueryWindowPos(dcd->hwndFrame, &swp);
3030 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3031 WinStoreWindowPos(FM2Str, "VTreeWindowPos", dcd->hwndFrame);
3032 }
3033 break;
3034
3035 case UM_MINIMIZE:
3036 if (dcd && hwndMain) {
3037 fOkayMinimize = TRUE;
3038 if (dcd->hwndObject && !fDummy) {
3039 DosSleep(50);//05 Aug 07 GKY 100
3040 if (!fDummy) {
3041 fOkayMinimize = FALSE;
3042 WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
3043 dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0,
3044 SWP_MINIMIZE | SWP_DEACTIVATE);
3045 }
3046 }
3047 }
3048 return 0;
3049
3050 case UM_MAXIMIZE:
3051 if (dcd || hwndMain)
3052 WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
3053 dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0, SWP_MAXIMIZE |
3054 SWP_SHOW);
3055 return 0;
3056
3057 case UM_CLOSE:
3058 {
3059 HWND hwndParent = WinQueryWindow(WinQueryWindow(WinQueryWindow(hwnd,
3060 QW_PARENT),
3061 QW_PARENT), QW_PARENT);
3062
3063 if (!mp1) {
3064 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
3065 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3066 if (hwndParent && !ParentIsDesktop(hwnd, hwndParent))
3067 WinDestroyWindow(hwndParent);
3068 }
3069 else
3070 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3071 QW_PARENT));
3072 }
3073 return 0;
3074
3075 case WM_CLOSE:
3076 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3077 if (dcd)
3078 dcd->stopflag++;
3079 if (dcd && dcd->hwndObject) {
3080 /* kill object window */
3081 if (WinIsWindow((HAB) 0, dcd->hwndObject)) {
3082 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3083 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
3084 }
3085 }
3086 else
3087 WinSendMsg(hwnd, UM_CLOSE, MPFROMLONG(1), MPVOID);
3088 return 0;
3089
3090 case WM_DESTROY:
3091# ifdef FORTIFY
3092 DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
3093# endif
3094 if (TreeCnrMenu)
3095 WinDestroyWindow(TreeCnrMenu);
3096 if (DirMenu)
3097 WinDestroyWindow(DirMenu);
3098 if (FileMenu)
3099 WinDestroyWindow(FileMenu);
3100 TreeCnrMenu = FileMenu = DirMenu = (HWND) 0;
3101 EmptyCnr(hwnd);
3102 if (apphead) {
3103 APPNOTIFY *info, *next;
3104 info = apphead;
3105 while (info) {
3106 next = info->next;
3107 free(info);
3108 info = next;
3109 }
3110 apphead = apptail = NULL;
3111 }
3112# ifdef FORTIFY
3113 Fortify_LeaveScope();
3114# endif
3115 break; // WM_DESTROY
3116 } // switch
3117 if (dcd && dcd->oldproc){
3118 return dcd->oldproc(hwnd, msg, mp1, mp2);
3119 }
3120 else
3121 return PFNWPCnr(hwnd, msg, mp1, mp2);
3122}
3123
3124HWND StartTreeCnr(HWND hwndParent, ULONG flags)
3125{
3126 /* bitmapped flags:
3127 * 0x00000001 = don't close app when window closes
3128 * 0x00000002 = no frame controls
3129 * 0x00000004 = no close or move button
3130 */
3131
3132 HWND hwndFrame = NULLHANDLE;
3133 HWND hwndSysMenu = NULLHANDLE;
3134 HWND hwndClient;
3135 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3136 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3137 DIRCNRDATA *dcd;
3138
3139 if (!hwndParent)
3140 hwndParent = HWND_DESKTOP;
3141 if (ParentIsDesktop(hwndParent, hwndParent))
3142 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3143 if (flags & 2)
3144 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3145 FCF_MINMAX | FCF_ICON));
3146 hwndFrame = WinCreateStdWindow(hwndParent,
3147 WS_VISIBLE,
3148 &FrameFlags,
3149 WC_TREECONTAINER,
3150 NULL,
3151 WS_VISIBLE | fwsAnimate,
3152 FM3ModHandle, TREE_FRAME, &hwndClient);
3153 if (hwndParent != HWND_DESKTOP) {
3154 hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
3155 if (hwndSysMenu != NULLHANDLE)
3156 WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
3157 MPFROM2SHORT(SC_CLOSE, TRUE),
3158 MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
3159 if (!fFreeTree)
3160 WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
3161 MPFROM2SHORT(SC_MOVE, TRUE),
3162 MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
3163 }
3164 if (hwndFrame && hwndClient) {
3165# ifdef FORTIFY
3166 Fortify_EnterScope();
3167# endif
3168 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3169 if (!dcd) {
3170 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_OUTOFMEMORY));
3171 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3172 hwndFrame = (HWND) 0;
3173 }
3174 else {
3175 SWP swp;
3176 WinQueryWindowPos(hwndFrame, &swp);
3177 if (*(ULONG *) realappname == FM3UL) {
3178 if (!WinCreateWindow(hwndFrame,
3179 WC_TREEOPENBUTTON,
3180 "#303",
3181 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | BS_BITMAP,
3182 ((swp.cx -
3183 WinQuerySysValue(HWND_DESKTOP,
3184 SV_CXMINMAXBUTTON)) -
3185 WinQuerySysValue(HWND_DESKTOP,
3186 SV_CXMINMAXBUTTON) / 2) -
3187 WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER),
3188 (swp.cy -
3189 WinQuerySysValue(HWND_DESKTOP,
3190 SV_CYMINMAXBUTTON)) -
3191 WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER),
3192 WinQuerySysValue(HWND_DESKTOP,
3193 SV_CXMINMAXBUTTON) / 2,
3194 WinQuerySysValue(HWND_DESKTOP,
3195 SV_CYMINMAXBUTTON), hwndFrame,
3196 HWND_TOP, IDM_OPENWINDOW, NULL, NULL)) {
3197 Win_Error(hwndFrame, hwndParent, pszSrcFile, __LINE__,
3198 PCSZ_WINCREATEWINDOW);
3199 }
3200 }
3201 else {
3202 if (!WinCreateWindow(hwndFrame,
3203 WC_TREESTATUS,
3204 GetPString(IDS_YOUAREHERETEXT),
3205 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER,
3206 swp.x + 4 + WinQuerySysValue(HWND_DESKTOP,
3207 SV_CXSIZEBORDER),
3208 swp.cy - (22 + WinQuerySysValue(HWND_DESKTOP,
3209 SV_CYSIZEBORDER)),
3210 (swp.cx - 8) - (WinQuerySysValue(HWND_DESKTOP,
3211 SV_CXSIZEBORDER)
3212 * 2), 22, hwndFrame, HWND_TOP,
3213 MAIN_STATUS, NULL, NULL)) {
3214 Win_Error(hwndFrame, hwndParent, pszSrcFile, __LINE__,
3215 PCSZ_WINCREATEWINDOW);
3216 }
3217 }
3218 memset(dcd, 0, sizeof(DIRCNRDATA));
3219 dcd->size = sizeof(DIRCNRDATA);
3220 dcd->type = TREE_FRAME;
3221 dcd->dontclose = ((flags & 1) != 0);
3222 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3223 dcd->hwndClient = hwndClient;
3224 dcd->hwndFrame = hwndFrame;
3225 {
3226 PFNWP oldproc;
3227
3228 oldproc = WinSubclassWindow(hwndFrame, TreeFrameWndProc);
3229 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3230 oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3231 (PFNWP) TreeTitleWndProc);
3232 WinSetWindowPtr(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3233 QWL_USER, (PVOID) oldproc);
3234 }
3235 dcd->hwndCnr = WinCreateWindow(hwndClient,
3236 WC_CONTAINER,
3237 NULL,
3238 CCS_AUTOPOSITION | CCS_MINIICONS |
3239 CCS_MINIRECORDCORE,
3240 0,
3241 0,
3242 0,
3243 0,
3244 hwndClient,
3245 HWND_TOP, (ULONG) TREE_CNR, NULL, NULL);
3246 if (!dcd->hwndCnr) {
3247 Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
3248 PCSZ_WINCREATEWINDOW);
3249 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3250 free(dcd);
3251 dcd = 0;
3252 hwndFrame = (HWND) 0;
3253 }
3254 else {
3255 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3256 if (ParentIsDesktop(hwndFrame, hwndParent)) {
3257 WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "VTree");
3258 FixSwitchList(hwndFrame, "VTree");
3259 DosPostEventSem(hevInitialCnrScanComplete);
3260 DosCloseEventSem(hevInitialCnrScanComplete);
3261 fInitialDriveScan = FALSE;
3262 }
3263 else {
3264 WinSetWindowText(hwndFrame, GetPString(IDS_TREETEXT));
3265 WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3266 GetPString(IDS_TREETEXT));
3267 }
3268 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr, TreeCnrWndProc);
3269 // fixme to document 01 test?
3270 if (dcd->oldproc == 0)
3271 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
3272 "WinSubclassWindow");
3273 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3274 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3275 }
3276 }
3277# ifdef FORTIFY
3278 if (dcd)
3279 Fortify_ChangeScope(dcd, -1);
3280 Fortify_LeaveScope();
3281 if (dcd)
3282 Fortify_ChangeScope(dcd, +1);
3283# endif
3284 }
3285 return hwndFrame;
3286}
3287
3288#pragma alloc_text(TREECNR,TreeCnrWndProc,TreeObjWndProc,TreeClientWndProc)
3289#pragma alloc_text(TREECNR,TreeFrameWndProc,TreeTitleWndProc,ShowTreeRec)
3290#pragma alloc_text(TREECNR,TreeStatProc,OpenButtonProc)
3291#pragma alloc_text(STARTUP,StartTreeCnr)
Note: See TracBrowser for help on using the repository browser.