source: trunk/dll/treecnr.c@ 872

Last change on this file since 872 was 872, checked in by Gregg Young, 18 years ago

Fix failure of font changes and font colors on main menus (tickets 27 & 162)

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