source: trunk/dll/treecnr.c@ 954

Last change on this file since 954 was 954, checked in by Steven Levine, 18 years ago

Rework ResizeChildren to resize drive tree correctly
Avoid trap in TreeCnrWndProc WM_SAVEAPPLICATION

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