#define BORDER_SIZE 4
#define CAPTION_SIZE 24
void CMvszDlg::OnPaint()
{
Invalidate();
CPaintDC dc(this);
CRect rc;
GetClientRect(&rc);
CBrush* pbr = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
dc.SelectObject(pbr);
dc.Rectangle(&rc);
dc.MoveTo(0, BORDER_SIZE + CAPTION_SIZE);
dc.LineTo(rc.right, BORDER_SIZE + CAPTION_SIZE);
dc.MoveTo(0, rc.bottom - (BORDER_SIZE + CAPTION_SIZE));
dc.LineTo(BORDER_SIZE, rc.bottom - (BORDER_SIZE + CAPTION_SIZE));
dc.MoveTo(rc.right - BORDER_SIZE, rc.bottom - (BORDER_SIZE + CAPTION_SIZE));
dc.LineTo(rc.right, rc.bottom - (BORDER_SIZE + CAPTION_SIZE));
dc.MoveTo(BORDER_SIZE + CAPTION_SIZE, 0);
dc.LineTo(BORDER_SIZE + CAPTION_SIZE, BORDER_SIZE);
dc.MoveTo(BORDER_SIZE + CAPTION_SIZE, rc.bottom - BORDER_SIZE);
dc.LineTo(BORDER_SIZE + CAPTION_SIZE, rc.bottom);
dc.MoveTo(rc.right - (BORDER_SIZE + CAPTION_SIZE), 0);
dc.LineTo(rc.right - (BORDER_SIZE + CAPTION_SIZE), BORDER_SIZE);
dc.MoveTo(rc.right - (BORDER_SIZE + CAPTION_SIZE), rc.bottom - BORDER_SIZE);
dc.LineTo(rc.right - (BORDER_SIZE + CAPTION_SIZE), rc.bottom);
rc.DeflateRect(BORDER_SIZE, BORDER_SIZE);
dc.Rectangle(&rc);
}
UINT CMvszDlg::OnNcHitTest(CPoint point)
{
ScreenToClient(&point);
CRect rc;
GetClientRect(&rc);
CRect rcTest = rc;
rcTest.DeflateRect(BORDER_SIZE, BORDER_SIZE);
int iBottom = rcTest.bottom;
rcTest.bottom = rcTest.top + CAPTION_SIZE;
if(rcTest.PtInRect(point))
return HTCAPTION;
rcTest.top = rcTest.bottom;
rcTest.bottom = iBottom;
if(rcTest.PtInRect(point))
return HTCLIENT;
rcTest.SetRect(0, 0, BORDER_SIZE + CAPTION_SIZE, BORDER_SIZE + CAPTION_SIZE);
if(rcTest.PtInRect(point))
return HTTOPLEFT;
rcTest.SetRect(BORDER_SIZE + CAPTION_SIZE, 0, rc.right - (BORDER_SIZE + CAPTION_SIZE), BORDER_SIZE + CAPTION_SIZE);
if(rcTest.PtInRect(point))
return HTTOP;
rcTest.SetRect(rc.right - (BORDER_SIZE + CAPTION_SIZE), 0, rc.right, BORDER_SIZE + CAPTION_SIZE);
if(rcTest.PtInRect(point))
return HTTOPRIGHT;
rcTest.SetRect(0, BORDER_SIZE + CAPTION_SIZE, BORDER_SIZE, rc.bottom - (BORDER_SIZE + CAPTION_SIZE));
if(rcTest.PtInRect(point))
return HTLEFT;
rcTest.SetRect(rc.right - BORDER_SIZE, BORDER_SIZE + CAPTION_SIZE, rc.right, rc.bottom - (BORDER_SIZE + CAPTION_SIZE));
if(rcTest.PtInRect(point))
return HTRIGHT;
rcTest.SetRect(0, rc.bottom - (BORDER_SIZE + CAPTION_SIZE), BORDER_SIZE + CAPTION_SIZE, rc.bottom);
if(rcTest.PtInRect(point))
return HTBOTTOMLEFT;
rcTest.SetRect(BORDER_SIZE + CAPTION_SIZE, rc.bottom - BORDER_SIZE, rc.right - (BORDER_SIZE + CAPTION_SIZE), rc.bottom);
if(rcTest.PtInRect(point))
return HTBOTTOM;
rcTest.SetRect(rc.right - (BORDER_SIZE + CAPTION_SIZE), rc.bottom - (BORDER_SIZE + CAPTION_SIZE), rc.right, rc.bottom);
if(rcTest.PtInRect(point))
return HTBOTTOMRIGHT;
return HTERROR;
}