添加工具栏

来源:互联网 发布:手机联系人同步软件 编辑:程序博客网 时间:2024/05/18 04:59

 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