source: trunk/dll/treecnr.c@ 1102

Last change on this file since 1102 was 1102, checked in by Gregg Young, 17 years ago

Make the variable passed to treecnr UM_RESCAN a pointer to a temp variable every where to avoid freeing pci->pszFileName or dcd->directory early

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