TBSTYLE_EX_MIXEDBUTTONS not working when some buttons do not have text - Programmer

This is a discussion on TBSTYLE_EX_MIXEDBUTTONS not working when some buttons do not have text - Programmer ; I am creating a CToolBarCtrl with CreateEx and using the TBSTYLE_EX_MIXEDBUTTONS so that I can have some buttons with text and some without. Unfortunately, even when one of the buttons does not have text it is sized as if it ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: TBSTYLE_EX_MIXEDBUTTONS not working when some buttons do not have text

  1. TBSTYLE_EX_MIXEDBUTTONS not working when some buttons do not have text

    I am creating a CToolBarCtrl with CreateEx and using the
    TBSTYLE_EX_MIXEDBUTTONS so that I can have some buttons with text and
    some without. Unfortunately, even when one of the buttons does not
    have text it is sized as if it does have text. It seems to size all
    the buttons the same width, in other words, to match the button with
    the longest text.

    Here is my code:

    CRect rect;
    rect.left = 0;
    rect.top = 0;
    rect.right = 100;
    rect.bottom = 25;

    // Create the toolbar.
    CWnd *pWnd = new CWnd();
    pWnd->Attach(m_hWnd);
    m_pTBButtons = new TBBUTTON[2];
    BOOL bRet = m_toolBar.CreateEx(TBSTYLE_EX_MIXEDBUTTONS,
    CBRS_ALIGN_TOP | WS_BORDER | WS_VISIBLE | WS_CHILD
    | TBSTYLE_WRAPABLE | TBSTYLE_LIST | TBSTYLE_FLAT,
    rect, pWnd, 300);

    m_toolBar.AddBitmap(2,IDB_BROWSER_TOOLBAR);

    //int i = m_toolBar.AddString(IDS_TOOLBAR_REFRESH);
    m_pTBButtons = new TBBUTTON[2];

    // Add "Refresh" button
    string.LoadString(IDS_TOOLBAR_REFRESH);
    pString = string.GetBufferSetLength(string.GetLength() + 1);
    pString[string.GetLength()] = 0; // must have added null
    m_pTBButtons[0].iString = -1;
    string.ReleaseBuffer();
    m_pTBButtons[0].fsState = TBSTATE_ENABLED;
    m_pTBButtons[0].fsStyle = 0;
    m_pTBButtons[0].dwData = 0;
    m_pTBButtons[0].iBitmap = 0;
    m_pTBButtons[0].idCommand = ID_BROWSERPOPUP_REFRESH;

    // Add "Get Latest" button
    string.LoadString(IDS_TOOLBAR_GETLATEST);
    pString = string.GetBufferSetLength(string.GetLength() + 1);
    pString[string.GetLength()] = 0; // must have added null
    m_pTBButtons[1].iString = m_toolBar.AddStrings(pString);
    string.ReleaseBuffer();
    m_pTBButtons[1].fsState = TBSTATE_ENABLED;
    m_pTBButtons[1].fsStyle = 0;
    m_pTBButtons[1].dwData = 0;
    m_pTBButtons[1].iBitmap = 1;
    m_pTBButtons[1].idCommand = ID_BROWSERPOPUP_GETLATEST;

    // Now add the buttons to the toolbar
    m_toolBar.AddButtons(1,&m_pTBButtons[0]);
    m_toolBar.AddButtons(1,&m_pTBButtons[1]);


    Thanks for any help,
    Byron Douglas

  2. Re: TBSTYLE_EX_MIXEDBUTTONS not working when some buttons do not have text

    Solved my own problem here. I was not creating the buttons with the
    BTNS_AUTOSIZE style.

+ Reply to Thread