Print Page | Close Window

toolbar button with subitems

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=6918
Printed Date: 01 October 2024 at 2:01pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: toolbar button with subitems
Posted By: spelhatre
Subject: toolbar button with subitems
Date Posted: 18 April 2007 at 9:32am
I want to dynamically create a toolbar button with subitems in a dialogbox.
This is my code (pToolbar is my CXTPToolbar object):

CXTPControlPopup* pControlPopup = CXTPControlPopup::CreateControlPopup(xtpControlSplitButtonPopup);
pToolbar->GetControls()->Add( pControlPopup, 10 /*cmd id*/);
CXTPControl* q = pControlPopup->GetControls()->Add( xtpControlButton, 10);
 q->SetCaption( "hello1");
 q = pControlPopup->GetControls()->Add( xtpControlButton, 10 );
 q->SetCaption( "hello2");  
pToolbar ->GetParent()->RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 11);

With this code, I have my button with the dropdown arrow (call it  B1).
But items "hello1" and "hello2" and not subitems or B1 but are also buttons in the toolbar.
And I cannot use pControlPopup->GetCommandBar() object because it returns a NULL pointer.
How to do this?
 thanks




Replies:
Posted By: Oleg
Date Posted: 18 April 2007 at 3:07pm
Hello,
try something like:
 
CXTPControlPopup* pControlPopup = (CXTPControlPopup*)pToolbar->GetControls()->Add( xtpControlSplitButtonPopup, 10 /*cmd id*/);
CXTPControl* q = pControlPopup->GetCommandBar()->GetControls()->Add( xtpControlButton, 10);


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


Posted By: spelhatre
Date Posted: 19 April 2007 at 3:55am
thanks, it works.



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