Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - How to add commandbars to MDIChild window?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to add commandbars to MDIChild window?

 Post Reply Post Reply
Author
Message
Howard Farseer View Drop Down
Groupie
Groupie


Joined: 30 September 2007
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote Howard Farseer Quote  Post ReplyReply Direct Link To This Post Topic: How to add commandbars to MDIChild window?
    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.
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 31 May 2008 at 6:09am
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
Howard Farseer View Drop Down
Groupie
Groupie


Joined: 30 September 2007
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote Howard Farseer Quote  Post ReplyReply Direct Link To This Post 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.

 
 
thank you very much! It really works!
Back to Top
Shinonome View Drop Down
Groupie
Groupie


Joined: 18 July 2008
Status: Offline
Points: 78
Post Options Post Options   Thanks (0) Thanks(0)   Quote Shinonome Quote  Post ReplyReply Direct Link To This Post 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 ;
}

-------------------------------------------------------------------------
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Shinonome View Drop Down
Groupie
Groupie


Joined: 18 July 2008
Status: Offline
Points: 78
Post Options Post Options   Thanks (0) Thanks(0)   Quote Shinonome Quote  Post ReplyReply Direct Link To This Post Posted: 23 July 2008 at 2:05am
I was quite inconsiderate in OnSize.
Thank you Oleg !

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.187 seconds.