求教:在对话框上有几个button,如何实现当鼠标移到button上时,提示该button的功能?

loopyifly 2003-01-07 02:54:41
是否是加入对WM_MOUSEMOVE的处理?
如何处理?

多谢先!!
...全文
74 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
loopyifly 2003-01-07
  • 打赏
  • 举报
回复
多谢friends1979(liuxia)
问题已经解决
loopyifly 2003-01-07
  • 打赏
  • 举报
回复
TO winne_ll(feiyang) :
给点注释,该函数实现什么功能,没找到与某个button ID关联的语句,如何实现当鼠标移到该button上出现提示。 m_MouseOnButton 是什么变量,编译通不过
winne_ll 2003-01-07
  • 打赏
  • 举报
回复
void CSaimButton::OnMouseMove(UINT nFlags, CPoint point)
{
CButton::OnMouseMove(nFlags, point);

// 如果是鼠标左键按下去则什么都不用作
if (nFlags & MK_LBUTTON && m_MouseOnButton == FALSE)
{
ReleaseCapture();
return;
}

//CWnd* pWnd; // Finestra attiva
CWnd* pParent; // Finestra che contiene il bottone

//pWnd = GetActiveWindow();
pParent = GetOwner();

if ((GetCapture() != this) && (pParent != NULL))
{
m_MouseOnButton = TRUE;
SetCapture();
Invalidate();
}
else
{
//根据鼠标指针获取当前视,如果不是它自已就使MouseOn 为FALSE
POINT p2 = point;
ClientToScreen(&p2);
CWnd* wndUnderMouse = WindowFromPoint(p2);
if (wndUnderMouse && wndUnderMouse->m_hWnd != this->m_hWnd)
{
// Redraw only if mouse goes out
if (m_MouseOnButton == TRUE)
{
m_MouseOnButton = FALSE;
Invalidate();
}
// If user is NOT pressing left button then release capture!
if (!(nFlags & MK_LBUTTON)) ReleaseCapture();
}
}
}
friends1979 2003-01-07
  • 打赏
  • 举报
回复
那你可以用CToolTipCtrl呀!

定义一个全局变量 CToolTipCtrl m_tooltip;
在程序初始化中加入:
m_tooltip.Create(this);
m_tooltip.AddTool((CButton *)GetDlgItem(IDC_BUTTON2),"this is a tooltip");

响应BOOL CYourDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class

switch(pMsg->message)
{
case WM_MOUSEMOVE:
m_tooltip.RelayEvent(pMsg);

}
return CDialog::PreTranslateMessage(pMsg);
}


这样就可以了
Luxm 2003-01-07
  • 打赏
  • 举报
回复
用CToolTipCtrl吧
loopyifly 2003-01-07
  • 打赏
  • 举报
回复
必须继承CButton类吗?

如果直接给对话框添加WM_MOUSEMOVE消息函数OnMouseMove(UINT nFlags, CPoint point),想在该函数中处理,应该怎么处理?给个思路 谢谢

void CDialogTestDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default

int index, ht = HitTestEx(point, index); //获得鼠标所在区域

CDialog::OnMouseMove(nFlags, point);
}
arvid_gs 2003-01-07
  • 打赏
  • 举报
回复
自己写一个button类,在里面处理,
sinhighly 2003-01-07
  • 打赏
  • 举报
回复

是继承
sinhighly 2003-01-07
  • 打赏
  • 举报
回复
自建一个集成CButton的Button类,然后再处理WM_MOUSEMOVE

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧