View the DQSD CVS repository here:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/
Update of /cvsroot/dqsd/dqsd/src/DQSDTools
In directory usw-pr-cvs1:/tmp/cvs-serv8543/src/DQSDTools
Modified Files:
DQSDTools.rc MenuBuilder.cpp
Log Message:
Fix for bug 617639 (problems with tooltips on scrolling menus)
Index: DQSDTools.rc
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/DQSDTools.rc,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** DQSDTools.rc 3 Oct 2002 22:23:55 -0000 1.30
--- DQSDTools.rc 4 Oct 2002 08:52:59 -0000 1.31
***************
*** 55,60 ****
VS_VERSION_INFO VERSIONINFO
! FILEVERSION 3,1,4,1
! PRODUCTVERSION 3,1,4,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
--- 55,60 ----
VS_VERSION_INFO VERSIONINFO
! FILEVERSION 3,1,4,2
! PRODUCTVERSION 3,1,4,2
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
***************
*** 75,79 ****
VALUE "ContributingAuthors", "Koen Mannaerts (WhirlyWiryWeb.com), David
Bau (notesbydave.com), Glenn Carr (glenncarr.com), Will Dean (indcomp.co.uk)\0"
VALUE "FileDescription", "ActiveX Tools for Dave's Quick Search Bar \0"
! VALUE "FileVersion", "3, 1, 4, 1\0"
VALUE "InternalName", "DQSDTools\0"
VALUE "LegalCopyright", "Copyright (c) 2002 David Bau. GNU Public
License Version 2 applies.\0"
--- 75,79 ----
VALUE "ContributingAuthors", "Koen Mannaerts (WhirlyWiryWeb.com), David
Bau (notesbydave.com), Glenn Carr (glenncarr.com), Will Dean (indcomp.co.uk)\0"
VALUE "FileDescription", "ActiveX Tools for Dave's Quick Search Bar \0"
! VALUE "FileVersion", "3, 1, 4, 2\0"
VALUE "InternalName", "DQSDTools\0"
VALUE "LegalCopyright", "Copyright (c) 2002 David Bau. GNU Public
License Version 2 applies.\0"
***************
*** 83,87 ****
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "DQSDTools ActiveX Components\0"
! VALUE "ProductVersion", "3, 1, 4, 1\0"
VALUE "SpecialBuild", "\0"
END
--- 83,87 ----
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "DQSDTools ActiveX Components\0"
! VALUE "ProductVersion", "3, 1, 4, 2\0"
VALUE "SpecialBuild", "\0"
END
Index: MenuBuilder.cpp
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDTools/MenuBuilder.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** MenuBuilder.cpp 8 Jul 2002 10:32:04 -0000 1.15
--- MenuBuilder.cpp 4 Oct 2002 08:52:59 -0000 1.16
***************
*** 1,8 ****
--- 1,11 ----
// MenuBuilder.cpp : Implementation of CMenuBuilder
#include "stdafx.h"
+ #include <windowsx.h> // For GET_X_LPARAM, etc macros
+
#include "DQSDTools.h"
#include "MenuBuilder.h"
#include "Utilities.h"
+
/////////////////////////////////////////////////////////////////////////////
// CMenuBuilder
***************
*** 219,223 ****
)
{
! static BOOL bAdded[100];
if(uMsg == WM_INITMENUPOPUP)
--- 222,227 ----
)
{
! // static BOOL bAdded[500];
! static bool bAdded;
if(uMsg == WM_INITMENUPOPUP)
***************
*** 240,244 ****
}
}
! ZeroMemory(bAdded, sizeof(bAdded));
}
if(uMsg == WM_MENUSELECT)
--- 244,249 ----
}
}
! // ZeroMemory(bAdded, sizeof(bAdded));
! bAdded = false;
}
if(uMsg == WM_MENUSELECT)
***************
*** 259,262 ****
--- 264,270 ----
if(pThis != NULL && pThis->m_toolTips.count(itemId) > 0)
{
+
+ /*
+ Even worse! This doesn't work on scrolling menus...
// The GetMenuItemRect call requires the zero-based
position of the menu item
// Unfortunately, I only have the ID in this message
call.
***************
*** 274,277 ****
--- 282,311 ----
}
}
+ */
+ // It's worse than I thought.
+ // Because very long menus can scroll, nItemPosition
+needs to be relative
+ // to the topmost DISPLAYED item, rather than the top
+of the whole menu.
+ // I've resorted to hit-testing each item rectangle,
+to find the one that we want
+ // Because I'm too lazy to change the code, there's a
+redudant second look-up
+ // of the item rectangle after this loop completes.
+ POINT cursorPos;
+ DWORD messagePos = GetMessagePos();
+ cursorPos.x = GET_X_LPARAM(messagePos);
+ cursorPos.y = GET_Y_LPARAM(messagePos);
+
+ int nItems = GetMenuItemCount(hMenu);
+ int nItemPosition;
+ for(nItemPosition = 0; nItemPosition < nItems;
+nItemPosition++)
+ {
+ RECT itemRect;
+ GetMenuItemRect(NULL, hMenu, nItemPosition,
+&itemRect);
+ if(PtInRect(&itemRect, cursorPos))
+ {
+ // We've found our item
+ break;
+ }
+ }
+
+ // ATLTRACE("ItemId: %d\n", itemId);
// If we don't find it, nItemPosition will be ==
nItems, so the GetMenuItemRect call will fail
***************
*** 287,290 ****
--- 321,331 ----
ti.cbSize = sizeof(ti);
+ if(bAdded)
+ {
+ ::SendMessage(m_hTooltipWnd,
+TTM_GETTOOLINFO, 0, (LPARAM)&ti);
+ }
+
+ // Rectangle(GetDC(NULL), itemRect.left,
+itemRect.top, itemRect.right, itemRect.bottom);
+
POINT topLeft;
topLeft.x = itemRect.left;
***************
*** 295,299 ****
ti.uFlags = TTF_TRANSPARENT;
! ti.uId = itemId;
// This looks horrible, because I'm casting
away the const, but it's safe
--- 336,340 ----
ti.uFlags = TTF_TRANSPARENT;
! ti.uId = 1;
// This looks horrible, because I'm casting
away the const, but it's safe
***************
*** 301,317 ****
ti.lpszText =
(LPTSTR)(pThis->m_toolTips[itemId].c_str());
MapWindowPoints(NULL, ti.hwnd,
(LPPOINT)&itemRect, 2);
ti.rect = itemRect;
// ATLTRACE("ToolRect: (wnd %x) %d,%d,%d,%d\n",
ti.hwnd, ti.rect.left, ti.rect.top, ti.rect.right, ti.rect.bottom);
!
! if(bAdded[nItemPosition])
{
! ATLTRACE("Moving\n");
::SendMessage(m_hTooltipWnd,
TTM_NEWTOOLRECT, 0, (LPARAM)&ti);
}
else
{
! ATLTRACE("Adding\n");
if(!::SendMessage(m_hTooltipWnd,
TTM_ADDTOOL, 0, (LPARAM)&ti))
{
--- 342,376 ----
ti.lpszText =
(LPTSTR)(pThis->m_toolTips[itemId].c_str());
+ // char tipTraceBuffer[100];
+ // tipTraceBuffer[0] = '\0';
+ // strncat(tipTraceBuffer, ti.lpszText, 99);
+ // ATLTRACE("TipText: '%s'\n", tipTraceBuffer);
+
+ // Map the rectangle relative to the menu
+window
+ // RECT menuWindowRect;
+ // ::GetWindowRect(ti.hwnd, &menuWindowRect);
+ // ATLTRACE("Menu Window: %d,%d,%d,%d\n",
+menuWindowRect.left, menuWindowRect.top, menuWindowRect.right, menuWindowRect.bottom);
+
+ // itemRect.left -= menuWindowRect.left;
+ // itemRect.top -= menuWindowRect.top;
+ // itemRect.right -= menuWindowRect.left;
+ // itemRect.bottom -= menuWindowRect.top;
+
MapWindowPoints(NULL, ti.hwnd,
(LPPOINT)&itemRect, 2);
ti.rect = itemRect;
// ATLTRACE("ToolRect: (wnd %x) %d,%d,%d,%d\n",
ti.hwnd, ti.rect.left, ti.rect.top, ti.rect.right, ti.rect.bottom);
!
! if(bAdded)
{
! // ATLTRACE("Moving\n");
! ::SendMessage(m_hTooltipWnd,
TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
!
! ::SendMessage(m_hTooltipWnd,
TTM_SETTOOLINFO, 0, (LPARAM)&ti);
::SendMessage(m_hTooltipWnd,
TTM_NEWTOOLRECT, 0, (LPARAM)&ti);
}
else
{
! // ATLTRACE("Adding\n");
if(!::SendMessage(m_hTooltipWnd,
TTM_ADDTOOL, 0, (LPARAM)&ti))
{
***************
*** 320,324 ****
else
{
! bAdded[nItemPosition] = TRUE;
}
}
--- 379,383 ----
else
{
! bAdded = true;
}
}
***************
*** 328,333 ****
msgHere.hwnd = ti.hwnd;
msgHere.lParam = MAKELPARAM(ti.rect.left,
ti.rect.top);
! msgHere.pt.x = ti.rect.left;
! msgHere.pt.y = ti.rect.top;
::SendMessage(m_hTooltipWnd, TTM_RELAYEVENT,
0, (LPARAM)&msgHere);
}
--- 387,395 ----
msgHere.hwnd = ti.hwnd;
msgHere.lParam = MAKELPARAM(ti.rect.left,
ti.rect.top);
! msgHere.pt.x = ti.rect.left + 5;
! msgHere.pt.y = ti.rect.top + 5;
!
! // ATLTRACE("Sending mouse move %d,%d\n",
ti.rect.left, ti.rect.top);
!
::SendMessage(m_hTooltipWnd, TTM_RELAYEVENT,
0, (LPARAM)&msgHere);
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
DQSD-CVS mailing list
https://lists.sourceforge.net/lists/listinfo/dqsd-cvs
DQSD CVS repository:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/