![]() |
Dll embeded FrameWnd wont load Toolbars |
Post Reply ![]() |
Author | |
johnmichael ![]() Groupie ![]() Joined: 30 June 2009 Location: United Kingdom Status: Offline Points: 18 |
![]() ![]() ![]() ![]() ![]() Posted: 27 August 2009 at 4:38am |
Hello, similar to the menus I have the problem that trying to use th CXTPCommandBars functions for loading menus and toolbars wont work:
here is the code as I think it should work with codejock CXTPCommandBars <code> BOOL CComponentEditorDialog::OnInitDialog() { LoadAccelTable( MAKEINTRESOURCE(IDR_COMPONENT_EDITOR_MENU) ); CRect rc; GetClientRect( &rc ); HMENU menu = LoadMenu(GetHInstance(),MAKEINTRESOURCE(IDR_COMPONENT_EDITOR_MENU)); CMenu * pMenu = new CMenu(); if ( pMenu ) { if ( pMenu->Attach(menu) ) { TRACE0("success created menu bar\n"); } else { TRACE0("Failed to create menu bar\n"); } } try { if (!InitCommandBars()) { return -1; } } catch (CResourceException *e) { e->Delete(); return -1; } // Get a pointer to the command bars object. CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars == NULL) { TRACE0("Failed to create command bars object.\n"); return -1; } CXTPCommandBar * pMenuBar = pCommandBars->Add(_T("Menu Bar"),xtpBarTop); if ( pMenuBar == NULL ) { TRACE0("Failed to create menu bar\n"); } else { pMenuBar->LoadMenu(pMenu); pMenuBar->SetFlags(xtpFlagStretched|xtpFlagNoMovable); pMenuBar->EnableCustomization(FALSE); pMenuBar->SetShowGripper(FALSE); } CXTPToolBar *pStdToolBar = pCommandBars->Add( _T("Component ToolBar"),xtpBarTop ); pStdToolBar->LoadToolBar(IDR_COMPONENT_TOOLBAR); //This fails to load I think because its not using the correct module to load the resource from GetDockingPaneManager()->InstallDockingPanes(this); GetDockingPaneManager()->SetTheme(xtpPaneThemeOffice2003); GetDockingPaneManager()->SetThemedFloatingFrames(TRUE); GetDockingPaneManager()->SetAlphaDockingContext(TRUE); GetDockingPaneManager()->SetShowDockingContextStickers(TRUE); m_componentGraph.Create(WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE,rc,this,AFX_IDW_PANE_FIRST); return TRUE; } </code> here is the code I had to develop to load the menu and toolbars manually. However with the toolbar there is no easy way to convert it to a CXTPToolbar from what I can tell so it is not skinned and looks like a standard windows 9x toolbar: <code> BOOL CComponentEditorDialog::OnInitDialog() { LoadAccelTable( MAKEINTRESOURCE(IDR_COMPONENT_EDITOR_MENU) ); CRect rc; GetClientRect( &rc ); HMENU menu = LoadMenu(GetHInstance(),MAKEINTRESOURCE(IDR_COMPONENT_EDITOR_MENU)); CMenu * pMenu = new CMenu(); if ( pMenu ) { if ( pMenu->Attach(menu) ) { TRACE0("success created menu bar\n"); } else { TRACE0("Failed to create menu bar\n"); } } try { if (!InitCommandBars()) { return -1; } } catch (CResourceException *e) { e->Delete(); return -1; } // Get a pointer to the command bars object. CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars == NULL) { TRACE0("Failed to create command bars object.\n"); return -1; } CXTPCommandBar * pMenuBar = pCommandBars->Add(_T("Menu Bar"),xtpBarTop); if ( pMenuBar == NULL ) { TRACE0("Failed to create menu bar\n"); } else { pMenuBar->LoadMenu(pMenu); pMenuBar->SetFlags(xtpFlagStretched|xtpFlagNoMovable); pMenuBar->EnableCustomization(FALSE); pMenuBar->SetShowGripper(FALSE); } // the following code creates a toolbar adds the command ids to it and then loads its relevant bitmap uint m_ids[ID_COMPONENT_TOOLBAR_END-ID_COMPONENT_TOOLBAR_OPEN]; if ( !m_toolbar.CreateEx(this) ) { TRACE0("Failed to create tool bar\n"); } else { for(int id = 0; id < ID_COMPONENT_TOOLBAR_END-ID_COMPONENT_TOOLBAR_OPEN; id++ ) { m_ids[id] = ID_COMPONENT_TOOLBAR_OPEN+id; } if ( m_toolbar.SetButtons(m_ids,ID_COMPONENT_TOOLBAR_END-ID_COMPONENT_TOOLBAR_OPEN) ) { if ( !m_toolbar.SetBitmap(LoadBitmap(GetHInstance(),MAKEINTRESOURCE(IDR_COMPONENT_TOOLBAR))) ) { TRACE0("Failed to create bitmap from tool bar\n"); } } } GetDockingPaneManager()->InstallDockingPanes(this); GetDockingPaneManager()->SetTheme(xtpPaneThemeOffice2003); GetDockingPaneManager()->SetThemedFloatingFrames(TRUE); GetDockingPaneManager()->SetAlphaDockingContext(TRUE); GetDockingPaneManager()->SetShowDockingContextStickers(TRUE); m_componentGraph.Create(WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE,rc,this,AFX_IDW_PANE_FIRST); return TRUE; } </code> Again I think this is a bug with the CXTPCommandBars failing to load the resources from the correct Module. Because specifying the module and resource to load manually succeeds. Is there away to convert my manual loading of the resource into a CXTPToolBar so that it gets skinned correctly as with the Menubar? regards |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hello,
With standard Menu and toolbar you manually pass instance to your dll - GetHInstance()
so how CommandBars should find them ???
Just set your dll as default resource insance - AfxSetResourceHandle(GetHInstance());
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
johnmichael ![]() Groupie ![]() Joined: 30 June 2009 Location: United Kingdom Status: Offline Points: 18 |
![]() ![]() ![]() ![]() ![]() |
yes this works better for menus and toolbars and does not affect the rest of the application
|
|
![]() |
|
fjosesen ![]() Groupie ![]() ![]() Joined: 30 June 2008 Status: Offline Points: 49 |
![]() ![]() ![]() ![]() ![]() |
Hi, Thanks in advance, FJSen |
|
Products: Suite Pro (ActiveX) v18.0.1
Toolkit Pro (MFC) v18.0.1 Platform: Windows 10 (64bit) Language: VC++ 2013 (MFC) |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |