source: trunk/dll/treecnr.c@ 1477

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

Added semaphore in UM_SHOWME to prevent dbl directory listings in tree; Ticket 363

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