VC让鼠标指到按钮上变成手型

两种方法: 
1、派生一个CButton类,然后重载OnSetCursor函数,在里面 
使用SetCursor函数设置鼠标指针。 
然后删除 
return CButton::OnSetCursor(pWnd, nHITTest, message); 
改成 
return TRUE; 

例如:
BOOL   CMyButton::OnSetCursor(CWnd*   pWnd,   UINT   nHITTest,   UINT   message)     
  {   
  ::SetCursor(::LoadCursor(NULL,   MAKEINTRESOURCE(IDC_HAND)));   
  return   TRUE;   
  } 

2、直接在程序里,响应WM_MOUSEMOVE消息,在里面判断鼠标指针是否指到了按钮上,是的话就用SetCursor函数设置鼠标指针,离开再设回以前的指针
void CbpmDlg::OnMouseMove(UINT nFlags, CPoint point)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	CRect adbanerRect;
	CRect  btnSelectPathRect;
	CRect  btnStartRect;
	m_GifPic.GetWindowRect(&adbanerRect);
	m_btnSelectPath.GetWindowRect(&btnSelectPathRect);
	m_btnStart.GetWindowRect(&btnStartRect);

	//如何鼠标在广告位置或按钮上,改变鼠标指针
	if(adbanerRect.PtInRect(point)||btnSelectPathRect.PtInRect(point)||btnStartRect.PtInRect(point))
	SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));

	CDialog::OnMouseMove(nFlags, point);
}
光有上面一个函数还是不行的,还需要重载CWnd类的虚拟函数PreTranslateMessage()
BOOL CbpmDlg::PreTranslateMessage(MSG *pMsg)
{
	if(pMsg->message == WM_MOUSEMOVE)
	{
		OnMouseMove(pMsg->wParam,pMsg->pt);
	}
	return CDialog::PreTranslateMessage(pMsg);
}

pretranslatemessage()作用和使用方法:点击打开链接
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
名称:MouseGesture(鼠标手势) 版本:1.0.0.2 大小:4904K 语言:简体中文 授权:免费软件 平台:Win8/Win7/Vista/Win2003/WinXP 简介: MouseGesture是一款Window系统辅助工具,可用于方便、快速、高效的管理所有窗口。您可以简单地通过不同手势来实现关闭、最小化、最大化、全部最小化、还原窗口、左移窗口和右移窗口的功能。 ------------------------------------------------------------------------------------------------- Introduction ------------------------------------------------------------------------------------------------- Welcome to the MouseGesture readme file. MouseGesture is a free tool that assist you to operate windows more quickly and effectively.With MouseGesture you can close, minimize, maximize, restore, left-move, right-move and minimize-all the windows just with your mouse moving. ------------------------------------------------------------------------------------------------------ What's new in MouseGesture 1.0.0.2 ? ------------------------------------------------------------------------------------------------------ * Optimized algorithms and operate more quickly * More accurate when judging the window * Add two browsers on which MouseGesture disable itself * Support for Windows 8 ------------------------------------------------------------------------------------------------- Features ------------------------------------------------------------------------------------------------- 1. Seven mouse-gesture actions associated with windows (Moving with RButton down) * Close a window (down-right) * minimize a window (down) * minimize all windows (down-left) * maximize a window (up) * restore a window (left-down) * left-move a window (left) * right-move a window (right) 2. Providing a using guide application for freshers 3. Enable you change the theme color as you like 4. Automatic launched with systems 5. Enable you shutdown MouseGesture temporarily if you need 6. Disable MouseGesture dynamically while you are surfing the Internet on web browser with it's own mousegestures. So far, 6 web browsers are in it. That is, Sougou explorer, QQBrowser, TheWorld, Maxthon and Opera.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值