source: trunk/dll/treecnr.c@ 1395

Last change on this file since 1395 was 1395, checked in by Gregg Young, 17 years ago

Allow user to turn off alert and/or error beeps in settings notebook. Ticket 341 Move repeated strings to PCSZs. Ticket 6 Add *DateFormat functions to format dates based on locale Ticket 28 Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error Ticket 6

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