<!-- Download Links -->
<!-- Article image -->
<!-- Add the rest of your HTML here -->
Tab controls when used well are a very valuable ui tool.
However, I have more recently felt that the original (and current) look of the standard tab control was too heavy: instead of just looking at the contents of the tab control I was distracted by the 3D borders which overplay the folder metaphor.
As many of you will know, Windows provides for limited customizing of the tab control appearance via owner-draw but this is restricted to the tab labels only and not to the tab border or the background.
The obvious solution was to override
WM_PAINT to extend the owner-draw mechanism to handle the main tab control border and the individual label borders, and to override
WM_ERASEBKGND to paint the background.
The result is
CBaseTabControl is the class which contains the necessary hooks to allow derived classes to paint whichever parts of the tab control they choose, and
CEnTabControl is an example derived class which implements some features that I have found useful.
Some Comments on the Source Code
Code Fix 1.1
Gian (email@example.com) correctly pointed out that if you try to attach a CImageList to the tab control then you get an ASSERT in the drawing code.
This occurs because the drawing code temporarily attaches the tab control imagelist to a CImageList for drawing purposes and MFC asserts that its already attached to a CImageList (the original).
The reason MFC asserts is because it keeps a static map for converting between HIMAGELIST and CImageList*, and the implementation of the underlying map prevents an HIMAGELIST being mapped to more than one CImageList*.
The fix is to use ImageList_Draw() for drawing.
- The code has not been thoroughly tested for bottom and side tabs, so please don't complain if it doesn't work as expected.