1.现将窗口设置为置于最顶层。
void xxxxxxx::OnPrepare()
{
::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
2.由于没有WM_MOUSEENTER事件,只有WM_MOUSELEAVE和WM_MOUSEMOVE事件,因此用这两个事件来模拟鼠标进出窗口的状态。
其中m_bMouseInClient 用来标志鼠标是否在窗口里面。
LRESULT xxxxxx::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (!m_bMouseInClient)
{
m_bMouseInClient = TRUE;
TRACKMOUSEEVENT tme = { sizeof(tme) };
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = m_hWnd;
TrackMouseEvent(&tme);
/*
鼠标进入窗口事件
*/
}
return 0;
}
LRESULT xxxxxxx::OnMouseLeave(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
m_bMouseInClient = FALSE;
/*
鼠标离开窗口事件
*/
return 0;
}