![]() |
How to find a control in a ribbon group |
Post Reply ![]() |
Author | |
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 899 |
![]() ![]() ![]() ![]() ![]() 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?
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
FindControl have work. Do you set bRecursive parameter to TRUE ?
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 899 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
pRibbonBar->GetControls()->FindControl |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 899 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
Using GetCount, GetAt(Index) method you can quckly add external method to find control.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
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 |