Prev: Windows Installer
Next: typedef struct RTTI/Reflection
From: RAN on 6 Mar 2010 19:11 On 7 mrt, 00:54, RAN <nijenh...(a)wish.nl> wrote: > On 6 mrt, 23:27, Uwe Kotyczka <uwe.kotyc...(a)web.de> wrote: > > > As Scott mentioned the toolbar you want will not belong to > > your CView derived class, but to it's parent, which is > > CChildFrame. > > To demonstrate it I just created a little demo project > > (not with VS23008, but with the old VS6) choosing the > > MDI interface. By default a toolbar is created as a > > child of CMainFrame. Then I moved the toolbar code from > > CMainFrame to CChildFrame (and docked it at the bottom > > instead of the top). > > You can study the demo and build something similar in your > > code. You will find my demo at:http://www.mediafire.com/file/gwymwymginw/Test.zip > > > HTH > > Thanks for your example it indeed works for VS6 BUT i am using > CMDIChildWndEx !!! (using VS2008Pro) for which it does not work. > What i have done so far: > 1) Created a MDI CView Tabbed documents project with app-wizard. > 2) In CChildFrame i added OnCreate() > > int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) > { > if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1) > return -1; > > // TODO: Add your specialized creation code here > if (!m_wndToolBar.Create(this) || > !m_wndToolBar.LoadToolBar(IDR_CHILDFRAME)) > { > TRACE0("Failed to create toolbar\n"); > return -1; // fail to create > } > > // TODO: Remove this if you don't want tool tips or a > // resizeable toolbar > m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | > CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); > > // 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 0; > > } > > it compiles and runs and halts into an ASSERT in winfrm2.cpp (line > 92) : > > void CFrameWnd::DockControlBar(CControlBar* pBar, CDockBar* pDockBar, > LPCRECT lpRect) > { > ENSURE_ARG(pBar != NULL); > // make sure CControlBar::EnableDocking has been called > ASSERT(pBar->m_pDockContext != NULL); > > if (pDockBar == NULL) > { > for (int i = 0; i < 4; i++) > { > if ((dwDockBarMap[i][1] & CBRS_ALIGN_ANY) == > (pBar->m_dwStyle & CBRS_ALIGN_ANY)) > { > pDockBar = (CDockBar*)GetControlBar(dwDockBarMap[i][0]); > /* --------> goes wrong here ------> */ ASSERT(pDockBar != NULL); > // assert fails when initial CBRS_ of bar does not > // match available docking sites, as set by EnableDocking() > break; > } > } > } > ENSURE_ARG(pDockBar != NULL); > ASSERT(m_listControlBars.Find(pBar) != NULL); > ASSERT(pBar->m_pDockSite == this); > // if this assertion occurred it is because the parent of pBar was > not initially > // this CFrameWnd when pBar's OnCreate was called > // i.e. this control bar should have been created with a different > parent initially > > pDockBar->DockControlBar(pBar, lpRect); > > } > > in line 92 : > > ASSERT(pDockBar != NULL); > // assert fails when initial CBRS_ of bar does not > // match available docking sites, as set by EnableDocking() > > the source here even gives some explanation of what goes wrong here > but i dont know how to match 'initial CBRS_ of bar with those set by > EnableDocking()'' > > Does this even work for a CMDIChildWndEx derived CChildFrame class ? > > Well so my question is does any one know how to add a toolbar to a > CMDIChildWndEx derived CChildFrame class ? > Any suggestions on how to get this working ? My project is here maybe someone could take a look at it : http://www.4shared.com/file/235762968/49b8b97a/GUI50.html
From: RAN on 7 Mar 2010 13:23
On 7 mrt, 01:11, RAN <nijenh...(a)wish.nl> wrote: > On 7 mrt, 00:54, RAN <nijenh...(a)wish.nl> wrote: > > > > > > > On 6 mrt, 23:27, Uwe Kotyczka <uwe.kotyc...(a)web.de> wrote: > > > > As Scott mentioned the toolbar you want will not belong to > > > your CView derived class, but to it's parent, which is > > > CChildFrame. > > > To demonstrate it I just created a little demo project > > > (not with VS23008, but with the old VS6) choosing the > > > MDI interface. By default a toolbar is created as a > > > child of CMainFrame. Then I moved the toolbar code from > > > CMainFrame to CChildFrame (and docked it at the bottom > > > instead of the top). > > > You can study the demo and build something similar in your > > > code. You will find my demo at:http://www.mediafire.com/file/gwymwymginw/Test.zip > > > > HTH > > > Thanks for your example it indeed works for VS6 BUT i am using > > CMDIChildWndEx !!! (using VS2008Pro) for which it does not work. > > What i have done so far: > > 1) Created a MDI CView Tabbed documents project with app-wizard. > > 2) In CChildFrame i added OnCreate() > > > int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) > > { > > if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1) > > return -1; > > > // TODO: Add your specialized creation code here > > if (!m_wndToolBar.Create(this) || > > !m_wndToolBar.LoadToolBar(IDR_CHILDFRAME)) > > { > > TRACE0("Failed to create toolbar\n"); > > return -1; // fail to create > > } > > > // TODO: Remove this if you don't want tool tips or a > > // resizeable toolbar > > m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | > > CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); > > > // 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 0; > > > } > > > it compiles and runs and halts into an ASSERT in winfrm2.cpp (line > > 92) : > > > void CFrameWnd::DockControlBar(CControlBar* pBar, CDockBar* pDockBar, > > LPCRECT lpRect) > > { > > ENSURE_ARG(pBar != NULL); > > // make sure CControlBar::EnableDocking has been called > > ASSERT(pBar->m_pDockContext != NULL); > > > if (pDockBar == NULL) > > { > > for (int i = 0; i < 4; i++) > > { > > if ((dwDockBarMap[i][1] & CBRS_ALIGN_ANY) == > > (pBar->m_dwStyle & CBRS_ALIGN_ANY)) > > { > > pDockBar = (CDockBar*)GetControlBar(dwDockBarMap[i][0]); > > /* --------> goes wrong here ------> */ ASSERT(pDockBar != NULL); > > // assert fails when initial CBRS_ of bar does not > > // match available docking sites, as set by EnableDocking() > > break; > > } > > } > > } > > ENSURE_ARG(pDockBar != NULL); > > ASSERT(m_listControlBars.Find(pBar) != NULL); > > ASSERT(pBar->m_pDockSite == this); > > // if this assertion occurred it is because the parent of pBar was > > not initially > > // this CFrameWnd when pBar's OnCreate was called > > // i.e. this control bar should have been created with a different > > parent initially > > > pDockBar->DockControlBar(pBar, lpRect); > > > } > > > in line 92 : > > > ASSERT(pDockBar != NULL); > > // assert fails when initial CBRS_ of bar does not > > // match available docking sites, as set by EnableDocking() > > > the source here even gives some explanation of what goes wrong here > > but i dont know how to match 'initial CBRS_ of bar with those set by > > EnableDocking()'' > > > Does this even work for a CMDIChildWndEx derived CChildFrame class ? > > > Well so my question is does any one know how to add a toolbar to a > > CMDIChildWndEx derived CChildFrame class ? > > Any suggestions on how to get this working ? > > My project is here maybe someone could take a look at it : > > http://www.4shared.com/file/235762968/49b8b97a/GUI50.html- Tekst uit oorspronkelijk bericht niet weergeven - > > - Tekst uit oorspronkelijk bericht weergeven - I tried some more and found out that this works for a CMFCToolBar : int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1) return -1; m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_CHILDFRAME); m_wndToolBar.LoadToolBar(IDR_CHILDFRAME, 0, 0, TRUE ); m_wndToolBar.SetPaneStyle( CBRS_TOOLTIPS | CBRS_FLYBY| CBRS_BOTTOM); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndToolBar); return 0; } |