SetItemSize and user drawn tab controls
I have this Win32 user-drawn tab control that is created as:
CONTROL "Tab1",IDC_TAB_CONT,"SysTabControl32",TCS_BOTTOM |
TCS_OWNERDRAWFIXED | NOT WS_VISIBLE,0,14,185,88
I'd like for this control to have its tabs resize as never to have to see the "sliding arrows":
Now, pretty much everything about this control works as expected, except for that fact that it won't respond to TabCtrl_SetItemSize
. Try as I may, the size I get for the tabs when I get to draw them (in the DRAWITEMSTRUCT
passed to WM_DRAWITEM
) is always the size that fits the longest caption in them and never the size I've set with TabCtrl_SetItemSize
.
However, in the TabCtrl_SetItemSize
documentation, it says that:
[ TabCtrl_SetItemSize
] sets the width and height of tabs in a fixed-width or owner-drawn tab control.
The only way I've managed to have a decent resizing is by setting a dummy string of the desired length in it by sending the control a TCM_SETITEM
message, and writing the desired text in it at draw time. This is rather inconvenient and not a particularly nice hack.
Is there anybody who would know
TabCtrl_SetItemSize
isn't working as expected? and/or Many thanks,
joce.
Setting TCS_OWNERDRAWFIXED
style is not enough, you have also to add TCS_FIXEDWIDTH
style.
The minimum size of a tab is at least icon width + 3 if icon is present.
If you have icons (imageList attached to tabControl), you might get those "sliding arrows" even with fixed width (if there is less space available than: number of tabs*(icon width+3)