VC中工具栏按钮文字及左右排列设置方法

BOOL CMainFrame::CreateSysToolBar() { m_wndToolBar.ModifyStyle(0, TBSTYLE_LIST | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT |CBRS_TOOLTIPS | TBSTYLE_TRANSPARENT|TBBS_CHECKBOX ); //改变工具栏属性 m_ilTB.Create(32, 32, TRUE | ILC_COLOR8, 4, 0); HICON hIcon = NULL; hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_MAINTENANCE), IMAGE_ICON, 32, 32, 0); m_ilTB.Add(hIcon); hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_TABOO), IMAGE_ICON, 32, 32, 0); m_ilTB.Add(hIcon); hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_PRINTER), IMAGE_ICON, 32, 32, 0); m_ilTB.Add(hIcon); m_wndToolBar.GetToolBarCtrl().SetImageList(&m_ilTB); // m_wndToolBar.SetButtons(NULL, 3); // m_wndToolBar.SetSizes(CSize(200,38),CSize(32,32)); //m_wndToolBar.GetToolBarCtrl().SetButtonWidth(10,85); // 设置每个工具按钮文字 m_wndToolBar.SetButtonInfo(0, ID_M_12001, BTNS_AUTOSIZE, 0); m_wndToolBar.SetButtonText(0, CString(_loadRes(30041))); m_wndToolBar.SetButtonInfo(1, ID_M_13001, BTNS_AUTOSIZE, 1); m_wndToolBar.SetButtonText(1, CString(_loadRes(30043))); m_wndToolBar.SetButtonInfo(2, ID_M_14001, BTNS_AUTOSIZE, 2); m_wndToolBar.SetButtonText(2, CString(_loadRes(30042))); //m_wndToolBar.SetButtonInfo(2, 0, TBBS_SEPARATOR, 0); /*CToolBarCtrl &tb = m_wndToolBar.GetToolBarCtrl(); tb.EnableButton(ID_M_12002,FALSE);*/ //m_wndToolBar.SetButtonInfo(1, ID_M_12002, TBBS_DISABLED, 0); // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); return TRUE; }

你可能感兴趣的:(VC中工具栏按钮文字及左右排列设置方法)