I have VS2010 Project which is an MFC dialog application which uses CToolTipCtrl for implementing tooltip on a CBitmapButton control. I have observed that when I hover my mouse for the first time on the CBitmapButton control, tooltip appears and after the time expires tooltip disappears. when I hover my mouse again on the same control tooltip never appears. I have attached my code here
------------CBitmapButtonWithTooltip.cpp--------------------
#include "stdafx.h"
#include "CBitmapButtonWithTooltip.h"
void CBitmapButtonWithTooltip::CreateToolTip(){
m_tt.Create(this, TTS_ALWAYSTIP);
m_tt.SetDelayTime(TTDT_AUTOPOP, 10000); // The time that the tip shows
m_tt.SetDelayTime(TTDT_INITIAL, 100); // The delay before the tip shows
m_tt.Activate(TRUE);
m_tt.AddTool(this, _T("ToolTip test with Cbitmap button"));
}
BOOL CBitmapButtonWithTooltip::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)
m_tt.RelayEvent(pMsg);
return CBitmapButton::PreTranslateMessage(pMsg);
}
------------CBitmapButtonWithTooltip.h--------------------
class CICBitmapButtonWithTooltip : public CBitmapButton{
public:
CToolTipCtrl m_tt;
CICBitmapButtonWithTooltip(CWnd* pParent = NULL);
~CICBitmapButtonWithTooltip();
void CreateToolTip();
BOOL PreTranslateMessage(MSG* pMsg);
DECLARE_MESSAGE_MAP()
};
I create an object and use as follows
CICBitmapButtonWithTooltip m_bButtonTip;m_bButtonTip.Create(NULL, WS_CHILD |BS_OWNERDRAW, CRect(0, 0, 48, 48), this, NULL);
m_bButtonTip.LoadBitmaps(IDB_BITMAP1);
m_bButtonTip.SetWindowPos(NULL, 50, 50, 48, 48, SWP_HIDEWINDOW);
m_bButtonTip.ShowWindow(SW_SHOW);
m_bButtonTip.CreateToolTip();