source: trunk/dll/treecnr.c@ 787

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

Rework UM_FILLSETUPLIST IDM_SAVEDIRCNRSTATE and ..._setups() logic for ticket# 109 and #31
Add GetMSecTimer()
Use GetMSecTimer in DbgMsg
Tweak notebook.ipf scanning page
Move more #pragma alloc_text statements to end of files for OpenWatcom
Delete obsoletes
Revert ExpandAll() ShowTreeRec() DosSleeps to 0 - DosSleep(1) was slowing down inner loops
Drop afFilesToGet - use FilesToGet directly
Optimze ShowTreeRec() collapse logic - was really slow

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