Can you find the error ! Drawing a button in non client area but caption is not setting to .... - Programmer

This is a discussion on Can you find the error ! Drawing a button in non client area but caption is not setting to .... - Programmer ; 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 ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Can you find the error ! Drawing a button in non client area but caption is not setting to ....

  1. 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);
    }


  2. Re: Can you find the error ! Drawing a button in non client area but caption is not setting to ....

    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/de...vcons_4esj.asp

    http://msdn.microsoft.com/library/de...windowrect.asp

    http://msdn.microsoft.com/library/de...clientrect.asp

    http://msdn.microsoft.com/library/de...temmetrics.asp

    http://msdn.microsoft.com/library/de...gions_8u9g.asp

    http://msdn.microsoft.com/library/de...gions_7tf2.asp

    http://msdn.microsoft.com/library/de...pping_2eni.asp

    http://msdn.microsoft.com/library/de...tdraw_4b3g.asp

    http://msdn.microsoft.com/library/de...vcons_1vsk.asp

    http://msdn.microsoft.com/library/de...vcons_66hv.asp

    Hope these suggestions helps,

    Kellie.


+ Reply to Thread