source: trunk/dll/treecnr.c@ 1077

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

Enhance Fortify infrastructure
Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope
Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT support
Add more fm/2 Fortify tooling and rework existing tooling for correct nesting
Still lots to do for cross-thread allocations
Add misc.h
Add walkem.h

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