MFC写了一个让鼠标锁定在指定范围内的程序,但alt+tab切换窗口后就失效了怎么解决

RECT rect;
void CMyDlg::OnButton1()
{
// TODO: Add your control notification handler code here
rect.bottom=553;
rect.right=866;
rect.left=578;
rect.top=343;
::ClipCursor(&rect);
}
void CMyDlg::OnButton2()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if (m_mm==438)
{
ClipCursor(NULL);
}

}

因为你一切换,程序就失去焦点,外部消息就失效了
解决办法是使用全局钩子,你这类程序像监视键盘什么的都是用的这种技术
温馨提示:答案为网友推荐,仅供参考