Print Page | Close Window

Ribbon. Dynamic content for xtpControlButtonPopup

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=14074
Printed Date: 22 June 2025 at 2:53pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Ribbon. Dynamic content for xtpControlButtonPopup
Posted By: Bart6
Subject: Ribbon. Dynamic content for xtpControlButtonPopup
Date Posted: 19 April 2009 at 11:39am
Hi all,

In my application (3D scene editor) i would like to populate the content of xtpControlButtonPopup dynamically with the available cameras. (the amount of cameras can be determined by the user).

In Mainframe I currently create a ribbon group and hardcode the xtpControlButtonPopup:

CXTPRibbonGroup* pSceneCameras = pTabPageScene->AddGroup(ID_SCENE_CAMERAS);
CXTPControl* pCameraPopup = pSceneCameras->Add(xtpControlButtonPopup, ID_CAMERAS_LIST);
pCameraPopup->SetCaption(TEXT("<name_ of active camera>")); // TODO: do this somewhere at runtime
pCameraPopup->GetCommandBar()->GetControls()->Add(new CXTPControlLabel(), ID_CAMERA_ACTIVE);
CXTPControl* pCameraItem1 = pCameraPopup->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_CAMERA);
pCameraPopup->GetCommandBar()->GetControls()->Add(new CXTPControlLabel(), ID_CAMERA_AVAILABLE);
CXTPControl* pCameraItem2 = pCameraPopup->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_CAMERA);
CXTPControl* pCameraItem3 = pCameraPopup->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_CAMERA);
// separator
CXTPControl* pCameraItem4 = pCameraPopup->GetCommandBar()->GetControls()->Add(xtpControlButton, ID_CAMERA_NEW);


Q: is there an example i can look at that populates the xtpControlButtonPopup at runtime - or if it doesn't, what is the best way to do it.

Thanks
Bart



Replies:
Posted By: Oleg
Date Posted: 20 April 2009 at 2:20am

Hi,

Check DynamicPopups sample.


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


Posted By: Bart6
Date Posted: 20 April 2009 at 4:40am
Thanks Oleg,
 
The dynamic Popup sample creates the content once, in the OnCreateControl member of CMainFrame. From then on, it doesn't change anymore (as far as i can see)
 
What i'm looking for is that i set the content each time the user clicks on the control (so i can set the control content, based on an internal collection - that changes from time to time during the coarse of time)
 
Bart


Posted By: rdhd
Date Posted: 20 April 2009 at 3:46pm
You can obtain the popup at any time. You probably want to do that whenever your internal collection changes. Otherwise you will have to try and intercept the user's click (possibly by subclassing the popup control).
 
Use the CXTPCommandBars::FindControl member to find your popup. A popup has its own command bar. So once you have the CXTPControlPopup returned from the first call, call the GetCommandBar member of the popup object and then the GetControls method of the command bar. Then it's probably easiest to simply call RemoveAll on the controls object and then repopulate the controls. No pun intended.
 

if (CXTPCommandBars* pCommandBars = pMainFrame->GetCommandBars())

{

if (CXTPControl* pControl = pCommandBars->FindControl(xtpControlError, nApplicationDefinedControlId, FALSE, TRUE))

{

XTPControlType Type = pControl->GetType();

if( xtpControlPopup == Type )

{

CXTPControlPopup* pPopupControl = (CXTPControlPopup*)pControl;

if( pPopupControl )

{

CXTPCommandBar* pCommandBar = pControl->GetCommandBar();

if( pCommandBar )

{

CXTPControls popupControls = pCommandBar->GetControls();

 
if( popupControls )
{
popupControls->RemoveAll();
 
for( int Index = 0; Index < nNumberOfNewControls; Index++ )
{
popupControls->Add( ... );
}
}
 
}

}

}

}

}

Above code not guranteed to compile. I copied some from an app and then modified in this reply ...



Posted By: Bart6
Date Posted: 21 April 2009 at 9:59am
Thanks rdhd, good suggestion.
I have the incoming events that camera's are added or removed - so i can handle the control there as you suggest.
Cheers
Bart



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