source: trunk/dll/treecnr.c@ 1359

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

Code to add refresh removable media to tree container related menus (Ticket 54); still needs check for presence of lvm.exe and grey out if not present.

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