CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 1999
    Posts
    1

    buttons on window tittle bar

    I want put my own button on window tittle bar (beside minimize maximize and close buttons).
    Can you help me?
    Thanks.


  2. #2
    Guest

    Re: buttons on window tittle bar

    I also have tried this, but the caption bar is only accessible when drawing, not
    creating objects. The best Way is to create your own caption & remove the original bar.


  3. #3
    Join Date
    May 1999
    Location
    Latvia
    Posts
    30

    Re: buttons on window tittle bar

    hi, what do you mean with "remove original bar" ?


  4. #4
    Join Date
    Apr 1999
    Posts
    383

    Re: buttons on window tittle bar

    You will need to handle the WM_NCPAINT message (override CWnd::OnNcPaint()), and after calling the default handler, get the window DC (GetWindowDC) draw your button onto the caption area. Use GetSystemMetrics() to work out the size and just where to draw it. The simplest general idea is something like this:

    void CChildFrame::OnNcPaint( )
    {
    CMDIChildWnd::OnNcPaint(); // Do normal frame & caption painting
    // calculate button position and size using GetWindowRect and
    // GetSystemMetrics to get the window width, border width & height, and
    // button sizes
    CDC* pDC = GetWindowDC();
    // Draw button into DC
    }



    However, if you want the window caption text to behave correctly when resized to any size and minimised, you really need to draw the whole caption yourself. There's a couple of examples in the 'TitleBar' section of the 'Misc' area on this site.

    You will also need to handle the non-client area mouse button clicks OnNcLButtonDown, etc.

    Dave



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured