1 .添加工具栏资源
在View --Resource 中新建一个ToolBar的资源。
2.添加成员变量:
CTooBar m_wndtoolbar;
3.在OnInitDialog中添加以下代码:
if (!m_wndtoolbar.CreateEx( this,TBSTYLE_FLAT , WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS,
CRect(4,4,0,0)) ||!m_wndtoolbar.LoadToolBar(IDR_TOOLBAR1) )
{
TRACE0("failed to create toolbar\n");
return FALSE;
}
m_wndtoolbar.ShowWindow(SW_SHOW);//显示工具条
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);//重绘控制条窗口
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog