怎样用ToolTip控件提示鼠标当前的位置信息

zhaoyimin 2007-02-13 10:07:12
在CEdit派生类里,响应鼠标移动OnMouseMove得到坐标后,怎样在这个位置弹出ToolTip控件,并显示当前鼠标位置坐标呢?
谢谢。
...全文
402 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaoyimin 2007-02-13
  • 打赏
  • 举报
回复
牛人,佩服。
结帖送分:)
dazedase 2007-02-13
  • 打赏
  • 举报
回复
测试成功,方法如下:

在CMyEdit中建立成员CToolTipCtrl m_toolTips;

CMyEdit建立时
m_toolTips.Create(this); //建立Hint
m_toolTips.AddTool(this,"hint");

然后重载如下消息
BOOL CMyEdit::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
switch(pMsg->message)
{
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MOUSEMOVE:
m_toolTips.RelayEvent(pMsg);
}
return CEdit::PreTranslateMessage(pMsg);
}

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

CString str;
str.Format("%d:%d",point.x,point.y);

m_toolTips.UpdateTipText(str,this);
m_toolTips.Update();

CEdit::OnMouseMove(nFlags, point);
}

记得结贴:)

15,976

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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