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

Thread: How to use BTNS_AUTOSIZE

  1. #1
    Join Date
    Aug 2013
    Posts
    35

    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
    3,757

    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center