source: trunk/dll/treecnr.c@ 705

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

Minor code cleanup fix ramdisk on states list & WORPLACE_PROCESS logic

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