4

Is there an easy way to remove the close button from an MFC feature pack caption bar?

(I don't mean the window caption, I'm talking about the little information bar that can appear at the top of the client area in these apps - ie:CMFCCaptionBar)

Thanks

Brad Robinson
  • 44,114
  • 19
  • 59
  • 88

2 Answers2

3

Figured out one way...

class CNoCloseCaptionBar : public CMFCCaptionBar
{
public:
    CNoCloseCaptionBar()
    {
    }

    virtual void RecalcLayout()
    {
        __super::RecalcLayout();
        m_rectClose.SetRectEmpty();
    }

};
Brad Robinson
  • 44,114
  • 19
  • 59
  • 88
  • Shameless hack directly modifying protected base class members but sadly I don't have a better alternative. This does not stop them from closing the caption bar just stops the x button from being drawn ... you have to overload the appropriate methods to actually prevent closing by other means. – AJG85 Apr 04 '11 at 03:52
0

Removing the bitmap worked for me. See the MSOffice2007Demo example in the Visual C++ 2008 Feature Pack.

Comment out the following line in CMainFrame:CreateMessageBar()

//m_wndMessageBar.SetBitmap(IDB_INFO, RGB(255, 255, 255), FALSE, CMFCCaptionBar::ALIGN_LEFT);

Caption Bar without close button enter image description here

j08691
  • 204,283
  • 31
  • 260
  • 272
ASooter
  • 1
  • 1