|
-
April 8th, 2009, 09:14 PM
#1
CButton Tooltips dont popup intermittently
VS2005 C++ (v8.0.50727.867), WinXP SP2
I have a standard MFC CDialog with some CButtons. The CButtons are using CToolTipCtrl to display a popup tooltip box.
When my Program starts up, all the tooltips work fine.
When I click a Button, the Tooltip never pops up anymore.
Is there bug in CToolTipCtrl?
This happens in two of my MFC programs that use CToolTips differently. One of the programs is using the CButtonST class by Davide Calabro, the other Program is using the ToolTipButton class made by ?? (downloaded from codeguru or Codeproject) which is basically a class that adds tooltips to CButton.
It happens with Static buttons, and buttons created on the fly.
Here is the code from BtnST.cpp
Code:
void CButtonST::InitToolTip()
{
if (m_ToolTip.m_hWnd == NULL)
{
// Create ToolTip control
m_ToolTip.Create(this, m_dwToolTipStyle);
// Create inactive
m_ToolTip.Activate(FALSE);
// Enable multiline
m_ToolTip.SendMessage(TTM_SETMAXTIPWIDTH, 0, 400);
//m_ToolTip.SendMessage(TTM_SETTITLE, TTI_INFO, (LPARAM)_T("Title"));
} // if
}
void CButtonST::SetTooltipText(int nText, BOOL bActivate)
{
CString sText;
// Load string resource
sText.LoadString(nText);
// If string resource is not empty
if (sText.IsEmpty() == FALSE) SetTooltipText((LPCTSTR)sText, bActivate);
}
void CButtonST::SetTooltipText(LPCTSTR lpszText, BOOL bActivate)
{
// We cannot accept NULL pointer
if (lpszText == NULL) return;
// Initialize ToolTip
InitToolTip();
// If there is no tooltip defined then add it
if (m_ToolTip.GetToolCount() == 0)
{
CRect rectBtn;
GetClientRect(rectBtn);
m_ToolTip.AddTool(this, lpszText, rectBtn, 1);
} // if
// Set text for tooltip
m_ToolTip.UpdateTipText(lpszText, this, 1);
m_ToolTip.Activate(bActivate);
}
void CButtonST::ActivateTooltip(BOOL bActivate)
{
// If there is no tooltip then do nothing
if (m_ToolTip.GetToolCount() == 0) return;
// Activate tooltip
m_ToolTip.Activate(bActivate);
}
BOOL CButtonST::PreTranslateMessage(MSG* pMsg)
{
InitToolTip();
m_ToolTip.RelayEvent(pMsg);
if (pMsg->message == WM_LBUTTONDBLCLK)
pMsg->message = WM_LBUTTONDOWN;
return CButton::PreTranslateMessage(pMsg);
}
Last edited by Anarchi; April 9th, 2009 at 01:00 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|