source: trunk/dll/treecnr.c@ 775

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

Minor clean up add comments re recent changes

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