鼠标移出窗口消息

请看源码,原理查MSDN中的TrackMouseEvent
void CMouseMoveDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
LPTRACKMOUSEEVENT lpET=new TRACKMOUSEEVENT; //一直是new?
lpET->cbSize=sizeof(TRACKMOUSEEVENT);
lpET->dwFlags=TME_LEAVE;
lpET->dwHoverTime=NULL;
lpET->hwndTrack=this->m_hWnd;
_TrackMouseEvent(lpET);
CDialog::OnMouseMove(nFlags, point);
}

BOOL CMouseMoveDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message==WM_MOUSELEAVE)
{
MessageBox("鼠标移出了窗体");
}
return CDialog::PreTranslateMessage(pMsg);
}

你可能感兴趣的:(窗口)