source: trunk/dll/treecnr.c@ 1552

Last change on this file since 1552 was 1552, checked in by Gregg Young, 15 years ago

Fixes a crash that occurs if you are quick enough to start a tree scan before the current scan is complete.

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