CTabCtrl SetItemRect?

736 Views Asked by At

I want to change the size of the tabs.

We have added a closing cross to our tabs, but it conflicts spaciously with the text of the tab.

enter image description here

So far I have realized the following:

  • GetItemRect(int i, RECT* rc) gives me the rect. What I really would like is a SetItemRect.
  • SetItem cannot be used as the item does not contain its size. It is calculated based upon the contents I give it.
  • I could add a space char in the end of the string, but that's just against the natural order of things. I will not tweak pixels with CStrings.
  • SetSize is supposed to set the size of a tab (all tabs?). But I cannot find out where to put it that does not trigger a redraw, which sparks an infinite loop if I put it with the WM_PAINT case.

This is where I custom draw the contents of the tab, but I cannot resize them here:

LRESULT CSkinnedTabCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
switch (message) {
    case WM_PAINT: {
        ...

        CPaintDC dc(this); 

        INT nCount = GetItemCount();

        for (INT i = 0; i < nCount; i++) {
            CRect rc;
            GetItemRect(i, rc);
            DrawItem(dc, i, rc);
        }

        return TRUE;
    }

Where do I set the size of the tabs, and how?

1

There are 1 best solutions below

0
On

IIRC you need to overwrite WM_NCCALCSIZE message.