关于MFC中ToolBar鼠标悬停提示的问题
程序结构是这样:主窗体CMainFrame、菜单(为什么用SPY++抓的时候显示的是ToolBar?),我现在要在菜单下面加一行ToolBar,我用的是CTrueColorToolBar这个类,图片可以出现,为了实现悬停提示,我在CTrueColorToolBar中 .h中声明:CToolTipCtrl tip;和virtual BOOL CDemo2View::PreTranslateMessage(MSG* pMsg);
.cpp中实现:
BOOL CDemo2View::PreTranslateMessage(MSG* pMsg)
{
if(tip.m_hWnd)
tip.RelayEvent(pMsg);
return CDialog::PreTranslateMessage(pMsg);
}
然后在CMainFrame中创建工具条时
if (!m_toolbarMain.CreateEx(this, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT,
WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP
| CBRS_TOOLTIPS) ||
!m_toolbarMain.LoadToolBar(IDR_TOOLBAR_MAINBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_toolbarMain.SetHeight(30);
m_toolbarMain.LoadTrueColorToolBar(24, IDB_BITMAP_NORMAL, IDB_BITMAP_HOT, IDB_BITMAP_HOT);
下面 m_toolbarMain.tip.Create(&m_toolbarMain);
m_toolbarMain.tip.Activate(TRUE);
EnableToolTips(TRUE);
CRect rect1(0,0,50,50); //设置提示区域1
m_toolbarMain.tip.AddTool(this,"tooltip",&rect1,1); //添加提示区域1
CRect rect2(100,100,150,150); //设置提示区域2
m_toolbarMain.tip.AddTool(this,"tooltip",&rect2,1); //添加提示区域2
为什么悬停提示出不来? 还有鼠标移到ToolBar上面的菜单栏时会出现悬停提示,汗.. m_toobarMain是我在CMainFrame中声明的CTrueColorToolBar对象。 怎么解决?有没有更好的ToolBar类推荐一下,我只需要实现图片和悬停提示。谢谢,分不多..