cObject
---DfComAutomationObject
------cComAutomationObject
---------cCJCommandBarComboBox
This provides a standard COM import wrapper for the Codejock CommandBarComboBox class.
All methods, properties and events are the standard COM interfaces for this class. In DataFlex each Codejock object or collection name is prefixed with "cCJ", each COM Property or method name is prefixed with "Com", and each event name is prefixed with "OnCom".
For an overview on the DataFlex implementation of the commandbar system, refer to Using Menus, Toolbars and Statusbars.
For more information about the Codejock COM commandbar system interface, refer to Codejock's Xtreme CommandBar documentation (class: CommandBarComboBox)
The following shows how a cCJMenuItem object is used to support combos
Object oViewsToolItem is a cCJMenuItem
Set peControlType to xtpControlComboBox
Procedure OnCreateControl Handle hoObj
Set ComDropDownWidth of hoObj to 300
Send FillComboList hoObj
End_Procedure
// This is a static example, OnPopupInit is not used
// Procedure OnPopupInit Variant vCommandBarControl Handle hoCommandBarControls
// Handle hoCombo
// Get CreateProxyControl vCommandBarControl to hoCombo
// Send FillComboList hoCombo
// Send Destroy of hoCombo
// End_Procedure
Procedure FillComboList Handle hoCombo
Send ComClear of hoCombo
Send ComAddItem of hoCombo "Order" 1
Set ComItemData of hoCombo 1 to msg_Activate_oOrderEntryView
Send ComAddItem of hoCombo "Customer" 2
Set ComItemData of hoCombo 2 to msg_Activate_oCustomerView
Send ComAddItem of hoCombo "Vendor" 3
Set ComItemData of hoCombo 3 to msg_Activate_oVendorView
End_Procedure
Procedure OnExecute Variant vCommandBarControl
Handle hMessage hoClient hoCombo
Integer iIndex
// create and bind proxy control
Get CreateProxyControl vCommandBarControl to hoCombo
// get the current selection
Get ComListIndex of hoCombo to iIndex
// note the index selections are 1 based
If (iIndex>0) Begin
// get the ItemData for the selected item and send that message
Get ComItemData of hoCombo iIndex to hMessage
If hMessage Begin
Get Client_Id to hoClient
Send hMessage of hoClient
End
End
// dispose of the proxy control
Send destroy of hoCombo
End_Procedure
End_ObjectIn all of the above samples, you know the combo control's COM dispatch pointer. The information is passed to you in the event. This will usually be the case. In these cases, you use CreateProxyControl to create the needed proxy object that interacts with the combo COM control.
If you need to access the combo control from some other object, you may not know what the COM pointer is. If this is the case you could find the combo control's COM pointer by calling the item's FindFirstControl function. This would provide you with the pointer you need to pass to CreateProxyControl
An alternate and easier technique would be to call the item's CreateFirstProxyControl function. This will find the first COM control assigned to the action's ID and, if found, create a bound proxy object for you.
This sample is similar to the combo sample above with the difference that the execution is triggered from a different object. In this case, an "Open View" button will be placed to the right of the combo form. Pressing that button will open the view currently selected in the combo.
Object oViewsToolItem is a cCJMenuItem
Set peControlType to xtpControlComboBox
Procedure OnCreateControl Handle hoObj
Send FillComboList hoObj
End_Procedure
Procedure FillComboList Handle hoCombo
Send ComClear of hoCombo
Send ComAddItem of hoCombo "Order" 1
Set ComItemData of hoCombo 1 to msg_Activate_oOrderEntryView
Send ComAddItem of hoCombo "Customer" 2
Set ComItemData of hoCombo 2 to msg_Activate_oCustomerView
Send ComAddItem of hoCombo "Vendor" 3
Set ComItemData of hoCombo 3 to msg_Activate_oVendorView
End_Procedure
// we do nothing in the Combo here... we do that in the next object
Procedure OnExecute Variant vCommandBarControl
End_Procedure
End_Object
Object oOpenView is a cCJMenuItem
Set psCaption to "Open View"
Procedure OnExecute Variant vCommandBarControl
Handle hMessage hoClient hoCombo
Integer iIndex
// We must find the combo control
Get CreateFirstProxyControl of oViewsToolItem to hoCombo
If hoCombo Begin
// Get the current selected value from the combo control
Get ComListIndex of hoCombo to iIndex
If (iIndex>0) Begin
Get ComItemData of hoCombo iIndex to hMessage
If hMessage Begin
Get Client_Id to hoClient
Send hMessage to hoClient
End
End
Send destroy of hoCombo
End
End_Procedure
End_Object