Search code examples
colorstabsmfccolor-scheme

CMFCTabCtrl color customising


Is there the way to change the line and background colors of CMFCBaseTabCtrl?

I can change tabs color via SetTabBkColor(...) or SetAutoColors(...) but control's header and lines remain grey.

SetSysColors(...) is not an option because it changes colors globally for entire OS.

Basically we need to apply some lite/dark color scheme. I can not find the way to change tab control background and line colors. When the tab background color is set by SetTabBkColor(...) it leaves the space near the tab border.

Also its expected that SetActiveTabColor(...) will change the background of the active tab but it does pretty nothing.

And there is no way to change the text color of the active tab. I belive this stuff is customisable but can not find how.

enter image description here


Solution

  • The colors are retrieved from the current instance of the CMFCVisualManager.

    CMFCVisualManager::GetTabFrameColors is used. And some other manager functions like OnEraseTabsFrame and OnEraseTabsArea.

    So derive your own visual manager from the one you prefer. Overwrite the specific functions and so you can change the colors and behavior.

    There is no other way. Just lok into the source code in void CMFCTabCtrl::OnDraw(CDC* pDC)

    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\src\mfc\afxtabctrl.cpp