TabCtrl_SetItemSize and custom tab controls

I have a Win32 custom drawn control created as:

    CONTROL "Tab1",IDC_TAB_CONT,"SysTabControl32",TCS_BOTTOM | 
            TCS_OWNERDRAWFIXED | NOT WS_VISIBLE,0,14,185,88

      

I would like this control to have its own tab sizes, since I never needed to see "sliding arrows":

alt text

Now almost everything about this control works as expected, except for the fact that it won't respond to TabCtrl_SetItemSize

. Try as best I can, the size I get for the tabs when I draw them (in DRAWITEMSTRUCT

, passed in WM_DRAWITEM

) is always the size that matches the longest header in them, and never the size I set with TabCtrl_SetItemSize

.

However, the TabCtrl_SetItemSize

documentation
says that:

[ TabCtrl_SetItemSize

] sets the width and height of the tabs to a fixed width or tab owner control.

The only way I have been able to achieve a decent resize is to set it to a dummy string of the correct length by sending a control message TCM_SETITEM

and typing the desired text into it while drawing. It's pretty awkward and not particularly pleasant to hack.

Is there anyone who would know

  • Why TabCtrl_SetItemSize

    isn't it working as expected? and / or
  • How to set the tab size correctly?

Many thanks,

Jos.

+2


source to share


1 answer


  • Customization is TCS_OWNERDRAWFIXED

    not enough, you also need to add style TCS_FIXEDWIDTH

    .

  • The minimum tab size is at least the width of the icon + 3, if the icon is present.
    If you have icons (imageList attached to a tabControl) you can get these "sliding arrows" even with a fixed width (if less space is available than: number of tabs * (icon width + 3)



+3


source







All Articles