FindAllControls - cCJAction
Finds all COM controls that have the same ID as this action
Type: Function
Return Data Type: Variant[]
Syntax
Function FindAllControls Returns Variant[]
Call Example
Get FindAllControls to Variant[]Variable
Description
FindAllControls searches the commandbar system for the all controls that have the same piId as the action. It returns an array of variant pointers to the controls.
You should rarely need to use this method.
Most of the time you will know what the COM pointer is as this is passed to the action object when various events are called (OnExecute, OnPopupInit, OnCreateControl). When you already know the control's COM pointer you can create a proxy object by calling CreateProxyControl. If you don't know the control's COM pointer but there is only one control assigned to the action ID, which is typical, you can use the message CreateFirstProxyControl to find and bind the control.
If end users are allowed to edit and customize their menus and toolbars it is possible that there can be multiple controls assigned to the same action. In such a case, you may need to use this function. You would then need to bind each returned control to a proxy object control using the CreateProxyControl method.
This sample uses this method to determine if there is more than one control associated with this action and if there is to raise an error.
// find all controls associated with this cCJMenuItem object
Variant[] ArrayOfvControls
Integer iControls
Get FindAllControls to ArrayOfvControls
Move (SizeOfArray(ArrayOfvControls)) to iControls
If (iControls>1) Begin
Send Info_Box "You have duplicate controls for this action"
End
This sample shows how you use FindAllControls to find the control and bind it to a proxy object.
// find all controls associated with this cCJMenuItem object
Variant[] ArrayOfvControls
Handle hoEdit
Integer iControls i
Get FindAllControls to ArrayOfvControls
Move (SizeOfArray(ArrayOfvControls)) to iControls
For i from 0 to (iControls-1)
Get CreateProxyControl of oEditMenuItem ArrayOfvControls[i] to hoEdit
Get ComText of hoEdit to sText
:
Send destroy of hoEdit
Loop
Note that most of the time the action properties will provide you with all of the information you need and will not have to interact with the COM controls at all. The exceptions to this rule are the few controls that contain special information that is not maintained by the action. Menu items with peControlType types defined as combos (xtpControlComboBox) and edits (xtpControlEdit) are examples of this. See cCJCommandBarComboBox and cCJCommandBarEdit for more about working with these types of items.
Return Value
Returns a variant array of COM pointers that have the same Id as this action