source: trunk/dll/treecnr.c@ 908

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

Back out change for notebook page find

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