source: trunk/dll/treecnr.c@ 1354

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

Added driveflags to over ride write verify for USB removable drives that fail when it is on (Ticket 323); A flag to prevent directory name from being broadcast to drives in the tree cnr prior to a recursive scan of the drive (causes dbl directory names Ticket 321) Add option for multithreaded recursive scan of user selected drives at startup (Ticket 322).

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