![]() |
Ribbon. Dynamic content for xtpControlButtonPopup |
Post Reply ![]() |
Author | |
Bart6 ![]() Groupie ![]() ![]() Joined: 22 March 2009 Location: Belgium Status: Offline Points: 20 |
![]() ![]() ![]() ![]() ![]() 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 |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi, Check DynamicPopups sample.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
Bart6 ![]() Groupie ![]() ![]() Joined: 22 March 2009 Location: Belgium Status: Offline Points: 20 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 931 |
![]() ![]() ![]() ![]() ![]() |
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 (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 ... |
|
![]() |
|
Bart6 ![]() Groupie ![]() ![]() Joined: 22 March 2009 Location: Belgium Status: Offline Points: 20 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
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 |