source: trunk/dll/treecnr.c@ 1213

Last change on this file since 1213 was 1213, checked in by John Small, 17 years ago

Ticket 187: Move data declarations/definitions out of fm3dll.h

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