我新建了一个class MYTOOLBAR : public CToolBarCtrl 下面的函数不有被调用: int MTOOLBAR::OnCreate(LPCREATESTRUCT lpCreateStruct) { AfxMessageBox(""); if (CToolBarCtrl::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here
你创建得时候只只指定了,在上面阿,看看msdn上面关于createex得函数, BOOL CreateEx(CWnd* pParentWnd, DWORD dwCtrlStyle = TBSTYLE_FLAT, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP, CRect rcBorders = CRect(0, 0, 0, 0), UINT nID = AFX_IDW_TOOLBAR);Return ValueNonzero if successful; otherwise 0.ParameterspParentWndPointer to the window that is the toolbar’s parent.dwCtrlStyleAdditional styles for the creation of the embedded CToolBarCtrl object. By default, this value is set to TBSTYLE_FLAT. For a complete list of toolbar styles, see dwStyle.dwStyleThe toolbar style. See Toolbar Control and Button Styles in the Platform SDK for a list of appropriate styles.rcBordersA CRect object that defines the widths of the toolbar window borders. These borders are set to 0,0,0,0 by default, thereby resulting in a toolbar window with no borders.nIDThe toolbar’s child-window ID.
剩下的步骤其实跟系统生成的那个ToolBar步骤一样。
CToolBar m_myToolBar;
if (!m_myToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC)
||!m_myToolBar.LoadToolBar(IDR_TOOLBAR1)
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_myoolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
下面的函数不有被调用:
int MTOOLBAR::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
AfxMessageBox("");
if (CToolBarCtrl::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
return 0;
}
请说手指点!
然后设置Toolbar上的ID
classwizard上加函数
我用下面的语句实现不了,
m_myToolBar.EnableDocking(CBRS_ALIGN_RIGHT);
EnableDocking(CBRS_ALIGN_RIGHT);
DockControlBar(&m_myToolBar);准备接分!!!!
BOOL CreateEx(CWnd* pParentWnd, DWORD dwCtrlStyle = TBSTYLE_FLAT, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP, CRect rcBorders = CRect(0, 0, 0, 0), UINT nID = AFX_IDW_TOOLBAR);Return ValueNonzero if successful; otherwise 0.ParameterspParentWndPointer to the window that is the toolbar’s parent.dwCtrlStyleAdditional styles for the creation of the embedded CToolBarCtrl object. By default, this value is set to TBSTYLE_FLAT. For a complete list of toolbar styles, see dwStyle.dwStyleThe toolbar style. See Toolbar Control and Button Styles in the Platform SDK for a list of appropriate styles.rcBordersA CRect object that defines the widths of the toolbar window borders. These borders are set to 0,0,0,0 by default, thereby resulting in a toolbar window with no borders.nIDThe toolbar’s child-window ID.