source: trunk/dll/treecnr.c@ 1352

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

Added seek and scan to directory context menu (Ticket 167)

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