source: trunk/dll/treecnr.c@ 1277

Last change on this file since 1277 was 1277, checked in by Gregg Young, 16 years ago

Add opencont.bmp use as bitmap for open container pushbutton in treecnr in mainwnd FM/2

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