source: trunk/dll/treecnr.c@ 557

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

Changes for 3.05 beta mostly drive flag/tree related

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