source: trunk/dll/treecnr.c@ 1316

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

Code clean up -- remove redundant code; move code to match openwatcom requirements etc.

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