source: trunk/dll/treecnr.c@ 687

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

Add CheckPmDrgLimit function to fix crash when dragging to FM/2 for other apps

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