We are making a skinned application for XP and need to implement the
minimize and close buttons. I was under the impression that I just
had to handle WM_NCHITTEST and return HTMINBUTTON to indicate that the
mouse is in the minimize button. After that, the system would handle
the WM_NCLBUTTONDOWN/UP messages and fire the WM_SYSCOMMAND message to
minimize/close the window, but that does not seem to be the case.
Do we need to implement WM_NCLBUTTONDOWN/UP and fire the WM_SYSCOMMAND
messages myself?
Excuse the magic numbers; i am just trying to get this to work right
now.
Here is my WTL code:
LRESULT CMainDlg::OnNCHitTest(CPoint pt)
{
// need to subtract window origin from x and y
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
BOOL check = GetWindowPlacement(&wp);
pt.x = pt.x - wp.rcNormalPosition.left;
pt.y = pt.y - wp.rcNormalPosition.top;
CRect minBtnRect(0, 0, 16, 17);
minBtnRect.MoveToXY(1246, 5);
CRect closeBtnRect(0, 0, 16, 17);
closeBtnRect.MoveToXY(minBtnRect.right + 2, 5);
if(minBtnRect.PtInRect(pt))
{
return HTMINBUTTON;
}
else if (closeBtnRect.PtInRect(pt))
{
return HTCLOSE;
}
else if(CRect(1, 1, 1279, 27).PtInRect(pt))
{
return HTCAPTION;
}
return HTCLIENT;
}
void CMainDlg::OnNCPaint(HRGN rgn)
{
}
LRESULT CMainDlg::OnNCActivate(BOOL active)
{
return 1;
}