Print Page | Close Window

Using Ribbon in a dialog

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=23364
Printed Date: 23 November 2024 at 9:08pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Using Ribbon in a dialog
Posted By: yves
Subject: Using Ribbon in a dialog
Date Posted: 05 June 2017 at 6:38pm
Hello. Is this possible to use Ribbon in a dialog? Does anyone have an example? Thanks.



Replies:
Posted By: Alex H.
Date Posted: 12 June 2017 at 9:23am
Hi!
Yes it works :-)

Have a look at:
Samples\CommandBars\DialogSample\DialogSampleDlg.cpp(197)

I can send you some snippets :-)

derive your dialog from
CXTPDialogBase<CXTResizeDialog>

in OnInitDialog create your commandbars

// Initialize the command bars if(!InitCommandBars()) { return -1; } // Get a pointer to the command bars object. CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars == NULL) { return -1;      // fail to create }
 then create your ribbon:

CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)pCommandBars->Add(_T(""), xtpBarTopRUNTIME_CLASS(CXTPRibbonBar)); if (!pRibbonBar) { return FALSE; }
pRibbonBar->EnableDocking(0); pRibbonBar->EnableCustomization(FALSE);
...

CXTPRibbonTab* pTabBase = pRibbonBar->AddTab( CMfxString(IDS_RIBBON_START) );
...

you will nedd a helper

//---------------------------------------------------------------------------------------  void CDlgMailNew::RepositionControls() //---------------------------------------------------------------------------------------  { if (m_bInRepositionControls) return; CRect rcClientStart; GetClientRect(rcClientStart); if ((GetStyle() & WS_MINIMIZE) || (rcClientStart.IsRectEmpty())) return; m_bInRepositionControls = TRUE; CRect rcClientNow; RepositionBars(AFX_IDW_CONTROLBAR_FIRSTAFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClientNow); CRect rcBorders(rcClientNow.left - rcClientStart.left, rcClientNow.top - rcClientStart.top,  rcClientStart.right - rcClientNow.right,  rcClientStart.bottom - rcClientNow.bottom); if (rcBorders != m_rcBorders) { CPoint ptOffset(rcBorders.left - m_rcBorders.left, rcBorders.top - m_rcBorders.top); CSize szOffset(rcBorders.left + rcBorders.right - m_rcBorders.left - m_rcBorders.right, rcBorders.top + rcBorders.bottom - m_rcBorders.top - m_rcBorders.bottom); m_ptRepositionOffset = ptOffset; CRect rcWindow; GetWindowRect(rcWindow); rcWindow.BottomRight() += szOffset; Offset(ptOffset); m_szWindow += szOffset; m_szMin += szOffset; MoveWindow(rcWindow, TRUE); } m_rcBorders = rcBorders; RepositionBars(AFX_IDW_CONTROLBAR_FIRSTAFX_IDW_CONTROLBAR_LAST, 0); m_bInRepositionControls = FALSE; }

----

call this helper in OnSize and in OnInitDialog

:-)




Posted By: cpede
Date Posted: 10 June 2020 at 2:48am
This was very useful for displaying Ribbons in a dialog.

But how do I remove/delete the Ribbon bar runtime from code in the dialog.

1) Using Remove on the Toolbar does not fully do the trick, since there still is an empty window/background in the ribbon area left?
2) SetVisible(FALSE) hides the toolbar but also leaves an empty window/background.
3) delete CommandBars is virtual and cannot be called

There is missing the opposite to InitCommandBars to fully remove the ribbon?

-cpede


-------------
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)



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