Search code examples
c++windowsvisual-studio-2008mfcmdi

How to customize MFC MDI CMFCTabCtrl


I've created MDI application based on MFC framework but the style of CMFCTabCtrl's doesn't satisfy our requirements. I want to change the tab height, colors and add some pictures and buttons.

But I don't know how. Are there any examples or articles that will help me out?


Solution

  • You can easily customize your MFC Tab control. There are plenty of options.

    To enable Close buttons you just need to call m_TabControl.EnableActiveTabCloseButton();

    Make sure to add a WM_CLOSE message handler in your child window:

    void CMyTabWindow::OnClose()
    {
        CMFCTabCtrl *pTab = static_cast<CMFCTabCtrl*>(GetParent());
        pTab->RemoveTab(pTab->GetActiveTab());
    }
    

    You can customize colors using SetTabBkColor() or SetAutoColors().

    You can also set images using SetImageList().

    The height can also be customized using SetTabsHeight().