Discussion:
Can you find the error ! Drawing a button in non client area but caption is not setting to ....
(too old to reply)
n***@yahoo.com
2006-05-17 17:51:27 UTC
Permalink
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);
}
Kellie Fitton
2006-05-17 22:05:43 UTC
Permalink
Hi,

You need to use the following APIs to draw a frame control
and paint the standard window buttons (min, max & close):

GetDC()
GetWindowRect()
GetClientRect()
GetSystemMetrics() using SM_CYCAPTION, SM_CYFRAME
CreateRectRgnIndirect()
CombineRgn()
SelectClipRgn()
DrawFrameControl()

............................................

DeleteObject()
ReleaseDC()

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_4esj.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/getwindowrect.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/getclientrect.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemmetrics.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/regions_8u9g.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/regions_7tf2.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/clipping_2eni.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_4b3g.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_1vsk.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_66hv.asp

Hope these suggestions helps,

Kellie.

Loading...