source: trunk/dll/treecnr.c@ 1402

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

Remove variable aurgs from docopy & unlinkf (not used); Move more strings to PCSZs and string table; Move PCSZs to compile time initialization; Fix hang on startup caused by a drive scan and a dircnr scan trying to update a drive in the tree at the same time (related to the "treeswitch options); Code cleanup mainly removal of old printfs, SayMsgs, DbgMsg and unneeded %s.

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