// This code fragment is taken from CMainFrame::OnCreate
// CMainFrame is derived from CMDIFrameWnd.//This example shows how to add text to toolbar buttons.
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE
| CBRS_TOP) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}//Show text on toolbar buttons.
VERIFY(m_wndToolBar.SetButtonText(0, _T("New")));
VERIFY(m_wndToolBar.SetButtonText(1, _T("Open")));
VERIFY(m_wndToolBar.SetButtonText(2, _T("Save")));
VERIFY(m_wndToolBar.SetButtonText(4, _T("Cut")));
VERIFY(m_wndToolBar.SetButtonText(5, _T("Copy")));
VERIFY(m_wndToolBar.SetButtonText(6, _T("Paste")));
VERIFY(m_wndToolBar.SetButtonText(8, _T("Print")));
VERIFY(m_wndToolBar.SetButtonText(9, _T("About")));CRect temp;
m_wndToolBar.GetItemRect(0, &temp);
m_wndToolBar.GetToolBarCtrl().SetButtonSize(CSize(temp.Width(),
temp.Height()));
用CToolBar类
// CMainFrame is derived from CMDIFrameWnd.//This example shows how to add text to toolbar buttons.
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE
| CBRS_TOP) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}//Show text on toolbar buttons.
VERIFY(m_wndToolBar.SetButtonText(0, _T("New")));
VERIFY(m_wndToolBar.SetButtonText(1, _T("Open")));
VERIFY(m_wndToolBar.SetButtonText(2, _T("Save")));
VERIFY(m_wndToolBar.SetButtonText(4, _T("Cut")));
VERIFY(m_wndToolBar.SetButtonText(5, _T("Copy")));
VERIFY(m_wndToolBar.SetButtonText(6, _T("Paste")));
VERIFY(m_wndToolBar.SetButtonText(8, _T("Print")));
VERIFY(m_wndToolBar.SetButtonText(9, _T("About")));CRect temp;
m_wndToolBar.GetItemRect(0, &temp);
m_wndToolBar.GetToolBarCtrl().SetButtonSize(CSize(temp.Width(),
temp.Height()));
用CToolBar类
解决方案 »
- createProcessingInstruction XML头部缺少encoding项
- 散下分
- 初学C++关于fatal error C1010:的问题
- 问个MFC很基础的问题
- MFC中怎样实现鼠标选中一段字符然后复制的功能
- 用PostMessage为什么收不到消息?
- 摄像头,视频,编解码问题
- 请问去哪里可以找到一些英文文献及其实现源代码呢?
- 提取图中用某种单一颜色矩形框标注的图像内容,并将其保存为BMP格式的文件。
- vc中直接用socket编程(不用CSocket,和CAsyncSocket)都用到哪些函数
- 关于COleDocObjectItem的问题
- 在对话框上创建子窗口成功,但不显示?
邪门了,在我原代码的后面加上:m_tb.AddStrings("aa");//实际上,任意字符串都行。
竟然可以正常显示字符了,即正常显示:“按钮上的字”,但是"aa"并没有显示出来,这是为什么呢?即改成下面这个样子://前面不变
//开始设置文字
TBBUTTONINFO tbInfo;
memset((char*)&tbInfo, 0, sizeof(TBBUTTONINFO));
tbInfo.cbSize = sizeof(TBBUTTONINFO);
tbInfo.dwMask = TBIF_TEXT;
tbInfo.cchText = strlen("按钮上的字");
tbInfo.pszText = "按钮上的字";
BOOL bRet = m_tb.SetButtonInfo(ID_BUTTONCHECK_1,&tbInfo);
m_tb.AddStrings("aa");//加上这一行后,要显示的字(“按钮上的字”)竟然奇迹般的显示出来的,但“aa”没有显示出来,可这是为什么呢?期待中!!!
// adds three strings with one call
lpszStrings = "String 1\0String 2\0String 3\0";
你这个我当然早就看过了,不是问你AddString如何用。
你没明白我的意思,建议你仔细看看我的问题,特别是下面我的疑惑。看6楼的描述。