source: trunk/dll/treecnr.c@ 802

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

Disable DbgMsgs shipped with 3.0.8beta1

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