Products & Services Solutions Academia Support User Community Company

Learn more about Gauges Blockset   

Using Your Own Microsoft ActiveX Control

See also Block Parameters for the ActiveX Control Block.

Adding the ActiveX Control Block to a Model

To use your own 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 some of the programming features of the control:

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 the appropriate values, described in subsequent sections.

      Note   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 has no effect. 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'));
propedit(temp.hActx);

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 an M-file 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)
propedit(varargin{1})

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:

{'keypress','axeventhandler'}

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:

{'keypress','ax_block_dclk'}

Colors of Controls

Controls that try to determine their colors by inheriting from the window in which they reside do not work properly in Simulink. 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.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS