CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Aug 2013

    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)
    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);

    Can anybody please help me?

  2. #2
    Join Date
    Apr 2000
    Belgium (Europe)

    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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.