Exemplo n.º 1
0
	LRESULT CWin::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
		::ScreenToClient(m_hWnd, &pt);

		RECT rcClient;
		::GetClientRect(*this, &rcClient);

		if( !::IsZoomed(*this) ) {
			RECT rcSizeBox = GetPaintMgr()->GetSizeBox();
			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 = GetPaintMgr()->GetCaptionRect();
		//modify by dfn.li 2013-7-12 21:09
		RECT rcBottomCaption = GetPaintMgr()->GetBottomCaptionRect();
		bool bCaption = false;
		if( pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
			&& pt.y >= rcCaption.top && pt.y < rcCaption.bottom ) 
			bCaption = true;
		bool bBottomCaption = false;
		if ( pt.x >= rcClient.left + rcBottomCaption.left && pt.x < rcClient.right - rcBottomCaption.right \
			&& pt.y >= rcClient.bottom - rcBottomCaption.bottom && pt.y < rcClient.bottom )
			bBottomCaption = true;

		if( bCaption||bBottomCaption ) {
				CControlUI* pControl = static_cast<CControlUI*>(GetPaintMgr()->FindControl(pt));
				if (pControl)
				{
					if (pControl->IsClass(CControlUI::GetClassName()) ||
						pControl->IsClass(CChildLayoutUI::GetClassName()) ||
						pControl->IsClass(CHorizontalLayoutUI::GetClassName())||
						pControl->IsClass(CTabLayoutUI::GetClassName()) ||
						pControl->IsClass(CTileLayoutUI::GetClassName()) ||
						pControl->IsClass(CVerticalLayoutUI::GetClassName()) ||
						pControl->IsClass(CTextUI::GetClassName()) ||
						pControl->IsClass(CLabelUI::GetClassName()))
					{
						return HTCAPTION;
					}
					return HTCLIENT;
				}
				return HTCAPTION;	
		}
	
		return HTCLIENT;
	}