ActiveX element

The ActiveX element serves for displaying a passive ActiveX Control within a visualization. The element is usable on Windows32 based systems in IEC 61131-3 editor HMI.

The configuration dialog is opened by a double-click on the Inserted element and offers three sub-dialogs, for selecting the control type, for defining method calls and for the configuration of the display:

Control:

../_images/6fcceaf24377e4e40a33139006eab46b

In this dialog you can mark the desired ActiveX Control in the selection list offering all ActiveX Controls which are registered on your computer.

Methodcalls:

../_images/d0e503a24377e4860a33139006eab46b

Here you configure the method calls for the chosen ActiveX Control:

Web browser:

These input fields only can be edited if you are configuring a control element which supports the ‘IWebBrowser’ interface (e.g. Internet Explorer or Mozilla Browser). In this case the method Navigate can be called (other method calls must be controlled via a user defined DLL, see below ‘Additional Call’).

Enter an URL as a parameter value in field  Variable for URL (Input as a string between inverted commas) resp. a project variable of type STRING defining an URL. The browser will be called as soon as the variable entered in field Condition for call gets TRUE (rising edge). If no call condition is defined here, in the Target-Visualization the browser will be called in each cycle of the visualization task!

Additional Call:

Via a user defined Windows-Dll you can define method calls for the ActiveX Control in order to control the behaviour of the control at a call. For this purpose you must enter the DLL in the field at DLL for Call. If you press the button you get the File Open dialog to browse for a DLL. If the DLL is in the visualization files directory which is specified in the project options, just the path relative to this directory will be entered, otherwise the complete file path.

Note

If the DLL is to be used on a runtime system with a Target-Visualization, it must explicitly be copied there. When the Control is called in the Target-Visualization, only the filename contained in the path will be regarded.

The DLL is called as soon as the variable defined below in Condition for call gets TRUE (rising edge). If no condition is specified, in the Target-Visualization it will be called in each cycle of the visualization task!

Regard the following when creating an appropriate DLL:

The DLL must export a method  “ExecuteActiveXCall” with this function prototype :

void ExecuteActiveXCall(IUnknown\*     pUnk, char\* pszId, char\* pszParam, char\* pszReturnBuffer, int nReturnBufferSize,     DWORD\* pdwReturnFlag);

The function will be called with the following parameters which can be defined in the configuration dialog:

  • pszId  :  string resp. string variable specified in field Methodidentification
  • pszParam :  value specified in field Parameter

The parameter pUnk allows a query of further  Com(ActiveX-)interfaces. With these interfaces you can call any Method on your ActiveX-Control with any parameters packed in a string!

The parameters pszReturnBuffer, nReturnBufferSize and pdwReturnFlag currently are not used.

Display:

../_images/8842d9a74377e4380a33139006eab46b

In this dialog you can specify the variables defining the position with X-Offset, Y-Offset (see Motion absolute) and visibility of the control element Invisible (see Variables).

Example of a DLL source file:

This example DLL will only call the methods GoBack or GoForward of the control if it supports the ‘IWebBrowser’ interface.

The method is chosen by the parameter pszId.

#include "stdafx.h"

#include <unknwn.h>

#include <exdisp.h>

BOOL APIENTRY DllMain( HANDLE     hModule,

DWORD      ul_reason_for_call,

LPVOID     lpReserved

)

{

return     TRUE;

}

extern "C" __declspec     (dllexport) void ExecuteActiveXCall(IUnknown\* pUnk, char\* pszId, char\*     pszParam,

char\*     pszReturnBuffer, int nReturnBufferSize, DWORD\* pdwReturnFlag)

{

if (strcmp(pszId, "IWebBrowser|GoBack")     == 0)

{

IUnknown\* pNewUnk;

IWebBrowser\* pwb;

pUnk->QueryInterface(IID_IWebBrowser,     (void\*\*) &pNewUnk);

pwb = (IWebBrowser\*) pNewUnk;

if (pwb)

{

pwb->GoBack();

pwb->Release();

}

}

else if (strcmp(pszId, "IWebBrowser|GoForward")     == 0)

{

IUnknown\* pNewUnk;

IWebBrowser\* pwb;

pUnk->QueryInterface(IID_IWebBrowser,     (void\*\*) &pNewUnk);

pwb = (IWebBrowser\*) pNewUnk;

if (pwb)

{

pwb->GoForward();

pwb->Release();

}

}

}