Print Page | Close Window

How to add commandbars to MDIChild window?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=10846
Printed Date: 27 June 2025 at 7:30am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to add commandbars to MDIChild window?
Posted By: Howard Farseer
Subject: How to add commandbars to MDIChild window?
Date Posted: 31 May 2008 at 1:20am
I've tried my way like this:
VERIFY(m_wndToolBar.CreateToolBar(WS_VISIBLE | WS_CHILD |
   CBRS_TOOLTIPS | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, this));
  VERIFY(m_wndToolBar.LoadToolBar(IDR_SPLIT_ADDRESSBAR/*IDR_EXPLORER_BAR*/));
 
but this toolbar doesn't has all features as toolbars in main frame window.
Especially it has no effect when i set xtpFlagStretched flag,.The custom control didn't  stretch while the same one in mainwnd toolbar did.



Replies:
Posted By: mgampi
Date Posted: 31 May 2008 at 6:09am

Hi,
Take a look at http://forum.codejock.com/forum_posts.asp?TID=9230 - http://forum.codejock.com/forum_posts.asp?TID=9230 .



-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: Howard Farseer
Date Posted: 31 May 2008 at 2:37pm
Originally posted by mgampi mgampi wrote:

Hi,
Take a look at http://forum.codejock.com/forum_posts.asp?TID=9230 - http://forum.codejock.com/forum_posts.asp?TID=9230 .

 
 
thank you very much! It really works!


Posted By: Shinonome
Date Posted: 22 July 2008 at 8:29am
I want to attach the toolbar in MDI child window of a CWnd.
It doesn't function though it wrote referring to 'http://forum.codejock.com/forum_posts.asp?TID=9230'.
I want to write it on the class that derives from not CMDIChildWnd but CWnd.
What is insufficient?

1) Create MDI Application without Document/View architecture.
2) Add OnCreate method in CChildView.
3) Edit OnCreate method, Constructor and destructor.

-------------------------------------------------------------------------

class CChildView : public CWnd
{
public:
     CChildView() ;
     virtual ~CChildView() ;

protected :
     virtual BOOL PreCreateWindow( CREATESTRUCT& cs ) ;

protected :
     afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct ) ;
     afx_msg void OnPaint() ;
     DECLARE_MESSAGE_MAP()

     CXTPCommandBars*     m_lpxtpCmdBars ;
} ;


CChildView::CChildView()
{
     m_lpxtpCmdBars = CXTPCommandBars::CreateCommandBars() ;
}

CChildView::~CChildView()
{
     m_lpxtpCmdBars->InternalRelease() ;
}

BEGIN_MESSAGE_MAP( CChildView, CWnd )
     ON_WM_PAINT()
     ON_WM_CREATE()
END_MESSAGE_MAP()

BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
{
     if( ! CWnd::PreCreateWindow( cs )) return FALSE ;

     cs.dwExStyle |= WS_EX_CLIENTEDGE;
     cs.style      &= ~WS_BORDER;
     cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, ::LoadCursor( NULL, IDC_ARROW ), reinterpret_cast< HBRUSH >( COLOR_WINDOW + 1 ), NULL ) ;

     return TRUE ;
}

void CChildView::OnPaint()
{
     CPaintDC dc( this ) ;
}

int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
     if( CWnd::OnCreate(lpCreateStruct ) == -1 ) return -1 ;

     m_lpxtpCmdBars->GetToolTipContext()->SetStyle( xtpToolTipStandard ) ;
     m_lpxtpCmdBars->SetSite( this ) ;
     m_lpxtpCmdBars->EnableCustomization( FALSE ) ;
     m_lpxtpCmdBars->EnableDocking();

     // Create ToolBar
     CXTPToolBar* lpxtpToolBar = (CXTPToolBar*)m_lpxtpCmdBars->Add( L"Standard", xtpBarBottom ) ;
     if( ! lpxtpToolBar || !lpxtpToolBar->LoadToolBar( IDR_MAINFRAME ))
     {
          TRACE0( "Failed to create toolbar\n" ) ;
          return -1 ;
     }
     lpxtpToolBar->SetShowGripper( FALSE ) ;
     lpxtpToolBar->ShowExpandButton( FALSE ) ;
     lpxtpToolBar->EnableDocking( xtpFlagAlignBottom ) ;

     return 0 ;
}

-------------------------------------------------------------------------


Posted By: Oleg
Date Posted: 23 July 2008 at 1:52am
Hi,
 
Also catch OnSize and add
 
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Shinonome
Date Posted: 23 July 2008 at 2:05am
I was quite inconsiderate in OnSize.
Thank you Oleg !




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net