source: trunk/dll/treecnr.c@ 1320

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

Use event semaphore to prevent rescan of drives while StubbySacnTreads are still running; code cleanup.

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