Search
Hosting ActiveX Controls

( a feature of FlowChartX Pro edition)

FlowChartX can host other ActiveX controls in diagram nodes. Virtually every control can be used to display or edit entities that your application presents in entity-relationship diagrams. That might be a ready-made control such as calendar, grid or browser displaying an html-page. In addition, you might create a form/dialog control or custom-drawn one and integrate it seamlessly with FlowChartX. Hosted controls can be interactive, with embedded user interface and animations. Take a look at the 'ActiveX nodes' sample that comes with FlowChartX Pro to see how easy it is to use both custom and standard controls as nodes in a diagram.

Creating controls inside a node

You can instantiate an OCX inside a Box object simply by setting two box properties. Assign the class identifier of the control to the AxControlId property and set Style to bsAxControl. To specify that all boxes drawn by the user should automatically create and host controls, set the BoxStyle and AxControlId properties of the FlowChart object. The control's class identifier can be a ProgID such as "MSCAL.Calendar" or a CLSID such as "{8E27C92B-1264-101C-8A2F-040224009C02}". If the assigned string is not a valid control identifier, it is interpreted as an URL and a browser control is created and navigated to the specified link.

Instantiating licensed controls

ActiveX controls that require runtime license keys must have their keys specified via the AxLicenseKeys indexed property. Use the control's CLSID or ProgID as an index and the control's key as value of that property. Control creation will fail if a license key is required and it is not available in the AxLicenseKeys map. If you need to know what is the runtime key of a control, inquire its developers or publishers about that. They will give you that information as long as you are their registered customer.

Accessing hosted controls

The AxControl property returns a reference to the ActiveX control hosted inside a box. C++ programmers might prefer getting a pointer to the hosted control's IUnknown interface via AxRawPtr. The AxControl property returns IDispatch pointer, required by VB, but harder to use with C++.

Control activation

FlowChartX subclasses the window of any hosted control, in order to detect mouse actions performed on it. That allows carrying out move and resize operations as with ordinary diagram nodes. However, manipulation of an OCX node via mouse might interfere with some user-interface features of the control. For that reason FlowChartX can be directed to pass or filter mouse messages sent to the window of a hosted control. A control is considered as active when the mouse messages are passed to it. The ControlActivation property of boxes specifies how and when to activate a control. Default value can be assigned to the HostedAxActivation property of FlowChart.

Appearance

The appearance of control host nodes depends mostly on the values of the hosted control's properties. The only property of the Box class that affects the appearance of host nodes is the WindowFrame which allows setting the border style of the control windows. Another related property is ControlPadding, which sets how much space to leave between a hosted control and the box borders.

Handling events raised by hosted controls

To get event notifications from a control hosted inside a box, you must register the event sink interface with the control. First query the control for IConnectionPointContainer; via this interface get the IConnectionPoint pointer responsible for the required event interface. Via that pointer register your sink by calling Advise.

Example

To create a browser control and navigate to an URL, use code like this:

VB  Copy Code

Dim browser As SHDocVw.WebBrowser

'create the control
fc.ActiveBox.AxControlId = "Shell.Explorer"
fc.ActiveBox.Style = bsAxControl

'get reference to it
Set browser = fc.ActiveBox.AxControl
browser.Navigate "http://mindfusion.eu"