Print Page | Close Window

How to find a control in a ribbon group

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=9518
Printed Date: 01 March 2025 at 12:13pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to find a control in a ribbon group
Posted By: rdhd
Subject: How to find a control in a ribbon group
Date Posted: 06 February 2008 at 4:59pm
The CXTPRibbonGroup has the methods I need to add a control. But it is not readily apparent which method I can call that will find a control already added to the group.
 
I tried calling CXTPRibbonGroup::GetAt(0). I then called the control GetCommandBar()->GetControls() method to get the contols object and then call its FindControl method.
 
However, if the first control is a xtpControlPopup control, the command bar controls returned only has the controls under the popup and not the controls of the group.
 
So how do I find a control on a CXTPRibbonGroup?



Replies:
Posted By: Oleg
Date Posted: 07 February 2008 at 12:44am
Hi,
FindControl have work. Do you set bRecursive parameter to TRUE ?


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


Posted By: rdhd
Date Posted: 07 February 2008 at 10:37am
I don't see a FindControl member of a group, nor will code compile if I try to call FindControl on a group. So the problem is not the recursive or visible flag. There is no CXTPRibbonGroup::FindControl.
 
I cannot call GetCommandBar on a group, nor GetControls. So again, I cannot figure out how to find a control in a specific group.
 
If I get ribbon bar the group belongs to I can wire up a call to FindControl but the call does not gurantee that the control belongs to the group I am interested in. Since controls are identified by their ID and the ID is a command ID and a command can exist in more than one place in the ribbon UI, I have this issue of not being able to find a control in a specific group. I could use SetTag to help ensure uniqueness but there is no FindControl call that searches using a tag. If The ribbon bar control's FindControl does return a control, I can get the group of the control. But if it is not the group I am searching, I cannot call FindControl again as it will keep finding the same control (no API to have FindControl start looking at the point it last found a control).
 
So, how do I go about finding a control on a specific group?
 
So far the only way I have is to get the group count and call GetAt until I exhaust all the controls or find the one I am interested in. Of course I have to catch popup controls so I can get their command bar's controls and do a FindControl in case the ID I am looking for is on a popup.
 
I tried calling pGroup->GetAt(0)->GetCommandBar()->GetControls() and then FindControl (recursive). However that fails if the first control is a popup as a popup has its own command bar and controls collection.


Posted By: Oleg
Date Posted: 07 February 2008 at 1:13pm

pRibbonBar->GetControls()->FindControl



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


Posted By: rdhd
Date Posted: 08 February 2008 at 12:36pm
pRibbonBar->GetControls()->FindControl is not sufficient to find a control in a specific group for the reasons I gave in my reply.
 
The call you suggest will only find the FIRST control with the given ID encountered in the ribbon. If there is more than one instance of a given command in the ribbon bar hierarchy, the call to FindControl will return the first control encounterd no matter how many times I make the call.
 
To see this, simply call Add(ID) using the same ID on two different ribbon groups. No matter how many times one calls FindControl(), FindControl will return the same CXTPControl pointer.
 
 
I see a tab has a "FindGroup" method.
 
A group has a "controls" collection member but no GetControls() method nor a FindControl() method.
 
Even a popup control has a round about way to restrict a control search to the control that appear under the popup. I can get a popup's command bar and the controls from the bar and then call FindControl. By debugging I have seen that the popup controls collection only contains the controls under the popup.
 
About the only missing search method in your API is one for finding a control in a specific group.
 


Posted By: Oleg
Date Posted: 08 February 2008 at 2:38pm
Hi,
Using GetCount, GetAt(Index) method you can quckly add external method to find control.


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



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