source: trunk/dll/treecnr.c@ 593

Last change on this file since 593 was 593, checked in by Gregg Young, 19 years ago

Changes to remove GetPString from window class names

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