source: trunk/dll/treecnr.c@ 1009

Last change on this file since 1009 was 1009, checked in by Steven Levine, 17 years ago

Add xfree xstrdup Fortify support
Add MT capable Fortify scope logic

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