下载此文档

第07章鼠标、键盘、计时器.ppt


文档分类:IT计算机 | 页数:约18页 举报非法文档有奖
1/18
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/18 下载此文档
文档列表 文档介绍
第7章鼠标、键盘、计时器
本章主要内容
鼠标的客户区消息和非客户区消息的处理
鼠标消息的捕获
处理键盘消息
  处理鼠标消息
根据产生鼠标消息时鼠标光标所处的位置,鼠标消息分为两类:
客户区鼠标消息
非客户区鼠标消息
  常用鼠标消息
  常用鼠标消息
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
MFC中,鼠标消息响应函数的原型一般为:
afx_msg void OnLButtonDown(
UINT nFlags, CPoint point );
掩码
产生鼠标消息时光标在窗口客户区的位置
 常用鼠标消息
 常用鼠标消息
 常用鼠标消息
afx_msg BOOL OnSetCursor( CWnd* pWnd,
UINT nHitTest, UINT message);
if( m_nMouseState == mapPan )
{
if( SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_HMOVE)) ) return TRUE ;
}
else if( m_nMouseState == mapZoomin )
{
if( SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_ZOOMIN)) )
return TRUE ;
}
else
{
if( ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)) )
return TRUE ;
}
如果鼠标处在应用程序窗口之外,还希望可以接受鼠标消息的话,则必须调用捕获鼠标消息函数:
CWnd* SetCapture();
完成了所应该做的工作之后,应用程序应该及时释放鼠标:
BOOL ReleaseCapture();
  捕获鼠标消息
  捕获鼠标消息举例
SetCapture();
//回到顺序编程
for (;;)
{ MSG msg;
VERIFY(::GetMessage(&msg, NULL, 0, 0));
case WM_LBUTTONDOWN: { }break;
case WM_MOUSEMOVE: { }break;
case WM_LBUTTONUP: { }break;
default: DispatchMessage(&msg); break;
}
ReleaseCapture();

第07章鼠标、键盘、计时器 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数18
  • 收藏数0 收藏
  • 顶次数0
  • 上传人mh900965
  • 文件大小377 KB
  • 时间2018-02-21