source: trunk/dll/treecnr.c@ 1426

Last change on this file since 1426 was 1426, checked in by Gregg Young, 16 years ago

Fix issue with name duplication in tree container when drive tree is accessed before a recursive scan is performed (Ticket 362)

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