EFanZh
EFanZh

Reputation: 2436

How to make a CMFCToolBar display its buttons' text label right to to their icons?

How to make a CMFCToolBar display its buttons' text labels right to their icons?

Because a CMFCToolBar is not a standard common control Toolbar, I can't just set a TBSTYLE_LIST flag to do it.

I can't use a CToolBar or CToolBarCtrl instead because they don't work well with my CDockablePanes.

Upvotes: 1

Views: 2340

Answers (4)

23W
23W

Reputation: 1530

You should use CMFCToolBar::SetToolBarBtnText() method. Toolbar must be created with TBSTYLE_FLAT control style.

if (m_MyToolBar.CreateEx(this, TBSTYLE_FLAT, AFX_DEFAULT_TOOLBAR_STYLE | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1, 1, 1, 1)) 
&&
MyToolBar.LoadToolBar(nToolBarResourceID))
{
  m_MyToolBar.SetToolBarBtnText( MyToolBar.CommandToIndex(ID_MY_CMD), _T("My command"));
}

That is all.

Upvotes: 1

rrirower
rrirower

Reputation: 4590

Those classes were ported from the BCG toolkit. The documentation is pretty poor. You should be able to set the button class public member variable m_bText to true and set the text in m_strText.

Upvotes: 0

Edward Clements
Edward Clements

Reputation: 5132

Try the EnableTextLabels function of the CMFCToolBar -- says "Enables or disables text labels under toolbar button images"

Upvotes: 0

demoncodemonkey
demoncodemonkey

Reputation: 11957

Can't you use CreateEx and pass TBSTYLE_LIST as the dwCtrlStyle parameter?

Upvotes: 1

Related Questions