source: trunk/dll/treecnr.c@ 1326

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

Changes to avoid duplicate directory names on scan using StubbyScanThread.

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