source: trunk/dll/treecnr.c@ 603

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

Work around for PM drag/drop limit; more drag/drop error checking

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