source: trunk/dll/treecnr.c@ 950

Last change on this file since 950 was 950, checked in by Gregg Young, 18 years ago

Cleanup of code to remove close menu item from tree container & conditionally move item.

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