source: branches/ticket_150/dll/treecnr.c@ 869

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

Removed large file APIs from code where hey are not needed.

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