给工具栏上的按钮添加文字(VC)

 

详见:MSDN里的CToolBar::SetSizes函数中的示例,摘抄如下:

// 这个例子演示了如何将文字添加到工具栏按钮上
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
文章来源:http://www.codelast.com/
//Create a toolbar. Resource ID of the toolbar to be loaded
//is IDR_MAINFRAME.

if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE
| CBRS_TOP) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0(“Failed to create toolbar ”);
return -1;  // fail to create
}

// 在工具栏按钮上显示文字
VERIFY(m_wndToolBar.SetButtonText(0,”New”));
VERIFY(m_wndToolBar.SetButtonText(1,”Open”));
VERIFY(m_wndToolBar.SetButtonText(2,”Save”));
VERIFY(m_wndToolBar.SetButtonText(4,”Cut”));
VERIFY(m_wndToolBar.SetButtonText(5,”Copy”));
VERIFY(m_wndToolBar.SetButtonText(6,”Paste”));
VERIFY(m_wndToolBar.SetButtonText(8,”Print”));
VERIFY(m_wndToolBar.SetButtonText(9,”About”));

CRect temp;
m_wndToolBar.GetItemRect(0,&temp);
m_wndToolBar.SetSizes(CSize(temp.Width(),
temp.Height()),CSize(16,15));

return 0;
}

文章来源:https://www.codelast.com/
➤➤ 版权声明 ➤➤ 
转载需注明出处:codelast.com 
感谢关注我的微信公众号(微信扫一扫):

wechat qrcode of codelast

发表评论