CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2013
    Posts
    52

    Unhappy How to use BTNS_AUTOSIZE

    I want to control my toolbar dynamically.

    First I added tool bar with style including TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_LIST.
    Then added the tool bar to a rebar. I added tool tips by handling TTN_GETDISPINFO.

    Everything works fine. But when I try to add text to right of the button, the text
    gets added but button size is not automatically changing.

    The following code is not working .

    void SetToolbarText(HWND& hwndToolbar,LPTSTR szText)
    {
    ATLASSERT(::IsWindow(hwndToolbar));
    TBBUTTONINFO tbbi = { 0 };
    tbbi.cbSize = sizeof(TBBUTTONINFO);
    tbbi.dwMask = TBIF_TEXT;// | TBIF_SIZE;//if I add TBIF_SIZE code will work!
    tbbi.cchText = 0;
    tbbi.cx = 200;
    tbbi.fsState = 0;
    tbbi.fsStyle = tbbi.fsStyle | BTNS_SHOWTEXT | BTNS_AUTOSIZE ;//TBSTYLE_AUTOSIZE
    //tbbi.fsStyle = tbbi.fsStyle | BTNS_SHOWTEXT | TBSTYLE_AUTOSIZE ;//TBSTYLE_AUTOSIZE
    tbbi.idCommand = 0;
    tbbi.iImage = 0;
    tbbi.lParam = 0;
    tbbi.pszText = szText;//szText is _T("ABC")
    BOOL b = (BOOL)::SendMessage(hwndToolbar, TB_SETBUTTONINFO, ID_BUTTON3, (LPARAM)&tbbi);
    return;
    }

    Can anybody please help me?

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: How to use BTNS_AUTOSIZE

    you need to add TBIF_STYLE to the mask if you want to change the fsStyle value to contain the AUTOSIZE flag

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured