Can you find the error ! Drawing a button in non client area but caption is not setting to ....
Hello Experts ,
I spent almost 4 hrs today doing this .If anyone can help me ,that
would be hats off !
I wanted to remove all the min,max and close button and later draw my
min max buttons.
Here is what i did
1.Added the styles in the PreCreateWindow.This works and the min ,max
,close are invisible .
2.Added a WN_NCPAINT handler for drawing of buttons ,when I want to
draw my buttons in the non client area but the min ,max ,close buttons
are still visible.
3. When you put a comment to ON_WM_NCPAINT()
min ,max ,close are visible .
Am i missing anything ?Can anyone point my error?
*******STEP1
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
ON_WM_NCPAINT() //Step 4
END_MESSAGE_MAP()
*******STEP2
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
// Create a window without min/max buttons or sizable border
cs.style = WS_VISIBLE | WS_OVERLAPPED | DS_SETFOREGROUND |
DS_CENTER |
WS_CAPTION ;
return CFrameWnd::PreCreateWindow(cs);
}
*******STEP4
void CMainFrame::OnNcPaint()
{
// TODO: Add your message handler code here
// Do not call CFrameWnd::OnNcPaint() for painting messages
CWindowDC d(this);
RECT rc;
GetWindowRect( &rc);
BOOL b = d.DrawFrameControl(CRect(760,4,800,23),DFC_CAPTION
,DFCS_CAPTIONCLOSE);
b = d.DrawFrameControl(CRect(719,4,759,23),DFC_CAPTION
,DFCS_CAPTIONMIN);
}