Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Ribbon. Dynamic content for xtpControlButtonPopup
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Ribbon. Dynamic content for xtpControlButtonPopup

 Post Reply Post Reply
Author
Message
Bart6 View Drop Down
Groupie
Groupie
Avatar

Joined: 22 March 2009
Location: Belgium
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bart6 Quote  Post ReplyReply Direct Link To This Post Topic: Ribbon. Dynamic content for xtpControlButtonPopup
    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
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: 20 April 2009 at 2:20am

Hi,

Check DynamicPopups sample.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Bart6 View Drop Down
Groupie
Groupie
Avatar

Joined: 22 March 2009
Location: Belgium
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bart6 Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 931
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post 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 ...

Back to Top
Bart6 View Drop Down
Groupie
Groupie
Avatar

Joined: 22 March 2009
Location: Belgium
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bart6 Quote  Post ReplyReply Direct Link To This Post 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
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.063 seconds.