LRESULT CbarDlg::OnNcHitTest(CPoint point) { // TODO: 在此添加消息處理程序代碼和/或調用默認值 const int borderwidth = 7; CRect rect; GetClientRect(rect); ScreenToClient(&point); if (point.y < borderwidth) { return HTTOP; } if (point.x < borderwidth) { return HTLEFT; } if(point.y > rect.bottom - rect.top - borderwidth && point.x > rect.right - rect.left - borderwidth) return HTBOTTOMRIGHT; if (point.y > rect.bottom - rect.top - borderwidth) { return HTBOTTOM; } if (point.x > rect.right - rect.left - borderwidth) { return HTRIGHT; } return HTCAPTION; //return CDialog::OnNcHitTest(point); } void CbarDlg::OnNcLButtonDown(UINT nHitTest, CPoint point) { // TODO: 在此添加消息處理程序代碼和/或調用默認值 // TODO: 在此添加消息處理程序代碼和/或調用默認值 if (nHitTest == HTTOP) SendMessage( WM_SYSCOMMAND, SC_SIZE | WMSZ_TOP, MAKELPARAM(point.x, point.y)); else if (nHitTest == HTBOTTOM) SendMessage( WM_SYSCOMMAND, SC_SIZE | WMSZ_BOTTOM, MAKELPARAM(point.x, point.y)); else if (nHitTest == HTLEFT) SendMessage( WM_SYSCOMMAND, SC_SIZE | WMSZ_LEFT, MAKELPARAM(point.x, point.y)); else if (nHitTest == HTRIGHT) SendMessage( WM_SYSCOMMAND, SC_SIZE | WMSZ_RIGHT, MAKELPARAM(point.x, point.y)); else if (nHitTest == HTTOPLEFT) SendMessage( WM_SYSCOMMAND, SC_SIZE | WMSZ_TOPLEFT, MAKELPARAM(point.x, point.y)); else if (nHitTest == HTTOPRIGHT) SendMessage( WM_SYSCOMMAND, SC_SIZE | WMSZ_TOPRIGHT, MAKELPARAM(point.x, point.y)); else if (nHitTest == HTBOTTOMLEFT) SendMessage( WM_SYSCOMMAND, SC_SIZE | WMSZ_BOTTOMLEFT, MAKELPARAM(point.x, point.y)); else if (nHitTest == HTBOTTOMRIGHT) SendMessage(WM_SYSCOMMAND, SC_SIZE | WMSZ_BOTTOMRIGHT, MAKELPARAM(point.x, point.y)); else if (nHitTest==HTCAPTION) SendMessage(WM_SYSCOMMAND, SC_MOVE | 4, MAKELPARAM(point.x, point.y)); }