CMFCToolBar在图标下显示文本方法
CMFCToolBar在工具栏上的图像下面显示文本的方法
1.使用SetButtonText
在CFrameWndEx的子类CMainFrame的OnCreate函数中创建工具栏之后调用SetButtonText
m_wndToolBar.SetButtonText(0,_T("新建"));
设置所有的工具栏按钮
或者 m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_FILE_NEW),TEXT("new"));
m_wndToolBar.AdjustLayout();
然后调用SetSizes设置按钮大小。
2.非常简便的方法是使用CMFCToolBar::EnableTextLabels方法 --------------///文本在图片下面
在工具栏编辑器里编辑每一个按钮的Prompt属性,格式是“说明文字\n名称”。其中名称就是显示的文本。
然后在CFrameWndEx的子类CMainFrame中重载函数LoadFrame,在其中添加代码:
m_wndToolBar.EnableTextLabels(TRUE);
其中m_wndToolBar是程序的主工具栏CMFCToolBar m_wndToolBar;
eg:
m_wndToolBar.EnableTextLabels();
m_wndToolBar.SetToolBarBtnText(0, _T(
"文字"
));