source: trunk/dll/treecnr.c@ 1299

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

Scan each drive on separate thread (added StubbyScanThread) to speed treecnr scans

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 85.7 KB
Line 
1/***********************************************************************
2
3 $Id: treecnr.c 1299 2008-11-28 23:48:50Z 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 while (StubbyScanCount !=0)
810 DosSleep(100);
811 FillTreeCnr(dcd->hwndCnr, dcd->hwndParent);
812 if (fOkayMinimize) {
813 PostMsg(dcd->hwndCnr, UM_MINIMIZE, MPVOID, MPVOID);
814 fOkayMinimize = FALSE;
815 }
816 WinSendMsg(dcd->hwndCnr,
817 CM_INVALIDATERECORD,
818 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
819 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
820 }
821 return 0;
822
823 case UM_COMMAND:
824 if (mp1) {
825
826 LISTINFO *li = (LISTINFO *) mp1;
827
828 switch (li->type) {
829 case IDM_DOITYOURSELF:
830 case IDM_APPENDTOCLIP:
831 case IDM_SAVETOCLIP:
832 case IDM_ARCHIVE:
833 case IDM_VIEW:
834 case IDM_EDIT:
835 case IDM_OBJECT:
836 case IDM_SHADOW:
837 case IDM_SHADOW2:
838 case IDM_PRINT:
839 case IDM_ATTRS:
840 case IDM_DELETE:
841 case IDM_PERMDELETE:
842 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
843 return (MRESULT) TRUE;
844 default:
845 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
846 return (MRESULT) TRUE;
847 }
848 }
849 return 0;
850
851 case UM_MASSACTION:
852 if (mp1) {
853
854 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
855 if (!dcd)
856 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
857 else {
858 WORKER *wk;
859# ifdef FORTIFY
860 Fortify_EnterScope();
861# endif
862 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
863 if (!wk)
864 FreeListInfo((LISTINFO *) mp1);
865 else {
866 wk->size = sizeof(WORKER);
867 wk->hwndCnr = dcd->hwndCnr;
868 wk->hwndParent = dcd->hwndParent;
869 wk->hwndFrame = dcd->hwndFrame;
870 wk->hwndClient = dcd->hwndClient;
871 wk->li = (LISTINFO *) mp1;
872 strcpy(wk->directory, dcd->directory);
873 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
874 Runtime_Error(pszSrcFile, __LINE__,
875 GetPString(IDS_COULDNTSTARTTHREADTEXT));
876 free(wk);
877 FreeListInfo((LISTINFO *) mp1);
878 }
879 }
880# ifdef FORTIFY
881 Fortify_LeaveScope();
882# endif
883 }
884 }
885 return 0;
886
887 case UM_ACTION:
888# ifdef FORTIFY
889 Fortify_EnterScope();
890# endif
891 if (mp1) {
892# ifdef FORTIFY
893 Fortify_BecomeOwner(mp1);
894# endif
895 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
896 if (!dcd)
897 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
898 else {
899 WORKER *wk;
900 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
901 if (!wk)
902 FreeListInfo((LISTINFO *) mp1);
903 else {
904 wk->size = sizeof(WORKER);
905 wk->hwndCnr = dcd->hwndCnr;
906 wk->hwndParent = dcd->hwndParent;
907 wk->hwndFrame = dcd->hwndFrame;
908 wk->hwndClient = dcd->hwndClient;
909 wk->li = (LISTINFO *) mp1;
910 strcpy(wk->directory, dcd->directory);
911 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
912 Runtime_Error(pszSrcFile, __LINE__,
913 GetPString(IDS_COULDNTSTARTTHREADTEXT));
914 free(wk);
915 FreeListInfo((LISTINFO *) mp1);
916 }
917 }
918 }
919 }
920# ifdef FORTIFY
921 Fortify_LeaveScope();
922# endif
923 return 0;
924
925 case WM_CLOSE:
926 WinDestroyWindow(hwnd);
927 break;
928
929 case WM_DESTROY:
930 hwndTree = (HWND) 0;
931 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
932 if (dcd) {
933 WinSendMsg(dcd->hwndCnr,
934 UM_CLOSE, MPFROMLONG(dcd->dontclose != FALSE), MPVOID);
935 free(dcd);
936# ifdef FORTIFY
937 Fortify_LeaveScope();
938# endif
939 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
940 }
941 DosPostEventSem(CompactSem);
942 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
943 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
944 break;
945 }
946 return WinDefWindowProc(hwnd, msg, mp1, mp2);
947}
948
949MRESULT EXPENTRY TreeCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
950{
951 static APPNOTIFY *apphead = NULL, *apptail = NULL;
952 DIRCNRDATA *dcd = INSTDATA(hwnd);
953
954 switch (msg) {
955 case WM_CREATE:
956 DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2); // 18 Jul 08 SHL fixme
957 break;
958
959 case DM_PRINTOBJECT:
960 return MRFROMLONG(DRR_TARGET);
961
962 case DM_DISCARDOBJECT:
963 if (dcd)
964 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
965 else
966 return MRFROMLONG(DRR_TARGET);
967
968 case WM_CHAR:
969 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
970 if (SHORT1FROMMP(mp1) & KC_KEYUP)
971 return (MRESULT) TRUE;
972 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
973 switch (SHORT2FROMMP(mp2)) {
974 case VK_INSERT:
975 if ((shiftstate & KC_CTRL) == KC_CTRL)
976 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
977 break;
978 case VK_DELETE:
979 if ((shiftstate & KC_CTRL) == KC_CTRL)
980 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
981 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
982 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
983 else
984 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
985 break;
986 }
987 }
988 if (shiftstate || fNoSearch)
989 break;
990 if (SHORT1FROMMP(mp1) & KC_CHAR) {
991
992 ULONG thistime, len;
993 SEARCHSTRING srch;
994 PCNRITEM pci;
995
996 if (!dcd)
997 break;
998 switch (SHORT1FROMMP(mp2)) {
999 case '\x1b':
1000 case '\r':
1001 case '\n':
1002 dcd->lasttime = 0;
1003 *dcd->szCommonName = 0;
1004 break;
1005 default:
1006 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1007 if (thistime > dcd->lasttime + 1250)
1008 *dcd->szCommonName = 0;
1009 dcd->lasttime = thistime;
1010 if (SHORT1FROMMP(mp2) == ' ' && !*dcd->szCommonName)
1011 break;
1012 KbdRetry:
1013 len = strlen(dcd->szCommonName);
1014 if (len >= CCHMAXPATH - 1) {
1015 *dcd->szCommonName = 0;
1016 len = 0;
1017 }
1018 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1019 dcd->szCommonName[len + 1] = 0;
1020 memset(&srch, 0, sizeof(SEARCHSTRING));
1021 srch.cb = (ULONG) sizeof(SEARCHSTRING);
1022 srch.pszSearch = (PSZ) dcd->szCommonName;
1023 srch.fsPrefix = TRUE;
1024 srch.fsCaseSensitive = FALSE;
1025 srch.usView = CV_ICON;
1026 pci = WinSendMsg(hwnd,
1027 CM_SEARCHSTRING,
1028 MPFROMP(&srch), MPFROMLONG(CMA_FIRST));
1029 if (pci && (INT) pci != -1) {
1030 /* make found item current item */
1031 WinSendMsg(hwnd,
1032 CM_SETRECORDEMPHASIS,
1033 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
1034 /* make sure that record shows in viewport */
1035 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1036 return (MRESULT) TRUE;
1037 }
1038 else {
1039 if (SHORT1FROMMP(mp2) == ' ') {
1040 dcd->szCommonName[len] = 0;
1041 break;
1042 }
1043 *dcd->szCommonName = 0;
1044 dcd->lasttime = 0;
1045 if (len) // retry as first letter if no match
1046 goto KbdRetry;
1047 }
1048 break;
1049 }
1050 }
1051 break;
1052
1053 case WM_MOUSEMOVE:
1054 case WM_BUTTON1UP:
1055 case WM_BUTTON2UP:
1056 case WM_BUTTON3UP:
1057 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1058 break;
1059
1060 case UM_TIMER:
1061 if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent) &&
1062 hwndStatus2) {
1063 FILEFINDBUF3L ffb;
1064 ULONG nm = 1;
1065 HDIR hdir = HDIR_CREATE;
1066
1067 if (*SwapperDat) {
1068 if (!xDosFindFirst(SwapperDat,
1069 &hdir,
1070 FILE_NORMAL | FILE_HIDDEN |
1071 FILE_SYSTEM | FILE_ARCHIVED | FILE_READONLY,
1072 &ffb, sizeof(ffb), &nm, FIL_STANDARDL)) {
1073 CHAR tb[39], tm[39], tpm[39], s[163];
1074 ULONG amem;
1075
1076 priority_bumped();
1077 DosFindClose(hdir);
1078 if (!DosQuerySysInfo(QSV_TOTAVAILMEM,
1079 QSV_TOTAVAILMEM,
1080 (PVOID) & amem, sizeof(amem))) {
1081 CommaFmtULL(tpm, sizeof(tpm), amem, 'M');
1082 }
1083 else
1084 *tpm = 0;
1085 if (!Dos16MemAvail(&amem))
1086 CommaFmtULL(tm, sizeof(tm), amem, 'M');
1087 else
1088 *tm = 0;
1089 CommaFmtULL(tb, sizeof(tb), ffb.cbFile, 'M');
1090 sprintf(s, " %s %s%s%s%s%s",
1091 GetPString(IDS_SWAPFILETEXT),
1092 tb,
1093 *tm ? GetPString(IDS_TREEMEMTEXT) : NullStr,
1094 tm, *tpm ? "/" : NullStr, tpm);
1095 WinSetWindowText(hwndStatus2, s);
1096 }
1097 else
1098 WinSetWindowText(hwndStatus2, NullStr);
1099 }
1100 else
1101 WinSetWindowText(hwndStatus2, NullStr);
1102 }
1103 if (msg == UM_TIMER)
1104 return 0;
1105 break;
1106
1107 case WM_PRESPARAMCHANGED:
1108 PresParamChanged(hwnd, "TreeCnr", mp1, mp2);
1109 break;
1110
1111 case UM_FILESMENU:
1112 {
1113 PCNRITEM pci;
1114 HWND menuHwnd = (HWND) 0;
1115 FSALLOCATE fsa;
1116
1117 pci = (PCNRITEM) CurrentRecord(hwnd);
1118 if (pci && (INT) pci != -1) {
1119 if (IsRoot(pci->pszFileName) || !DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
1120 FSIL_ALLOC, &fsa,
1121 sizeof(FSALLOCATE)))
1122 menuHwnd = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
1123 else {
1124 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
1125// WinEnableMenuItem(DirMenu,
1126// IDM_TREE,
1127// FALSE);
1128 }
1129 if (!(pci->attrFile & FILE_DIRECTORY))
1130 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
1131 }
1132 return MRFROMLONG(menuHwnd);
1133 }
1134
1135 case UM_COMPARE:
1136 if (dcd && mp1 && mp2) {
1137
1138 COMPARE *cmp;
1139 CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
1140
1141 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1142 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1143 if (cmp) {
1144 cmp->size = sizeof(COMPARE);
1145 strcpy(cmp->leftdir, leftdir);
1146 strcpy(cmp->rightdir, rightdir);
1147 cmp->hwndParent = dcd->hwndParent;
1148 cmp->dcd.hwndParent = dcd->hwndParent;
1149 WinDlgBox(HWND_DESKTOP,
1150 HWND_DESKTOP,
1151 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1152 }
1153 }
1154 }
1155 return 0;
1156
1157 case UM_UPDATERECORDLIST:
1158 if (dcd && mp1)
1159 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1160 return 0;
1161
1162 case UM_UPDATERECORD:
1163 if (dcd && mp1) {
1164
1165 CHAR *filename;
1166
1167 filename = mp1;
1168 if (filename)
1169 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1170 }
1171 return 0;
1172
1173 case WM_SETFOCUS:
1174 if (dcd && hwndStatus && mp2) {
1175 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1176 if (hwndMain)
1177 PostMsg(hwndMain, UM_ADVISEFOCUS, MPFROMLONG(dcd->hwndFrame), MPVOID);
1178 }
1179 break;
1180
1181 case UM_RESCAN:
1182 if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1183 /*
1184 * put name of our window on status line
1185 */
1186
1187 PCNRITEM pci = NULL;
1188 CHAR str[CCHMAXPATH + 6];
1189
1190 if (fAutoView && hwndMain) {
1191 pci = WinSendMsg(hwnd,
1192 CM_QUERYRECORDEMPHASIS,
1193 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1194 if (pci && (INT) pci != -1 && fComments &&
1195 !(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW))
1196 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1197 else
1198 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1199 }
1200 if (!fAutoView || !hwndMain)
1201 pci = (PCNRITEM) WinSendMsg(hwnd,
1202 CM_QUERYRECORDEMPHASIS,
1203 MPFROMLONG(CMA_FIRST),
1204 MPFROMSHORT(CRA_CURSORED));
1205 if ((INT) pci == -1)
1206 pci = NULL;
1207 if (pci) {
1208 if (*(ULONG *) realappname == FM3UL) {
1209 sprintf(str, "%s %s", GetPString(IDS_DTTEXT), pci->pszFileName);
1210 WinSetWindowText(dcd->hwndFrame, str);
1211 WinSetWindowText(WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR),
1212 str);
1213 }
1214 else
1215 WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
1216 MAIN_STATUS), pci->pszFileName);
1217 if (fMoreButtons && hwndName) {
1218 WinSetWindowText(hwndName, pci->pszFileName);
1219 sprintf(str,
1220 "%04u/%02u/%02u %02u:%02u:%02u",
1221 pci->date.year,
1222 pci->date.month,
1223 pci->date.day,
1224 pci->time.hours, pci->time.minutes, pci->time.seconds);
1225 WinSetWindowText(hwndDate, str);
1226 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1227 }
1228 }
1229 PostMsg(dcd->hwndObject, UM_RESCAN2, MPFROMP(pci), MPVOID);
1230 if (hwndStatus2)
1231 PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID);
1232 }
1233 return 0;
1234
1235 case UM_SETUP2:
1236 {
1237 PCNRITEM pci = (PCNRITEM) mp1;
1238
1239 if (pci)
1240 NotifyError(pci->pszFileName, (ULONG) mp2);
1241 }
1242 return 0;
1243
1244 case UM_SETUP:
1245 if (!dcd) {
1246 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1247 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1248 return 0;
1249 }
1250 else {
1251 if (!dcd->hwndObject) {
1252 /*
1253 * first time through -- set things up
1254 */
1255 CNRINFO cnri;
1256
1257# ifdef FORTIFY
1258 Fortify_EnterScope();
1259# endif
1260
1261 RestorePresParams(hwnd, "TreeCnr");
1262 memset(&cnri, 0, sizeof(CNRINFO));
1263 cnri.cb = sizeof(CNRINFO);
1264 WinSendMsg(hwnd,
1265 CM_QUERYCNRINFO,
1266 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1267 cnri.cyLineSpacing = 0;
1268 cnri.cxTreeIndent = 12;
1269 cnri.pSortRecord = (PVOID) SortTreeCnr;
1270 cnri.flWindowAttr &= (~(CV_NAME | CV_DETAIL | CV_TEXT));
1271 cnri.flWindowAttr |= (CV_TREE | CA_TREELINE | CV_ICON | CV_MINI);
1272 {
1273 ULONG size = sizeof(ULONG);
1274
1275 PrfQueryProfileData(fmprof,
1276 appname,
1277 "TreeflWindowAttr",
1278 (PVOID) & cnri.flWindowAttr, &size);
1279 size = sizeof(MASK);
1280 *dcd->mask.prompt = 0;
1281 if (!*dcd->mask.szMask && !dcd->mask.attrFile) {
1282 if (PrfQueryProfileSize(fmprof,
1283 appname, "TreeFilter", &size) && size) {
1284 PrfQueryProfileData(fmprof,
1285 appname, "TreeFilter", &dcd->mask, &size);
1286 SetMask(NULL, &dcd->mask);
1287 }
1288 else
1289 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1290 FILE_ARCHIVED | FILE_DIRECTORY |
1291 FILE_HIDDEN | FILE_SYSTEM);
1292 }
1293 dcd->mask.attrFile |= FILE_DIRECTORY;
1294 }
1295 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
1296 cnri.flWindowAttr |= CV_FLOW;
1297 dcd->flWindowAttr = cnri.flWindowAttr;
1298 WinSendMsg(hwnd,
1299 CM_SETCNRINFO,
1300 MPFROMP(&cnri),
1301 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1302 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1303 if (_beginthread(MakeObjWin, NULL, 327680, (PVOID) dcd) == -1) {
1304 Runtime_Error(pszSrcFile, __LINE__,
1305 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1306 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1307 // return 0;
1308 }
1309 else
1310 DosSleep(1);
1311# ifdef FORTIFY
1312 Fortify_LeaveScope();
1313# endif
1314 }
1315 }
1316 return 0;
1317
1318 case WM_BUTTON3CLICK:
1319 case WM_CHORD:
1320 {
1321 PCNRITEM pci = NULL;
1322 QUERYRECFROMRECT pqr;
1323 NOTIFYRECORDENTER nr;
1324 BOOL tbool = fDCOpens;
1325 RECTL rectl;
1326 POINTL ptl;
1327
1328 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1329 if (msg == WM_CHORD) {
1330 if (!WinQueryPointerPos(HWND_DESKTOP, &ptl))
1331 break;
1332 WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
1333 }
1334 else {
1335 ptl.x = SHORT1FROMMP(mp1);
1336 ptl.y = SHORT2FROMMP(mp1);
1337 }
1338 memset(&rectl, 0, sizeof(rectl));
1339 memset(&pqr, 0, sizeof(pqr));
1340 pqr.cb = sizeof(pqr);
1341 pqr.rect.xLeft = ptl.x - 1;
1342 pqr.rect.xRight = ptl.x + 1;
1343 pqr.rect.yTop = ptl.y + 1;
1344 pqr.rect.yBottom = ptl.y - 1;
1345 pqr.fsSearch = CMA_PARTIAL;
1346 pci = (PCNRITEM) WinSendMsg(hwnd,
1347 CM_QUERYRECORDFROMRECT,
1348 MPFROMLONG(CMA_FIRST), MPFROMP(&pqr));
1349 if (!pci || (INT) pci == -1)
1350 break; //Probable B3 click on white space Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1351 else {
1352 memset(&nr, 0, sizeof(nr));
1353 nr.hwndCnr = hwnd;
1354 nr.pRecord = (PRECORDCORE) pci;
1355 fDCOpens = TRUE;
1356 WinSendMsg(hwnd,
1357 WM_CONTROL,
1358 MPFROM2SHORT(WinQueryWindowUShort(hwnd,
1359 QWS_ID),
1360 CN_ENTER), MPFROMP(&nr));
1361 PostMsg(hwnd, UM_RESTOREDC, MPFROMLONG(tbool), MPVOID);
1362 }
1363 }
1364 break;
1365
1366 case UM_RESTOREDC:
1367 fDCOpens = (BOOL) mp1;
1368 return 0;
1369
1370 case WM_CONTROL:
1371 DosError(FERR_DISABLEHARDERR);
1372 if (dcd) {
1373 switch (SHORT2FROMMP(mp1)) {
1374 case CN_BEGINEDIT:
1375 case CN_REALLOCPSZ:
1376 case CN_ENDEDIT:
1377 {
1378 MRESULT mre;
1379
1380 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
1381 if (mre != (MRESULT) - 1)
1382 return mre;
1383 }
1384 break;
1385
1386 case CN_DRAGLEAVE:
1387 if (mp2) {
1388
1389 PDRAGINFO pDInfo;
1390
1391 // fixme to know why - seems superfluous
1392 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
1393 DrgAccessDraginfo(pDInfo);
1394 DrgFreeDraginfo(pDInfo);
1395 }
1396 return 0;
1397
1398 case CN_DRAGAFTER:
1399 case CN_DRAGOVER:
1400 if (mp2) {
1401
1402 PDRAGITEM pDItem;
1403 PDRAGINFO pDInfo;
1404 PCNRITEM pci;
1405 USHORT uso;
1406
1407 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
1408 if (!DrgAccessDraginfo(pDInfo)) {
1409 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
1410 "DrgAccessDraginfo");
1411 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
1412 }
1413 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
1414 if ((INT) pci == -1)
1415 pci = NULL;
1416 if (pci && (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODROP))) {
1417 DrgFreeDraginfo(pDInfo);
1418 return MRFROM2SHORT(DOR_NODROP, 0);
1419 }
1420 if (!WinIsWindowEnabled(dcd->hwndFrame)) {
1421 DrgFreeDraginfo(pDInfo);
1422 return MRFROM2SHORT(DOR_NODROP, 0);
1423 }
1424 if (pci) {
1425 uso = pDInfo->usOperation;
1426 if (uso == DO_DEFAULT)
1427 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
1428 if (!(pci->attrFile & FILE_DIRECTORY)) {
1429 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
1430 DrgFreeDraginfo(pDInfo);
1431 return (MRFROM2SHORT(DOR_NODROP, 0));
1432 }
1433 if (uso != DO_LINK &&
1434 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
1435 DRIVE_NOTWRITEABLE)) {
1436
1437 ARC_TYPE *info;
1438
1439 if (!fQuickArcFind &&
1440 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
1441 DRIVE_SLOW))
1442 info = find_type(pci->pszFileName, NULL);
1443 else
1444 info = quick_find_type(pci->pszFileName, NULL);
1445 if (!info || ((uso == DO_MOVE && !info->move) ||
1446 (uso == DO_COPY && !info->create))) {
1447 DrgFreeDraginfo(pDInfo);
1448 return (MRFROM2SHORT(DOR_NODROP, 0));
1449 }
1450 }
1451 }
1452 }
1453 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
1454 0); /* Index to DRAGITEM */
1455 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
1456 DRM_OS2FILE, /* mechanisms and data */
1457 NULL) || DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE)) { /* formats */
1458 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
1459 if (!pci || (INT) pci == -1)
1460 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
1461 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
1462 DRIVE_NOTWRITEABLE)
1463 return MRFROM2SHORT(DOR_DROP, DO_LINK);
1464 if (toupper(*pci->pszFileName) < 'C')
1465 return MRFROM2SHORT(DOR_DROP, DO_COPY);
1466 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
1467 ((fCopyDefault) ? DO_COPY : DO_MOVE));
1468 }
1469 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
1470 }
1471 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
1472
1473 case CN_INITDRAG:
1474 {
1475 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
1476 PCNRITEM pci;
1477
1478 if (!pcd) {
1479 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1480 break;
1481 }
1482 else {
1483 pci = (PCNRITEM) pcd->pRecord;
1484 if (!pci || (INT) pci == -1) {
1485 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1486 break;
1487 }
1488 if (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODRAG)) {
1489 Runtime_Error(pszSrcFile, __LINE__, "drag not allowed");
1490 break;
1491 }
1492 if (hwndStatus2) {
1493 WinSetWindowText(hwndStatus2, (IsRoot(pci->pszFileName)) ?
1494 GetPString(IDS_DRAGROOTTEXT) :
1495 (pci->attrFile & FILE_DIRECTORY) ?
1496 GetPString(IDS_DRAGDIRTEXT) :
1497 GetPString(IDS_DRAGFILETEXT));
1498 }
1499 DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE);
1500 if (hwndStatus2) {
1501 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1502 }
1503 }
1504 }
1505 return 0;
1506
1507 case CN_DROP:
1508 {
1509 LISTINFO *li;
1510 ULONG action = UM_ACTION;
1511
1512 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
1513 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
1514 if (li) {
1515 if (!*li->targetpath) {
1516 if (li->list[0])
1517 PMMkDir(dcd->hwndParent, li->list[0], FALSE);
1518 FreeListInfo(li);
1519 return 0;
1520 }
1521 if (li->list && li->list[0] && IsRoot(li->list[0]))
1522 li->type = DO_LINK;
1523 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
1524
1525 CHECKLIST cl;
1526
1527 memset(&cl, 0, sizeof(cl));
1528 cl.size = sizeof(cl);
1529 cl.flags = li->type;
1530 cl.list = li->list;
1531 cl.cmd = li->type;
1532 cl.prompt = li->targetpath;
1533 li->type = WinDlgBox(HWND_DESKTOP,
1534 dcd->hwndParent,
1535 DropListProc,
1536 FM3ModHandle, DND_FRAME, MPFROMP(&cl));
1537 if (li->type == DID_ERROR)
1538 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,
1539 "Drag & Drop Dialog");
1540 if (!li->type) {
1541 FreeListInfo(li);
1542 return 0;
1543 }
1544 li->list = cl.list;
1545 if (!li->list || !li->list[0]) {
1546 FreeListInfo(li);
1547 return 0;
1548 }
1549 }
1550 switch (li->type) {
1551 case DO_LINK:
1552 if (fLinkSetsIcon) {
1553 li->type = IDM_SETICON;
1554 action = UM_MASSACTION;
1555 }
1556 else
1557 li->type = IDM_COMPARE;
1558 break;
1559 case DND_EXTRACT:
1560 if (*li->targetpath && !IsFile(li->targetpath))
1561 li->type = IDM_EXTRACT;
1562 break;
1563 case DND_MOVE:
1564 li->type = IDM_MOVE;
1565 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1566 action = UM_MASSACTION;
1567 li->type = IDM_ARCHIVEM;
1568 }
1569 break;
1570 case DND_WILDMOVE:
1571 li->type = IDM_WILDMOVE;
1572 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1573 action = UM_MASSACTION;
1574 li->type = IDM_ARCHIVEM;
1575 }
1576 break;
1577 case DND_OBJECT:
1578 li->type = IDM_OBJECT;
1579 action = UM_MASSACTION;
1580 break;
1581 case DND_SHADOW:
1582 li->type = IDM_SHADOW;
1583 action = UM_MASSACTION;
1584 break;
1585 case DND_COMPARE:
1586 li->type = IDM_COMPARE;
1587 break;
1588 case DND_SETICON:
1589 action = UM_MASSACTION;
1590 li->type = IDM_SETICON;
1591 break;
1592 case DND_COPY:
1593 li->type = IDM_COPY;
1594 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1595 action = UM_MASSACTION;
1596 li->type = IDM_ARCHIVE;
1597 }
1598 break;
1599 case DND_WILDCOPY:
1600 li->type = IDM_WILDCOPY;
1601 if (*li->targetpath && IsFile(li->targetpath) == 1) {
1602 action = UM_MASSACTION;
1603 li->type = IDM_ARCHIVE;
1604 }
1605 break;
1606 default:
1607 if (*li->arcname && li->info) {
1608 action = UM_MASSACTION;
1609 li->type = (li->type == DO_MOVE) ?
1610 IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
1611 }
1612 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
1613 action = UM_MASSACTION;
1614 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
1615 }
1616 else
1617 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
1618 break;
1619 }
1620 if (!li->list || !li->list[0])
1621 FreeListInfo(li);
1622 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
1623 FreeListInfo(li);
1624 else {
1625
1626 USHORT usop = 0;
1627
1628 switch (li->type) {
1629 case IDM_COPY:
1630 case IDM_WILDCOPY:
1631 usop = DO_COPY;
1632 break;
1633 case IDM_MOVE:
1634 case IDM_WILDMOVE:
1635 case IDM_ARCHIVEM:
1636 usop = DO_MOVE;
1637 break;
1638 }
1639 if (usop)
1640 return MRFROM2SHORT(DOR_DROP, usop);
1641 }
1642 }
1643 }
1644 return 0;
1645
1646 case CN_EMPHASIS:
1647 if (!fDummy) {
1648
1649 PNOTIFYRECORDEMPHASIS pre = mp2;
1650
1651 if (pre->fEmphasisMask & CRA_SELECTED) {
1652 if (pre->pRecord->flRecordAttr & CRA_SELECTED) {
1653 if (((PCNRITEM) (pre->pRecord))->attrFile & FILE_DIRECTORY) {
1654 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1655 if (fFollowTree &&
1656 !(driveflags
1657 [toupper(*((PCNRITEM) pre->pRecord)->pszFileName) -
1658 'A'] & DRIVE_INVALID)) {
1659 if (!LastDir && !ParentIsDesktop(hwnd, dcd->hwndParent))
1660 LastDir = FindDirCnr(dcd->hwndParent);
1661 if (LastDir) {
1662
1663 NOTIFYRECORDENTER pri;
1664 BOOL tbool = fDCOpens;
1665
1666 fDCOpens = FALSE;
1667 memset(&pri, 0, sizeof(pri));
1668 pri.hwndCnr = hwnd;
1669 pri.fKey = FALSE;
1670 pri.pRecord = pre->pRecord;
1671 WinSendMsg(hwnd,
1672 WM_CONTROL,
1673 MPFROM2SHORT(SHORT1FROMMP(mp1),
1674 CN_ENTER), MPFROMP(&pri));
1675 fDCOpens = tbool;
1676 }
1677 }
1678 if (*(ULONG *) realappname != FM3UL)
1679 WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
1680 MAIN_STATUS),
1681 ((PCNRITEM) (pre->pRecord))->pszFileName);
1682 }
1683 }
1684 }
1685 }
1686 break;
1687
1688 case CN_CONTEXTMENU:
1689 {
1690 PCNRITEM pci = (PCNRITEM) mp2;
1691 BOOL wasFollowing;
1692
1693 //DosEnterCritSec(); //GKY 11-28-08
1694 wasFollowing = fFollowTree;
1695 fFollowTree = FALSE;
1696 //DosExitCritSec();
1697 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
1698 WinSendMsg(hwnd,
1699 CM_SETRECORDEMPHASIS,
1700 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
1701 MarkAll(hwnd, FALSE, FALSE, TRUE);
1702 if (!(pci->attrFile & FILE_DIRECTORY))
1703 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
1704 else if (!IsRoot(pci->pszFileName))
1705 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
1706 else
1707 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
1708 }
1709 else {
1710 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP);
1711 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
1712 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1713 MPFROM2SHORT(TRUE, CRA_SOURCE));
1714 dcd->cnremphasized = TRUE;
1715 }
1716 }
1717 if (dcd->hwndLastMenu) {
1718 if (dcd->hwndLastMenu == DirMenu)
1719 WinEnableMenuItem(DirMenu, IDM_TREE, FALSE);
1720 if (dcd->hwndLastMenu == TreeCnrMenu) {
1721 if (dcd->flWindowAttr & CV_MINI)
1722 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
1723 }
1724 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
1725 if (dcd->cnremphasized) {
1726 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1727 MPFROM2SHORT(FALSE, CRA_SOURCE));
1728 dcd->cnremphasized = FALSE;
1729 }
1730 if (dcd->hwndLastMenu != TreeCnrMenu)
1731 MarkAll(hwnd, TRUE, FALSE, TRUE);
1732 }
1733 }
1734 //DosEnterCritSec(); //GKY 11-28-08
1735 fFollowTree = wasFollowing;
1736 //DosExitCritSec();
1737 }
1738 break;
1739
1740 case CN_ENTER:
1741 if (mp2) {
1742 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
1743
1744 PostMsg(hwnd, UM_ENTER, MPFROMP(pci), MPVOID);
1745 }
1746 break;
1747
1748 case CN_COLLAPSETREE:
1749 case CN_EXPANDTREE:
1750 {
1751 PCNRITEM pci = (PCNRITEM) mp2;
1752
1753 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
1754 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
1755
1756 struct
1757 {
1758 ULONG serial;
1759 CHAR volumelength;
1760 CHAR volumelabel[CCHMAXPATH];
1761 }
1762 volser;
1763
1764 memset(&volser, 0, sizeof(volser));
1765 DosError(FERR_DISABLEHARDERR);
1766 if (!DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
1767 FSIL_VOLSER, &volser,
1768 (ULONG) sizeof(volser))) {
1769 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
1770 !volser.serial ||
1771 driveserial[toupper(*pci->pszFileName) - 'A'] !=
1772 volser.serial)
1773 UnFlesh(hwnd, pci);
1774 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
1775 (!volser.serial ||
1776 driveserial[toupper(*pci->pszFileName) - 'A'] !=
1777 volser.serial)) {
1778 if (Flesh(hwnd, pci) &&
1779 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
1780 !dcd->suspendview && fTopDir)
1781 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
1782 }
1783 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
1784 }
1785 else {
1786 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
1787 UnFlesh(hwnd, pci);
1788 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1789 DosBeep(250, 100);
1790 }
1791 }
1792 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
1793 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
1794 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
1795 }
1796 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
1797 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
1798 }
1799 }
1800 break;
1801 } // switch WM_CONTROL
1802 }
1803 return 0;
1804
1805 case UM_ACTION:
1806 if (mp1) {
1807
1808 LISTINFO *li = mp1;
1809 ULONG action = (ULONG) mp2;
1810
1811 if (!li->list || !li->list[0] ||
1812 !PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
1813 FreeListInfo(li);
1814 }
1815 return 0;
1816
1817 case UM_SHOWME:
1818 if (mp1 && dcd) {
1819 CHAR *dir = xstrdup((CHAR *)mp1, pszSrcFile, __LINE__);
1820
1821 if (dir) {
1822 if (!PostMsg(dcd->hwndObject, UM_SHOWME, MPFROMP(dir), MPVOID))
1823 free(dir);
1824 }
1825 }
1826 return 0;
1827
1828 case UM_TOPDIR:
1829 if (mp1) {
1830
1831 PCNRITEM pci = (PCNRITEM) mp1;
1832
1833 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1834 }
1835 return 0;
1836
1837 case UM_ENTER:
1838 {
1839 FILEFINDBUF3 ffb;
1840 HDIR hDir = HDIR_CREATE;
1841 ULONG nm = 1;
1842 APIRET status;
1843 BOOL IsOk = FALSE;
1844 ULONG ulDriveNum, ulDriveMap;
1845 PCNRITEM pciP, pciL, pci;
1846 ULONG fl = SWP_ACTIVATE;
1847
1848 if (fFollowTree)
1849 fl = 0;
1850 SetShiftState();
1851 pci = (PCNRITEM) mp1;
1852 if (pci &&
1853 (INT) pci != -1 &&
1854 !(pci->rc.flRecordAttr & CRA_INUSE) &&
1855 !(pci->flags & RECFLAGS_ENV) && IsFullName(pci->pszFileName)) {
1856 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_INVALID) {
1857 DosBeep(50, 100);
1858 if (hwndStatus)
1859 WinSetWindowText(hwndStatus, GetPString(IDS_RESCANSUGTEXT));
1860 return 0;
1861 }
1862 DosError(FERR_DISABLEHARDERR);
1863 if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) {
1864 if (!(ulDriveMap & 1 << (toupper(*pci->pszFileName) - 'A'))) {
1865 pciL = pciP = pci;
1866 for (;;) {
1867 pciP = WinSendMsg(hwnd,
1868 CM_QUERYRECORD,
1869 MPFROMP(pciL),
1870 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
1871 if (pciP && (INT) pciP != -1)
1872 pciL = pciP;
1873 else {
1874 pciP = pciL;
1875 break;
1876 }
1877 } // for
1878 RemoveCnrItems(hwnd, pciP, 1, CMA_FREE | CMA_INVALIDATE);
1879 return 0;
1880 }
1881 }
1882 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
1883 (DRIVE_REMOVABLE | DRIVE_NOPRESCAN)) {
1884
1885 struct
1886 {
1887 ULONG serial;
1888 CHAR volumelength;
1889 CHAR volumelabel[CCHMAXPATH];
1890 }
1891 volser;
1892
1893 pciL = pciP = pci;
1894 for (;;) {
1895 pciP = WinSendMsg(hwnd,
1896 CM_QUERYRECORD,
1897 MPFROMP(pciL),
1898 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
1899 if (pciP && (INT) pciP != -1)
1900 pciL = pciP;
1901 else {
1902 pciP = pciL;
1903 break;
1904 }
1905 }
1906 if ((driveflags[toupper(*pci->pszFileName) - 'A'] &
1907 DRIVE_NOPRESCAN) ||
1908 (toupper(*pci->pszFileName) > 'B' &&
1909 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
1910 DRIVE_CDROM))) {
1911
1912 INT removable, x = (INT) (toupper(*pci->pszFileName) - 'A');
1913 ULONG drvtype;
1914 CHAR FileSystem[CCHMAXPATH];
1915
1916 DosError(FERR_DISABLEHARDERR);
1917 removable = CheckDrive(toupper(*pciP->pszFileName),
1918 FileSystem, &drvtype);
1919 if (removable != -1) {
1920 driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN |
1921 DRIVE_NOLOADICONS | DRIVE_NOLOADSUBJS |
1922 DRIVE_NOLOADLONGS | DRIVE_INCLUDEFILES |
1923 DRIVE_SLOW | DRIVE_NOSTATS);
1924
1925 if (removable == 1)
1926 driveflags[x] |= DRIVE_REMOVABLE;
1927 if (drvtype & DRIVE_REMOTE)
1928 driveflags[x] |= DRIVE_REMOTE;
1929 if (!strcmp(FileSystem, CBSIFS)) {
1930 driveflags[x] |= DRIVE_ZIPSTREAM;
1931 driveflags[x] &= (~DRIVE_REMOTE);
1932 }
1933 if(!strcmp(FileSystem,NDFS32)) {
1934 driveflags[x] |= DRIVE_VIRTUAL;
1935 driveflags[x] &= (~DRIVE_REMOTE);
1936 }
1937 if(!strcmp(FileSystem,RAMFS)) {
1938 driveflags[x] |= DRIVE_RAMDISK;
1939 driveflags[x] &= (~DRIVE_REMOTE);
1940 }
1941 if (!strcmp(FileSystem, CDFS) || !strcmp(FileSystem, ISOFS))
1942 driveflags[x] |= (DRIVE_REMOVABLE |
1943 DRIVE_NOTWRITEABLE | DRIVE_CDROM);
1944 if(!strcmp(FileSystem,NTFS))
1945 driveflags[x] |= DRIVE_NOTWRITEABLE;
1946 if (strcmp(FileSystem, HPFS) &&
1947 strcmp(FileSystem, JFS) &&
1948 strcmp(FileSystem, CDFS) &&
1949 strcmp(FileSystem, ISOFS) &&
1950 strcmp(FileSystem, RAMFS) &&
1951 strcmp(FileSystem, FAT32) &&
1952 strcmp(FileSystem, NDFS32) &&
1953 strcmp(FileSystem, NTFS) &&
1954 strcmp(FileSystem, HPFS386)) {
1955 driveflags[x] |= DRIVE_NOLONGNAMES;
1956 }
1957 SelectDriveIcon(pciP);
1958 WinSendMsg(hwnd,
1959 CM_INVALIDATERECORD,
1960 MPFROMP(&pciP),
1961 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
1962 if (hwndMain)
1963 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
1964 }
1965 }
1966 memset(&volser, 0, sizeof(volser));
1967 DosError(FERR_DISABLEHARDERR);
1968 status = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
1969 FSIL_VOLSER, &volser,
1970 (ULONG) sizeof(volser));
1971 if (!status) {
1972 if (!volser.serial ||
1973 driveserial[toupper(*pci->pszFileName) - 'A'] !=
1974 volser.serial) {
1975 UnFlesh(hwnd, pciP);
1976 Flesh(hwnd, pciP);
1977 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
1978 }
1979 pciL = WinSendMsg(hwnd,
1980 CM_QUERYRECORD,
1981 MPFROMP(pciP),
1982 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
1983 if (!pciL)
1984 Flesh(hwnd, pciP);
1985 }
1986 else {
1987 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
1988 UnFlesh(hwnd, pci);
1989 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1990 PostMsg(hwnd, UM_SETUP2, MPFROMP(pci), MPFROMLONG(status));
1991 return 0;
1992 }
1993 }
1994 status = 0;
1995 IsOk = (IsRoot(pci->pszFileName) &&
1996 IsValidDrive(toupper(*pci->pszFileName)));
1997 if (!IsOk) {
1998 DosError(FERR_DISABLEHARDERR);
1999 status = DosFindFirst(pci->pszFileName, &hDir,
2000 FILE_NORMAL | FILE_DIRECTORY |
2001 FILE_ARCHIVED | FILE_READONLY |
2002 FILE_HIDDEN | FILE_SYSTEM,
2003 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
2004 priority_bumped();
2005 }
2006 if (!status) {
2007 if (!IsOk)
2008 DosFindClose(hDir);
2009 if (IsOk || (ffb.attrFile & FILE_DIRECTORY)) {
2010 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT)) {
2011 PostMsg(hwnd,
2012 WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
2013 return 0;
2014 }
2015 if ((shiftstate & (KC_CTRL | KC_SHIFT)) == (KC_CTRL | KC_SHIFT)) {
2016 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
2017 return 0;
2018 }
2019 if (!(shiftstate & (KC_CTRL | KC_SHIFT))) {
2020 if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
2021 if (FindDirCnrByName(pci->pszFileName, TRUE))
2022 return 0;
2023 }
2024 }
2025 if ((shiftstate & KC_CTRL) ||
2026 (!(shiftstate & KC_SHIFT) &&
2027 ParentIsDesktop(hwnd, dcd->hwndParent) && fVTreeOpensWPS)) {
2028
2029 ULONG size = sizeof(ULONG), flWindowAttr = CV_ICON;
2030 CHAR s[33];
2031
2032 strcpy(s, "ICON");
2033 PrfQueryProfileData(fmprof,
2034 appname,
2035 "DirflWindowAttr",
2036 (PVOID) & flWindowAttr, &size);
2037 if (flWindowAttr & CV_DETAIL) {
2038 if (IsRoot(pci->pszFileName))
2039 strcpy(s, "TREE");
2040 else
2041 strcpy(s, "DETAILS");
2042 }
2043 OpenObject(pci->pszFileName, s, dcd->hwndFrame);
2044 return 0;
2045 }
2046 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2047 !fDCOpens && !LastDir && !(shiftstate & KC_SHIFT))
2048 LastDir = FindDirCnr(dcd->hwndParent);
2049 if (LastDir && !fDCOpens && !(shiftstate & KC_SHIFT)) {
2050 WinSendMsg(LastDir,
2051 UM_SETDIR, MPFROMP(pci->pszFileName), MPVOID);
2052 WinSetWindowPos(WinQueryWindow(WinQueryWindow(LastDir,
2053 QW_PARENT),
2054 QW_PARENT),
2055 HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | fl);
2056 }
2057 else
2058 OpenDirCnr(hwnd,
2059 dcd->hwndParent,
2060 dcd->hwndFrame, FALSE, pci->pszFileName);
2061 }
2062 else {
2063 if (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
2064 DRIVE_INCLUDEFILES))
2065 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE);
2066 else {
2067
2068 SWP swp;
2069
2070 WinQueryWindowPos(dcd->hwndFrame, &swp);
2071 DefaultViewKeys(hwnd,
2072 dcd->hwndFrame,
2073 dcd->hwndParent, &swp, pci->pszFileName);
2074 }
2075 }
2076 }
2077 else {
2078 if (!IsRoot(pci->pszFileName)) {
2079 NotifyError(pci->pszFileName, status);
2080 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE);
2081 }
2082 }
2083 }
2084 else if (!pci)
2085 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
2086 if (fFollowTree)
2087 WinSetFocus(HWND_DESKTOP, hwnd);
2088 }
2089 return 0;
2090
2091 case WM_MENUEND:
2092 if (dcd) {
2093
2094 HWND hwndMenu = (HWND) mp2;
2095
2096 if (hwndMenu == TreeCnrMenu || hwndMenu == TreeMenu ||
2097 hwndMenu == DirMenu) {
2098 MarkAll(hwnd, TRUE, FALSE, TRUE);
2099 if (dcd->cnremphasized) {
2100 WinSendMsg(hwnd,
2101 CM_SETRECORDEMPHASIS,
2102 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2103 dcd->cnremphasized = FALSE;
2104 }
2105 }
2106 }
2107 break;
2108
2109 case UM_OPENWINDOWFORME:
2110 if (dcd) {
2111 if (mp1 && !IsFile((CHAR *)mp1))
2112 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
2113 }
2114 return 0;
2115
2116 case MM_PORTHOLEINIT:
2117 if (dcd) {
2118 switch (SHORT1FROMMP(mp1)) {
2119 case 0:
2120 case 1:
2121 {
2122 ULONG wmsg;
2123
2124 wmsg = ((SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU);
2125 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
2126 wmsg, MPVOID, MPVOID), mp1, mp2);
2127 }
2128 break;
2129 }
2130 }
2131 break;
2132
2133 case UM_INITMENU:
2134 case WM_INITMENU:
2135 if (dcd) {
2136 switch (SHORT1FROMMP(mp1)) {
2137 case IDM_FILESMENU:
2138 {
2139 PCNRITEM pci;
2140
2141 pci = (PCNRITEM) CurrentRecord(hwnd);
2142 if (pci && (INT) pci != -1) {
2143 BOOL rdy;
2144 BOOL writeable;
2145 BOOL removable;
2146 BOOL remote;
2147 BOOL underenv;
2148 CHAR chDrvU;
2149 CHAR szDrv[CCHMAXPATH];
2150
2151 strcpy(szDrv, pci->pszFileName);
2152 chDrvU = *pci->pszFileName;
2153 chDrvU = toupper(chDrvU);
2154 MakeValidDir(szDrv);
2155 rdy = *szDrv == chDrvU; // Drive not ready if MakeValidDir changes drive letter
2156 removable = rdy
2157 && (driveflags[chDrvU - 'A'] & DRIVE_REMOVABLE) != 0;
2158 writeable = rdy
2159 && !(driveflags[chDrvU - 'A'] & DRIVE_NOTWRITEABLE);
2160 remote = rdy && (driveflags[chDrvU - 'A'] & (DRIVE_REMOTE || DRIVE_VIRTUAL)) == 0;
2161 underenv = (pci->flags & RECFLAGS_UNDERENV) != 0;
2162
2163 CopyPresParams((HWND) mp2, hwndMainMenu);
2164 WinEnableMenuItem((HWND) mp2, IDM_INFO, rdy);
2165
2166 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, writeable);
2167 WinEnableMenuItem((HWND) mp2, IDM_EAS, writeable);
2168 WinEnableMenuItem((HWND) mp2, IDM_SUBJECT, writeable);
2169 WinEnableMenuItem((HWND) mp2, IDM_DRVFLAGS, 1); // fixme to allow if not ready
2170
2171 WinEnableMenuItem((HWND) mp2, IDM_ARCHIVE, rdy);
2172
2173 WinEnableMenuItem((HWND) mp2, IDM_UPDATE, !underenv);
2174 WinEnableMenuItem((HWND) mp2, IDM_EXPANDSUBMENU, !underenv);
2175 WinEnableMenuItem((HWND) mp2, IDM_EXPAND, !underenv);
2176 WinEnableMenuItem((HWND) mp2, IDM_COLLAPSE, !underenv);
2177
2178 WinEnableMenuItem((HWND) mp2, IDM_SIZES, rdy);
2179 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, writeable);
2180 WinEnableMenuItem((HWND) mp2, IDM_SHOWALLFILES, rdy);
2181 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, writeable);
2182
2183 WinEnableMenuItem((HWND) mp2, IDM_CHKDSK, writeable && !remote);
2184 WinEnableMenuItem((HWND) mp2, IDM_FORMAT, writeable && !remote);
2185 WinEnableMenuItem((HWND) mp2, IDM_OPTIMIZE, writeable && !remote);
2186 WinEnableMenuItem((HWND) mp2, IDM_PARTITIONSMENU, !remote);
2187
2188 WinEnableMenuItem((HWND) mp2, IDM_DETACH, remote);
2189
2190 WinEnableMenuItem((HWND) mp2, IDM_EJECT, removable);
2191
2192 WinEnableMenuItem((HWND) mp2, IDM_LOCK, removable);
2193 WinEnableMenuItem((HWND) mp2, IDM_UNLOCK, removable);
2194
2195 WinEnableMenuItem((HWND) mp2, IDM_DELETE, !underenv && writeable);
2196 WinEnableMenuItem((HWND) mp2, IDM_PERMDELETE, !underenv
2197 && writeable);
2198 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, !underenv
2199 && writeable);
2200 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, !underenv
2201 && writeable);
2202 WinEnableMenuItem((HWND) mp2, IDM_RENAME, !underenv && writeable);
2203
2204 }
2205 }
2206 break;
2207
2208 case IDM_VIEWSMENU:
2209 WinCheckMenuItem((HWND) mp2,
2210 IDM_MINIICONS, ((dcd->flWindowAttr & CV_MINI) != 0));
2211 CopyPresParams((HWND) mp2, hwndMainMenu);
2212 WinEnableMenuItem((HWND) mp2, IDM_RESELECT, FALSE);
2213 break;
2214
2215 case IDM_COMMANDSMENU:
2216 SetupCommandMenu((HWND) mp2, hwnd);
2217 CopyPresParams((HWND) mp2, hwndMainMenu);
2218 break;
2219
2220 case IDM_SORTSUBMENU:
2221 SetSortChecks((HWND) mp2, TreesortFlags);
2222 CopyPresParams((HWND) mp2, hwndMainMenu);
2223 break;
2224
2225 case IDM_WINDOWSMENU:
2226 SetupWinList((HWND) mp2,
2227 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
2228 CopyPresParams((HWND) mp2, hwndMainMenu);
2229 break;
2230 }
2231 dcd->hwndLastMenu = (HWND) mp2;
2232 }
2233 if (msg == WM_INITMENU)
2234 break;
2235 return 0;
2236
2237 case UM_COMMAND:
2238 if (!mp1)
2239 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2240 else {
2241 if (!dcd) {
2242 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2243 FreeListInfo((LISTINFO *) mp1);
2244 }
2245 else {
2246 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
2247 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2248 FreeListInfo((LISTINFO *) mp1);
2249 }
2250 else
2251 return (MRESULT) TRUE;
2252 }
2253 }
2254 return 0;
2255
2256 case UM_LOADFILE:
2257 if (dcd && mp2) {
2258
2259 HWND hwnd;
2260
2261 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
2262 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
2263 (CHAR *)mp2, dcd->hwndFrame);
2264 else
2265 hwnd = StartMLEEditor(dcd->hwndParent,
2266 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
2267 free((CHAR *)mp2);
2268 return MRFROMLONG(hwnd);
2269 }
2270 return 0;
2271
2272 case UM_FIXCNRMLE:
2273 case UM_FIXEDITNAME:
2274 return CommonCnrProc(hwnd, msg, mp1, mp2);
2275
2276 case UM_NOTIFY:
2277 if (mp2)
2278 Notify((CHAR *)mp2);
2279 return 0;
2280
2281 case UM_FILTER:
2282 if (dcd) {
2283
2284 BOOL tempsusp = dcd->suspendview;
2285
2286 if (mp1) {
2287 DosEnterCritSec();
2288 SetMask((CHAR *)mp1, &dcd->mask);
2289 DosExitCritSec();
2290 }
2291 dcd->suspendview = TRUE;
2292 dcd->mask.attrFile |= FILE_DIRECTORY;
2293 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2294 dcd->suspendview = tempsusp;
2295 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2296 }
2297 return 0;
2298
2299 case UM_DRIVECMD:
2300 if (mp1)
2301 ShowTreeRec(hwnd, (CHAR *)mp1, FALSE, TRUE);
2302 return 0;
2303
2304 case WM_APPTERMINATENOTIFY:
2305 {
2306 APPNOTIFY *info;
2307 PCNRITEM pci;
2308 CHAR s[] = " :\\";
2309
2310 if (!mp2) {
2311 if (hwndMain)
2312 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
2313 }
2314 info = apphead;
2315 while (info) {
2316 if (info->happ == (HAPP) mp1) {
2317 *s = info->device;
2318 pci = FindCnrRecord(hwnd, s, NULL, FALSE, FALSE, TRUE);
2319 if (pci && (INT) pci != -1) {
2320 driveserial[info->device - 'A'] = -1;
2321 DriveFlagsOne(info->device - 'A');
2322 if (driveflags[info->device - 'A'] &
2323 (DRIVE_INVALID | DRIVE_IGNORE))
2324 RemoveCnrItems(hwnd, pci, 1, CMA_FREE);
2325 else
2326 Flesh(hwnd, pci);
2327 }
2328 if (info->prev)
2329 info->prev->next = info->next;
2330 if (info->next)
2331 info->next->prev = info->prev;
2332 if (apphead == info)
2333 apphead = info->next;
2334 if (apptail == info)
2335 apptail = info->prev;
2336 free(info);
2337 break;
2338 }
2339 info = info->next;
2340 }
2341 }
2342 break;
2343
2344 case WM_COMMAND:
2345 DosError(FERR_DISABLEHARDERR);
2346 if (dcd) {
2347 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2348 return 0;
2349 switch (SHORT1FROMMP(mp1)) {
2350 case IDM_SETTARGET:
2351 SetTargetDir(hwnd, FALSE);
2352 break;
2353
2354 case IDM_DETACH:
2355 {
2356 CHAR d[3] = " :";
2357 PCNRITEM pci;
2358 PROGDETAILS pgd;
2359 CHAR params[368], *p;
2360 HAPP happ;
2361
2362 pci = (PCNRITEM) CurrentRecord(hwnd);
2363 if (pci && (INT) pci != -1 && isalpha(*pci->pszFileName)) {
2364 *d = toupper(*pci->pszFileName);
2365 p = GetCmdSpec(FALSE);
2366 memset(&pgd, 0, sizeof(pgd));
2367 pgd.Length = sizeof(pgd);
2368 pgd.progt.progc = PROG_WINDOWABLEVIO;
2369 pgd.progt.fbVisible = SHE_VISIBLE;
2370 pgd.pszTitle = GetPString(IDS_DETACHREQUESTTEXT);
2371 pgd.pszExecutable = p;
2372 pgd.pszParameters = params;
2373 pgd.pszStartupDir = NULL;
2374 pgd.pszIcon = NULL;
2375 pgd.pszEnvironment = NULL;
2376 pgd.swpInitial.hwndInsertBehind = HWND_TOP;
2377 pgd.swpInitial.hwnd = hwnd;
2378 pgd.swpInitial.fl = SWP_SHOW | SWP_ACTIVATE;
2379 sprintf(params, "/C NET USE %s /D", d);
2380 happ = WinStartApp(hwnd, &pgd, pgd.pszParameters,
2381 NULL, SAF_MAXIMIZED);
2382 if (!happ) {
2383 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, hwnd,
2384 GetPString(IDS_ERRORTEXT),
2385 GetPString(IDS_CANTSTARTTEXT), p, params);
2386 }
2387 else {
2388 APPNOTIFY *info;
2389
2390 info = xmallocz(sizeof(APPNOTIFY), pszSrcFile, __LINE__);
2391 if (info) {
2392 info->happ = happ;
2393 info->device = *d;
2394 if (!apphead)
2395 apphead = info;
2396 else {
2397 apptail->next = info;
2398 info->prev = apptail;
2399 }
2400 apptail = info;
2401 }
2402 }
2403 }
2404 }
2405 break;
2406
2407 case IDM_REMAP:
2408 WinDlgBox(HWND_DESKTOP, hwnd, RemapDlgProc,
2409 FM3ModHandle, MAP_FRAME, NULL);
2410 break;
2411
2412 case IDM_CONTEXTMENU:
2413 {
2414 PCNRITEM pci;
2415
2416 pci = (PCNRITEM) CurrentRecord(hwnd);
2417 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
2418 MPFROMP(pci));
2419 }
2420 break;
2421
2422 case IDM_FINDINTREE:
2423 {
2424 PSZ pszTempDir;
2425 PCNRITEM pci;
2426
2427 pci = (PCNRITEM) CurrentRecord(hwnd);
2428 if (pci && (INT) pci != -1) {
2429 pszTempDir = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
2430 if (pszTempDir)
2431 MakeValidDir(pszTempDir);
2432 }
2433 else
2434 pszTempDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
2435 if (pszTempDir) {
2436 if (WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2437 WalkAllDlgProc,
2438 FM3ModHandle, WALK_FRAME, MPFROMP(pszTempDir))) {
2439 if (!WinSendMsg(hwnd, UM_SHOWME, MPFROMP(pszTempDir), MPFROMLONG(1)))
2440 free(pszTempDir);
2441 }
2442 else
2443 free(pszTempDir);
2444 }
2445 }
2446 break;
2447
2448 case IDM_BEGINEDIT:
2449 OpenEdit(hwnd);
2450 break;
2451
2452 case IDM_ENDEDIT:
2453 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
2454 break;
2455
2456 case IDM_FILTER:
2457 {
2458 BOOL empty = FALSE;
2459 PCNRITEM pci;
2460
2461 pci = (PCNRITEM) CurrentRecord(hwnd);
2462 if (!*dcd->mask.szMask)
2463 empty = TRUE;
2464 dcd->mask.fIsTree = TRUE;
2465 *dcd->mask.prompt = 0;
2466 if (pci && (INT) pci != -1)
2467 dcd->mask.fFilesIncluded =
2468 ((driveflags[toupper(*pci->pszFileName) - 'A'] &
2469 DRIVE_INCLUDEFILES) != 0);
2470 else
2471 dcd->mask.fFilesIncluded = FALSE;
2472 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2473 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2474 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2475 else if (empty)
2476 *dcd->mask.szMask = 0;
2477 PrfWriteProfileData(fmprof, appname, "TreeFilter", &dcd->mask,
2478 sizeof(MASK));
2479 }
2480 break;
2481
2482 case IDM_SHOWSORT:
2483 QuickPopup(hwnd, dcd, CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP),
2484 IDM_SORTSUBMENU);
2485 break;
2486
2487 case IDM_SHOWSELECT:
2488 QuickPopup(hwnd, dcd, CheckMenu(hwndMainMenu, &TreeCnrMenu, TREECNR_POPUP),
2489 IDM_SELECTSUBMENU);
2490 break;
2491
2492 case IDM_TREECNRVIEWSETTINGS:
2493 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
2494 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_TREECNRVIEWSETTINGS), mp2);
2495 else {
2496 WinDlgBox(HWND_DESKTOP,
2497 hwnd,
2498 CfgDlgProc,
2499 FM3ModHandle,
2500 CFG_FRAME,
2501 MPFROMLONG(IDM_TREECNRVIEWSETTINGS));
2502 }
2503 break;
2504
2505 case IDM_WALKDIR:
2506 case IDM_OPENWALK:
2507 {
2508 CHAR newpath[CCHMAXPATH];
2509 PCNRITEM pci;
2510
2511 pci = (PCNRITEM) CurrentRecord(hwnd);
2512 if (pci && (INT) pci != -1) {
2513 strcpy(newpath, pci->pszFileName);
2514 MakeValidDir(newpath);
2515 }
2516 else
2517 strcpy(newpath, pFM2SaveDirectory);
2518 if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkAllDlgProc,
2519 FM3ModHandle, WALK_FRAME,
2520 MPFROMP(newpath)) || !*newpath)
2521 break;
2522 WinSendMsg(hwnd, UM_OPENWINDOWFORME, MPFROMP(newpath), MPVOID);
2523 }
2524 break;
2525
2526 case IDM_HELP:
2527 if (hwndHelp) {
2528 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
2529 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
2530 else
2531 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
2532 }
2533 break;
2534
2535 case IDM_PARTITION:
2536 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2537 NULL, NULL,
2538 "%s", "MINILVM.EXE");
2539 break;
2540
2541 case IDM_PARTITIONDF:
2542 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2543 NULL, NULL,
2544 "%s", "DFSOS2.EXE");
2545 break;
2546
2547 case IDM_PARTITIONLVMG:
2548 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2549 NULL, NULL,
2550 "%s", "LVMGUI.CMD");
2551 break;
2552
2553 case IDM_PARTITIONFD:
2554 runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
2555 NULL, NULL,
2556 "%s", "FDISKPM.EXE");
2557 break;
2558
2559 case IDM_SORTNAME:
2560 case IDM_SORTFILENAME:
2561 case IDM_SORTSIZE:
2562 case IDM_SORTEASIZE:
2563 case IDM_SORTFIRST:
2564 case IDM_SORTLAST:
2565 case IDM_SORTLWDATE:
2566 case IDM_SORTLADATE:
2567 case IDM_SORTCRDATE:
2568 TreesortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
2569 case IDM_SORTDIRSFIRST:
2570 case IDM_SORTDIRSLAST:
2571 case IDM_SORTREVERSE:
2572 switch (SHORT1FROMMP(mp1)) {
2573 case IDM_SORTFILENAME:
2574 TreesortFlags |= SORT_FILENAME;
2575 break;
2576 case IDM_SORTSIZE:
2577 TreesortFlags |= SORT_SIZE;
2578 break;
2579 case IDM_SORTEASIZE:
2580 TreesortFlags |= SORT_EASIZE;
2581 break;
2582 case IDM_SORTFIRST:
2583 TreesortFlags |= SORT_FIRSTEXTENSION;
2584 break;
2585 case IDM_SORTLAST:
2586 TreesortFlags |= SORT_LASTEXTENSION;
2587 break;
2588 case IDM_SORTLWDATE:
2589 TreesortFlags |= SORT_LWDATE;
2590 break;
2591 case IDM_SORTLADATE:
2592 TreesortFlags |= SORT_LADATE;
2593 break;
2594 case IDM_SORTCRDATE:
2595 TreesortFlags |= SORT_CRDATE;
2596 break;
2597 case IDM_SORTDIRSFIRST:
2598 if (TreesortFlags & SORT_DIRSFIRST)
2599 TreesortFlags &= (~SORT_DIRSFIRST);
2600 else {
2601 TreesortFlags |= SORT_DIRSFIRST;
2602 TreesortFlags &= (~SORT_DIRSLAST);
2603 }
2604 break;
2605 case IDM_SORTDIRSLAST:
2606 if (TreesortFlags & SORT_DIRSLAST)
2607 TreesortFlags &= (~SORT_DIRSLAST);
2608 else {
2609 TreesortFlags |= SORT_DIRSLAST;
2610 TreesortFlags &= (~SORT_DIRSFIRST);
2611 }
2612 break;
2613 case IDM_SORTREVERSE:
2614 if (TreesortFlags & SORT_REVERSE)
2615 TreesortFlags &= (~SORT_REVERSE);
2616 else
2617 TreesortFlags |= SORT_REVERSE;
2618 break;
2619 }
2620 PrfWriteProfileData(fmprof, appname, "TreeSort", &TreesortFlags,
2621 sizeof(INT));
2622 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
2623 break;
2624
2625 case IDM_COLLECT:
2626 if (!Collector) {
2627
2628 HWND hwndC;
2629 SWP swp;
2630
2631 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2632 !fAutoTile &&
2633 (!fExternalCollector && *(ULONG *) realappname == FM3UL))
2634 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2635 hwndC = StartCollector((fExternalCollector ||
2636 *(ULONG *) realappname != FM3UL) ?
2637 HWND_DESKTOP : dcd->hwndParent, 4);
2638 if (hwndC) {
2639 if (!ParentIsDesktop(hwnd,
2640 dcd->hwndParent) &&
2641 !fAutoTile &&
2642 (!fExternalCollector && *(ULONG *) realappname == FM3UL))
2643 WinSetWindowPos(hwndC,
2644 HWND_TOP,
2645 swp.x,
2646 swp.y,
2647 swp.cx,
2648 swp.cy,
2649 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
2650 else if (!ParentIsDesktop(hwnd,
2651 dcd->hwndParent) &&
2652 fAutoTile && *(ULONG *) realappname == FM3UL)
2653 TileChildren(dcd->hwndParent, TRUE);
2654 }
2655 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
2656 DosSleep(100);//05 Aug 07 GKY 250
2657 }
2658 else
2659 StartCollector(dcd->hwndParent, 4);
2660 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2661 break;
2662
2663 case IDM_COLLECTOR:
2664 DosSleep(32);//05 Aug 07 GKY 64
2665 {
2666 CHAR **list;
2667
2668 list = BuildList(hwnd);
2669 if (list) {
2670 if (Collector) {
2671 if (!PostMsg(Collector, WM_COMMAND,
2672 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2673 FreeList(list);
2674 }
2675 else
2676 FreeList(list);
2677 }
2678 }
2679 break;
2680
2681 case IDM_COLLAPSEALL:
2682 WinSendMsg(hwnd, CM_COLLAPSETREE, MPVOID, MPVOID);
2683 break;
2684
2685 case IDM_COLLAPSE:
2686 case IDM_EXPAND:
2687 {
2688 PCNRITEM pci = NULL;
2689
2690 pci = (PCNRITEM) CurrentRecord(hwnd);
2691 if (pci && (INT) pci != -1) {
2692 if (pci->flags & RECFLAGS_UNDERENV)
2693 break;
2694 PostMsg(dcd->hwndObject, UM_EXPAND, mp1, MPFROMP(pci));
2695 }
2696 }
2697 break;
2698
2699 case IDM_UPDATE:
2700 {
2701 PCNRITEM pci = (PCNRITEM)CurrentRecord(hwnd);
2702 if (pci && (INT)pci != -1) {
2703 UINT driveflag = driveflags[toupper(*pci->pszFileName) - 'A'];
2704 if (pci->attrFile & FILE_DIRECTORY) {
2705 if (pci->flags & RECFLAGS_UNDERENV)
2706 break;
2707 UnFlesh(hwnd, pci);
2708 // Check if drive type might need update
2709 if ((driveflag & (DRIVE_INVALID | DRIVE_NOPRESCAN)) ||
2710 (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno))
2711 {
2712 driveflags[toupper(*pci->pszFileName) - 'A'] &=
2713 (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
2714 DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | DRIVE_NOSTATS);
2715 DriveFlagsOne(toupper(*pci->pszFileName) - 'A');
2716 driveflag = driveflags[toupper(*pci->pszFileName) - 'A'];
2717 if (driveflag & DRIVE_INVALID)
2718 pci->rc.hptrIcon = hptrDunno;
2719 else {
2720 SelectDriveIcon(pci);
2721 }
2722 WinSendMsg(hwnd,
2723 CM_INVALIDATERECORD,
2724 MPFROMP(&pci),
2725 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2726 if (hwndMain)
2727 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
2728 }
2729 if (~driveflag & DRIVE_INVALID)
2730 Flesh(hwnd, pci);
2731 }
2732 }
2733 }
2734 break;
2735
2736 case IDM_RESCAN:
2737 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
2738 break;
2739
2740 case IDM_RESORT:
2741 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
2742 break;
2743
2744 case IDM_TEXT:
2745 case IDM_MINIICONS:
2746 {
2747 CNRINFO cnri;
2748
2749 memset(&cnri, 0, sizeof(CNRINFO));
2750 cnri.cb = sizeof(CNRINFO);
2751 WinSendMsg(hwnd,
2752 CM_QUERYCNRINFO,
2753 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
2754 if (SHORT1FROMMP(mp1) == IDM_MINIICONS) {
2755 if (cnri.flWindowAttr & CV_MINI)
2756 cnri.flWindowAttr &= (~CV_MINI);
2757 else
2758 cnri.flWindowAttr |= CV_MINI;
2759 }
2760 else {
2761 if (cnri.flWindowAttr & CV_TEXT) {
2762 cnri.flWindowAttr &= (~CV_TEXT);
2763 cnri.flWindowAttr |= CV_ICON;
2764 }
2765 else {
2766 cnri.flWindowAttr &= (~CV_ICON);
2767 cnri.flWindowAttr |= CV_TEXT;
2768 }
2769 }
2770 dcd->flWindowAttr = cnri.flWindowAttr;
2771 PrfWriteProfileData(fmprof,
2772 appname,
2773 "TreeflWindowAttr",
2774 &cnri.flWindowAttr, sizeof(ULONG));
2775 WinSendMsg(hwnd,
2776 CM_SETCNRINFO,
2777 MPFROMP(&cnri),
2778 MPFROMLONG(CMA_FLWINDOWATTR | CMA_TREEICON |
2779 CMA_SLTREEBITMAPORICON));
2780 }
2781 break;
2782
2783 case IDM_SIZES:
2784 case IDM_DRVFLAGS:
2785 case IDM_SHOWALLFILES:
2786 case IDM_UNDELETE:
2787 case IDM_OPTIMIZE:
2788 case IDM_CHKDSK:
2789 case IDM_FORMAT:
2790 case IDM_MKDIR:
2791 case IDM_LOCK:
2792 case IDM_UNLOCK:
2793 case IDM_EJECT:
2794 case IDM_CLOSETRAY:
2795 {
2796 PCNRITEM pci;
2797
2798 pci = (PCNRITEM) CurrentRecord(hwnd);
2799 if (pci && (INT) pci != -1)
2800 CommonDriveCmd(hwnd, pci->pszFileName, SHORT1FROMMP(mp1));
2801 }
2802 break;
2803
2804 case IDM_SAVETOLIST:
2805 WinDlgBox(HWND_DESKTOP,
2806 hwnd,
2807 SaveListDlgProc, FM3ModHandle, SAV_FRAME, MPFROMP(&hwnd));
2808 break;
2809
2810 case IDM_DELETE:
2811 case IDM_PERMDELETE:
2812 case IDM_MOVE:
2813 case IDM_WPSMOVE:
2814 case IDM_WILDMOVE:
2815 case IDM_RENAME:
2816 {
2817 PCNRITEM pci;
2818
2819 pci = (PCNRITEM) CurrentRecord(hwnd);
2820 if (pci && (INT) pci != -1) {
2821 if (pci->flags & RECFLAGS_UNDERENV)
2822 break;
2823 }
2824 }
2825 /* else intentional fallthru */
2826 case IDM_ATTRS:
2827 case IDM_INFO:
2828 case IDM_COPY:
2829 case IDM_WPSCOPY:
2830 case IDM_WILDCOPY:
2831 case IDM_DOITYOURSELF:
2832 case IDM_OPENWINDOW:
2833 case IDM_OPENSETTINGS:
2834 case IDM_OPENDEFAULT:
2835 case IDM_OPENICON:
2836 case IDM_OPENDETAILS:
2837 case IDM_OPENTREE:
2838 case IDM_SHADOW:
2839 case IDM_SHADOW2:
2840 case IDM_COMPARE:
2841 case IDM_VIEW:
2842 case IDM_VIEWTEXT:
2843 case IDM_VIEWBINARY:
2844 case IDM_EDIT:
2845 case IDM_EDITTEXT:
2846 case IDM_EDITBINARY:
2847 case IDM_EAS:
2848 case IDM_SUBJECT:
2849 case IDM_APPENDTOCLIP:
2850 case IDM_SAVETOCLIP:
2851 case IDM_ARCHIVE:
2852 case IDM_MCIPLAY:
2853 case IDM_UUDECODE:
2854 {
2855 LISTINFO *li;
2856 ULONG action = UM_ACTION;
2857# ifdef FORTIFY
2858 Fortify_EnterScope();
2859# endif
2860 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2861 if (li) {
2862 li->type = SHORT1FROMMP(mp1);
2863 li->hwnd = hwnd;
2864 li->list = BuildList(hwnd);
2865 if (!li->list || !li->list[0]) {
2866 free(li);
2867 break;
2868 }
2869 if (IsRoot(li->list[0])) {
2870 switch (SHORT1FROMMP(mp1)) {
2871 case IDM_MOVE:
2872 case IDM_COPY:
2873 case IDM_WILDCOPY:
2874 case IDM_WILDMOVE:
2875 case IDM_WPSMOVE:
2876 case IDM_WPSCOPY:
2877 case IDM_RENAME:
2878 case IDM_DELETE:
2879 case IDM_PERMDELETE:
2880 mp1 = MPFROM2SHORT(IDM_INFO, SHORT2FROMMP(mp1));
2881 li->type = IDM_INFO;
2882 }
2883 }
2884 switch (SHORT1FROMMP(mp1)) {
2885 case IDM_APPENDTOCLIP:
2886 case IDM_SAVETOCLIP:
2887 case IDM_ARCHIVE:
2888 case IDM_DELETE:
2889 case IDM_PERMDELETE:
2890 case IDM_ATTRS:
2891 case IDM_SHADOW:
2892 case IDM_SHADOW2:
2893 case IDM_DOITYOURSELF:
2894 case IDM_EAS:
2895 case IDM_VIEW:
2896 case IDM_VIEWTEXT:
2897 case IDM_VIEWBINARY:
2898 case IDM_EDIT:
2899 case IDM_EDITTEXT:
2900 case IDM_EDITBINARY:
2901 case IDM_MCIPLAY:
2902 action = UM_MASSACTION;
2903 }
2904 if (SHORT1FROMMP(mp1) == IDM_SHADOW ||
2905 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2906 *li->targetpath = 0;
2907 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2908 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2909 FreeListInfo(li);
2910 }
2911 }
2912# ifdef FORTIFY
2913 Fortify_LeaveScope();
2914# endif
2915 }
2916 break;
2917
2918 default:
2919 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2920 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2921
2922 INT x;
2923
2924 if (!cmdloaded)
2925 load_commands();
2926 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2927 if (x >= 0) {
2928 x++;
2929 RunCommand(hwnd, x);
2930 if (fUnHilite)
2931 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2932 }
2933 }
2934 break;
2935 }
2936 }
2937 return 0;
2938
2939 case WM_SAVEAPPLICATION:
2940 if (dcd && !ParentIsDesktop(hwnd, dcd->hwndParent)) {
2941
2942 SWP swp, swpP;
2943 INT ratio;
2944
2945 WinQueryWindowPos(dcd->hwndFrame, &swp);
2946 if (!(swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE | SWP_HIDE))) {
2947 WinQueryWindowPos(dcd->hwndParent, &swpP);
2948 if (swp.cx) {
2949 ratio = (swpP.cx * 100) / swp.cx;
2950 if (ratio > 0)
2951 PrfWriteProfileData(fmprof, appname, "TreeWindowRatio",
2952 &ratio, sizeof(INT));
2953 }
2954 }
2955 }
2956 else if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
2957
2958 SWP swp;
2959
2960 WinQueryWindowPos(dcd->hwndFrame, &swp);
2961 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
2962 WinStoreWindowPos(FM2Str, "VTreeWindowPos", dcd->hwndFrame);
2963 }
2964 break;
2965
2966 case UM_MINIMIZE:
2967 if (dcd && hwndMain) {
2968 fOkayMinimize = TRUE;
2969 if (dcd->hwndObject && !fDummy) {
2970 DosSleep(50);//05 Aug 07 GKY 100
2971 if (!fDummy) {
2972 fOkayMinimize = FALSE;
2973 WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
2974 dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0,
2975 SWP_MINIMIZE | SWP_DEACTIVATE);
2976 }
2977 }
2978 }
2979 return 0;
2980
2981 case UM_MAXIMIZE:
2982 if (dcd || hwndMain)
2983 WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
2984 dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0, SWP_MAXIMIZE |
2985 SWP_SHOW);
2986 return 0;
2987
2988 case UM_CLOSE:
2989 {
2990 HWND hwndParent = WinQueryWindow(WinQueryWindow(WinQueryWindow(hwnd,
2991 QW_PARENT),
2992 QW_PARENT), QW_PARENT);
2993
2994 if (!mp1) {
2995 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
2996 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
2997 if (hwndParent && !ParentIsDesktop(hwnd, hwndParent))
2998 WinDestroyWindow(hwndParent);
2999 }
3000 else
3001 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3002 QW_PARENT));
3003 }
3004 return 0;
3005
3006 case WM_CLOSE:
3007 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3008 if (dcd)
3009 dcd->stopflag++;
3010 if (dcd && dcd->hwndObject) {
3011 /* kill object window */
3012 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3013 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
3014 }
3015 else
3016 WinSendMsg(hwnd, UM_CLOSE, MPFROMLONG(1), MPVOID);
3017 return 0;
3018
3019 case WM_DESTROY:
3020 if (TreeCnrMenu)
3021 WinDestroyWindow(TreeCnrMenu);
3022 if (DirMenu)
3023 WinDestroyWindow(DirMenu);
3024 if (FileMenu)
3025 WinDestroyWindow(FileMenu);
3026 TreeCnrMenu = FileMenu = DirMenu = (HWND) 0;
3027 EmptyCnr(hwnd);
3028 if (apphead) {
3029 APPNOTIFY *info, *next;
3030 info = apphead;
3031 while (info) {
3032 next = info->next;
3033 free(info);
3034 info = next;
3035 }
3036 apphead = apptail = NULL;
3037 }
3038# ifdef FORTIFY
3039 // if (dcd)
3040 // Fortify_ChangeScope(dcd, -1);
3041 Fortify_LeaveScope();
3042 // if (dcd)
3043 // Fortify_ChangeScope(dcd, -1);
3044# endif
3045 break; // WM_DESTROY
3046 } // switch
3047 if (dcd && dcd->oldproc){
3048 return dcd->oldproc(hwnd, msg, mp1, mp2);
3049 }
3050 else
3051 return PFNWPCnr(hwnd, msg, mp1, mp2);
3052}
3053
3054HWND StartTreeCnr(HWND hwndParent, ULONG flags)
3055{
3056 /* bitmapped flags:
3057 * 0x00000001 = don't close app when window closes
3058 * 0x00000002 = no frame controls
3059 * 0x00000004 = no close or move button
3060 */
3061
3062 HWND hwndFrame = NULLHANDLE;
3063 HWND hwndSysMenu = NULLHANDLE;
3064 HWND hwndClient;
3065 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3066 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3067 DIRCNRDATA *dcd;
3068
3069 if (!hwndParent)
3070 hwndParent = HWND_DESKTOP;
3071 if (ParentIsDesktop(hwndParent, hwndParent))
3072 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3073 if (flags & 2)
3074 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3075 FCF_MINMAX | FCF_ICON));
3076 hwndFrame = WinCreateStdWindow(hwndParent,
3077 WS_VISIBLE,
3078 &FrameFlags,
3079 WC_TREECONTAINER,
3080 NULL,
3081 WS_VISIBLE | fwsAnimate,
3082 FM3ModHandle, TREE_FRAME, &hwndClient);
3083 if (hwndParent != HWND_DESKTOP) {
3084 hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
3085 if (hwndSysMenu != NULLHANDLE)
3086 WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
3087 MPFROM2SHORT(SC_CLOSE, TRUE),
3088 MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
3089 if (!fFreeTree)
3090 WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
3091 MPFROM2SHORT(SC_MOVE, TRUE),
3092 MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
3093 }
3094 if (hwndFrame && hwndClient) {
3095# ifdef FORTIFY
3096 Fortify_EnterScope();
3097# endif
3098 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3099 if (!dcd) {
3100 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_OUTOFMEMORY));
3101 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3102 hwndFrame = (HWND) 0;
3103 }
3104 else {
3105 SWP swp;
3106 WinQueryWindowPos(hwndFrame, &swp);
3107 if (*(ULONG *) realappname == FM3UL) {
3108 if (!WinCreateWindow(hwndFrame,
3109 WC_TREEOPENBUTTON,
3110 "#303",
3111 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | BS_BITMAP,
3112 ((swp.cx -
3113 WinQuerySysValue(HWND_DESKTOP,
3114 SV_CXMINMAXBUTTON)) -
3115 WinQuerySysValue(HWND_DESKTOP,
3116 SV_CXMINMAXBUTTON) / 2) -
3117 WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER),
3118 (swp.cy -
3119 WinQuerySysValue(HWND_DESKTOP,
3120 SV_CYMINMAXBUTTON)) -
3121 WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER),
3122 WinQuerySysValue(HWND_DESKTOP,
3123 SV_CXMINMAXBUTTON) / 2,
3124 WinQuerySysValue(HWND_DESKTOP,
3125 SV_CYMINMAXBUTTON), hwndFrame,
3126 HWND_TOP, IDM_OPENWINDOW, NULL, NULL)) {
3127 Win_Error2(hwndFrame, hwndParent, pszSrcFile, __LINE__,
3128 IDS_WINCREATEWINDOW);
3129 }
3130 }
3131 else {
3132 if (!WinCreateWindow(hwndFrame,
3133 WC_TREESTATUS,
3134 GetPString(IDS_YOUAREHERETEXT),
3135 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER,
3136 swp.x + 4 + WinQuerySysValue(HWND_DESKTOP,
3137 SV_CXSIZEBORDER),
3138 swp.cy - (22 + WinQuerySysValue(HWND_DESKTOP,
3139 SV_CYSIZEBORDER)),
3140 (swp.cx - 8) - (WinQuerySysValue(HWND_DESKTOP,
3141 SV_CXSIZEBORDER)
3142 * 2), 22, hwndFrame, HWND_TOP,
3143 MAIN_STATUS, NULL, NULL)) {
3144 Win_Error2(hwndFrame, hwndParent, pszSrcFile, __LINE__,
3145 IDS_WINCREATEWINDOW);
3146 }
3147 }
3148 memset(dcd, 0, sizeof(DIRCNRDATA));
3149 dcd->size = sizeof(DIRCNRDATA);
3150 dcd->type = TREE_FRAME;
3151 dcd->dontclose = ((flags & 1) != 0);
3152 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3153 dcd->hwndClient = hwndClient;
3154 dcd->hwndFrame = hwndFrame;
3155 {
3156 PFNWP oldproc;
3157
3158 oldproc = WinSubclassWindow(hwndFrame, TreeFrameWndProc);
3159 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3160 oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3161 (PFNWP) TreeTitleWndProc);
3162 WinSetWindowPtr(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3163 QWL_USER, (PVOID) oldproc);
3164 }
3165 dcd->hwndCnr = WinCreateWindow(hwndClient,
3166 WC_CONTAINER,
3167 NULL,
3168 CCS_AUTOPOSITION | CCS_MINIICONS |
3169 CCS_MINIRECORDCORE | WS_VISIBLE,
3170 0,
3171 0,
3172 0,
3173 0,
3174 hwndClient,
3175 HWND_TOP, (ULONG) TREE_CNR, NULL, NULL);
3176 if (!dcd->hwndCnr) {
3177 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3178 IDS_WINCREATEWINDOW);
3179 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3180 free(dcd);
3181 dcd = 0;
3182 hwndFrame = (HWND) 0;
3183 }
3184 else {
3185 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3186 if (ParentIsDesktop(hwndFrame, hwndParent)) {
3187 WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "VTree");
3188 FixSwitchList(hwndFrame, "VTree");
3189 }
3190 else {
3191 WinSetWindowText(hwndFrame, GetPString(IDS_TREETEXT));
3192 WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR),
3193 GetPString(IDS_TREETEXT));
3194 }
3195 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr, TreeCnrWndProc);
3196 // DbgMsg(pszSrcFile, __LINE__, "oldproc subclass %X", dcd->oldproc); // 05 Jul 07 SHL
3197 // fixme to document 01 test?
3198 if (dcd->oldproc == 0)
3199 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
3200 "WinSubclassWindow");
3201 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3202 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3203 }
3204 }
3205# ifdef FORTIFY
3206 if (dcd)
3207 Fortify_ChangeScope(dcd, -1);
3208 Fortify_LeaveScope();
3209 if (dcd)
3210 Fortify_ChangeScope(dcd, +1);
3211# endif
3212 }
3213 return hwndFrame;
3214}
3215
3216#pragma alloc_text(TREECNR,TreeCnrWndProc,TreeObjWndProc,TreeClientWndProc)
3217#pragma alloc_text(TREECNR,TreeFrameWndProc,TreeTitleWndProc,ShowTreeRec)
3218#pragma alloc_text(TREECNR,TreeStatProc,OpenButtonProc)
3219#pragma alloc_text(STARTUP,StartTreeCnr)
Note: See TracBrowser for help on using the repository browser.