1.先添加工具欄(IDR_TOOLBAR1)資源,并畫好各個按鈕
2.在對話框類聲名中添加成員變量 CToolBar 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);
4.響應Dialogue 的 WM_SIZE消息,在里面設置工具條位置。
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
posted on 2009-05-20 14:09
李陽 閱讀(170)
評論(0) 編輯 收藏 引用