Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In childframe.h

ADD:
CSS
protected:
    CMFCToolBar       m_wndChildToolBar;


C#
public:
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);


In childframe.cpp
ADD:
VB
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx)
    ON_WM_CREATE()
END_MESSAGE_MAP()



C#
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1)
        return -1;
    if (!m_wndChildToolBar.CreateEx(this, TBSTYLE_FLAT,WS_OVERLAPPED| WS_CHILD | WS_VISIBLE | CBRS_LEFT | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
        !m_wndChildToolBar.LoadToolBar(IDR_TOOLBAR1))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;      // fail to create
    }
    // TODO:  Add your specialized creation code here
    m_wndChildToolBar.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);

    DockPane(&m_wndChildToolBar);
    return 0;
}


After,build and debug
the toolbar in the childframe,we can not see the icons,and the toolbar can not dock to another place.
I used vs2012.
How to edit the code?Any suggestions will be appreciated!
Posted
Comments
KarstenK 16-May-13 10:54am    
check that the resource id IDR_TOOLBAR1 has a toolbar image with pixel width and depth
suncuigang 16-May-13 20:44pm    
IDR_TOOLBAR1 is new created. It i with height 15,width 16 ,16 colors. It is located in res/toolbar1.bmp.
but after debuging, the images in the toolbar of chindframe are invisible.
KarstenK 17-May-13 2:01am    
Check all styles and try a toolbar with 256 colors.
suncuigang 17-May-13 2:21am    
in the mainframe.cpp,
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(/*theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 :*/ IDR_MAINFRAME))
I used IDR_MAINFRAME,the icons are visible.
seems the toolbar colors in mainframe and childframe must be same!
Thanks, Karstenk!
suncuigang 19-May-13 23:20pm    
Hello,Karstenk.
I don't know why the m_wndChildToolBar can not docking anyway, even though I add

m_wndChildToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndChildToolBar);
in CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
Do you know?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900