Using a Custom ActiveX Control

Adding the ActiveX Control Block to a Model

To use a custom Microsoft® ActiveX® control in a Simulink® model, you must associate it with the generic ActiveX Control block. To configure the ActiveX Control block to display your control, you need to know:

  • The name under which the control is registered on your system

  • The events that cause the control to perform an action

  • The control properties that are changed by events, by signals passed to the block, or by initialization commands

To use an ActiveX Control block in a Simulink model:

  1. Drag the ActiveX Control block from the top level of the Gauges Blockset™ library to your model. Place the block where you want the control to appear.

  2. Double-click the block to display its Block Parameters dialog box. Specify values as described in subsequent sections.


      • Double-clicking the border of a preconfigured block (supplied with the blockset) displays its ActiveX Control Properties dialog box, which lists properties in multiple tabbed panels.

      • Double-clicking a block that you created by customizing the generic ActiveX Control block displays its Block Parameters dialog box.

Notes on Third-Party Controls

This section contains additional notes about third-party controls. One note is about editing controls that ignore mouse events, while another concerns the colors of controls.

Editing Controls That Ignore Mouse Events

Certain controls do not handle typical mouse events (double-click, right-click, etc.). It appears that you cannot edit these controls when you use them with the ActiveX Control block; double-clicking or right-clicking blocks that use these controls produces no response. To edit this type of block, you must first select the block so that it is current in the Simulink model. Then enter the following commands in the MATLAB® Command Window:

temp = get_param(gcb,'userdata'));

This opens the properties dialog box for that control. See the COM sections in the MATLAB documentation for more information on the propedit command and assigning event callbacks to controls.

Additionally, you can choose an event on your control through which you want to open the property editor. For example, write a function to open the property editor (or whatever you want the event to do). The function must take multiple arguments, of which the first one is the handle of the control. For example, a simple function to open the property editor of a control looks like this:

function axeventhandler(varargin)

Next enter an event with the handler you just wrote in the Other Events and Handlers parameter field. Assuming the keypress event is valid, the event and handler entry looks like this:


To use the error-checking code already written for Gauges Blockset software, you can enter ax_block_dclk for events that should open the property editor (note that the editor does not open when the simulation is running). For example, to make a keystroke open the property editor (assuming that the keypress event is valid), enter the event and handler pair as follows:


Colors of Controls

In Simulink, controls cannot determine their colors by inheriting them from the window in which they reside. More specifically, controls that send the WM_CTLCOLOR message to their parent have this problem. WM_CTLCOLOR is a Microsoft Windows® message sent by a control to enable the parent container to determine the color used by the control.

    Caution   Placing one of these controls in the ActiveX Control block causes MATLAB software to crash.

Was this topic helpful?