xml
<Window size="300,600" caption="0,0,180,30" roundcorner="5,5" sizebox="10,10,10,10" mininfo="280,70" maxinfo="300,700" >
响应消息:
LRESULT CSubtitleWindow::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
::ScreenToClient(*this, &pt);
RECT rcClient;
::GetClientRect(*this, &rcClient);
if (!::IsZoomed(*this))
{
RECT rcSizeBox = m_PaintManager.GetSizeBox(); // GetSizeBox用来获取xml中Window标签的sizebox属性,该属性指示你的鼠标移动到窗口边框多少个像素会变成指示符(这个指示符表示可以改变窗口大小的指示符)
if (pt.y < rcClient.top + rcSizeBox.top) {
if (pt.x < rcClient.left + rcSizeBox.left) return HTTOPLEFT;
if (pt.x > rcClient.right - rcSizeBox.right) return HTTOPRIGHT;
return HTTOP;
}
else if (pt.y > rcClient.bottom - rcSizeBox.bottom) {
if (pt.x < rcClient.left + rcSizeBox.left) return HTBOTTOMLEFT;
if (pt.x > rcClient.right - rcSizeBox.right) return HTBOTTOMRIGHT;
return HTBOTTOM;
}
if (pt.x < rcClient.left + rcSizeBox.left) return HTLEFT;
if (pt.x > rcClient.right - rcSizeBox.right) return HTRIGHT;
}
RECT rcCaption = m_PaintManager.GetCaptionRect();
if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.left + rcCaption.right\
&& pt.y >= rcCaption.top && pt.y < rcCaption.bottom) {
return HTCAPTION;
}
return HTCLIENT;
}