急迫请求mfc钩子拦截鼠标消息的例子,原理,在线等待,十分感谢!!!
发布网友
发布时间:2024-10-04 15:19
我来回答
共2个回答
热心网友
时间:2024-10-08 22:42
void CKnob::OnLButtonDown(UINT nFlags, CPoint point)
{ // TODO: Add your message handler code here and/or call default
MSG msg;
::SetCapture(GetSafeHwnd());
while(::GetMessage(&msg, NULL, NULL, NULL))
{
CPoint ptTmp = (0,0);
if(::GetCapture() != GetSafeHwnd() )
break;
else if( msg.message <WM_MOUSEFIRST || msg.message >WM_MOUSELAST )
{ //如果是和鼠标无关的消息,
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else if( msg.message == WM_MOUSEMOVE)
{ //按住移动
ptTmp.x =(short)LOWORD(msg.lParam);
int iChangeValue = (ptTmp.x - point.x)/4 ;
m_iCurValue += iChangeValue;
CPoint ptTmp = (0,0);
ptTmp.x = (short)LOWORD(msg.lParam);
ptTmp.y = (short)HIWORD(msg.lParam);
SetValue(m_iCurValue);
CWnd::OnMouseMove(nFlags,point);
}
else if( msg.message == WM_LBUTTONUP)
{ //按住又松开
GetParent()->SendMessage(WM_KNOBVALUECHANGED,NULL,NULL);
ReleaseCapture();
break;
}
}
CWnd::OnLButtonDown(nFlags, point);
}
热心网友
时间:2024-10-08 22:40
看看孙鑫老师讲的那个视频吧