HACP & HATS User Group - Group home

Using ActiveX Controls to interact with IBM Personal Communications

By BADAL BURATHOKI posted Wed September 15, 2021 09:16 AM

  

Introduction

An ActiveX control is a reusable software component based on Component Object Model (COM) that supports a wide variety of OLE functionality. These controls can be used in any ActiveX container application. An ActiveX control container can be written in Visual C++, MS Excel, MS Word etc. and is a container that fully supports ActiveX controls. A container application can incorporate ActiveX controls into its own windows or dialogs.

PCOMM provides an ActiveX control, ‘PCOMM ctrX’ which allows user to embed a PCOMM session inside an ActiveX control container application. Once integrated, the PCOMM session gets embedded in the container application and users can seamlessly perform GUI operations and execute PCOMM emulator automation APIs (e.g. EHLLAPI & HACL) in this session.


Features

1.  By using ‘PCOMM ctrX’ in the container application, one can directly embed the PCOMM session in the ActiveX control or invoke the session at the run time (lazy loading).
2.  Users can launch PCOMM by providing below parameters:
      Session ID (optional):
       o   When set: This can be ranging from ‘A’ to ‘Z’.
       o   When not set: PCOMM session is launched with next available Session ID.
       o   Already existing/launched: Provides an option to the user to embed the same session in the  ActiveX control.

      Session Profile (mandatory): Users must provide a valid PCOMM .ws profile name, else the launch of embedded PCOMM will fail.
      o   Session Profile name may or may not have a ‘.ws’ extension.
      o   If path is not provided, then the default path is picked up from the registry.
      o   With Customized path, PCOMM is launched with the .ws file from customized path.

3.  Automation/Screen Scraping: Operations based on automation objects (HACL) and Emulator Programming (ELLAHPI) are supported.
4.  Menu and Toolbar items in the PCOMM session of ActiveX control are hidden.
5.  PCOMM ActiveX provides interfaces to control the embedded PCOMM session and is elaborated in the below sections.


Interfaces

PCOMM ActiveX control exposes below interfaces to interact with the container application:

CHAR pcsOcxStartSession (CHAR sessID, BSTR wsProfile): Starts PCOMM session in the ActiveX Control window by using a specified workstation profile and A (optional) short session ID can also be specified.

VARIANT_BOOL pcsOcxConnectSession(void): Connect the PCOMM emulator to the host data stream. This has the same effect as going to the PCOMM emulator Communication menu and choosing Connect.

VARIANT_BOOL pcsOcxDisconnectSession(void): Disconnect the PCOMM emulator to the host data stream. This has the same effect as going to the PCOMM emulator Communication menu and choosing Disconnect.


Adding ActiveX control in the Application

Once the pcsctrX.ocx file is registered in the system, it is available to be added in an ActiveX container application. Below are few methods to add PCOMM ActiveX control in a .NET winform applications.

Using Visual Studio Toolbar – This is the static invocation of the ActiveX.
1.       Open your client application project in Visual Studio (version 2005 or higher).
2.       Open the target GUI page in design mode and select Tools -> Choose Toolbox Items -> COM Components.
3.       Under Name column, select “PCOMM ctrX” and click OK.
4.       Draw the .OCX on the form.
5.       When the application is launched, you will see a black screen where .OCX was drawn.
6.       Right click anywhere on this black screen and click on ‘Connect’.

7.       In the dialog box, provide session ID (optional) and PCOMM Workstation profile file and click OK. You can use the Browse button to browse and select an existing ws profile file.
Session connect dialog box


8.       An embedded PCOMM session is started within the black screen area with a hidden menu and toolbar.

Embedded PCOMM Session


Runtime invocation of ActiveX control – This is a dynamic invocation of the ActiveX.
1.       Use ‘Program ID’ of pcsctrX.ocx to load the ActiveX Control in the Application. Program ID for pcsctrX.ocx is ‘PCOMM.ctrX’.
2.       Use ‘pcsOcxStartSession’ interface to start the PCOMM Session in above ActiveX Control.

Sample C# WinForm Application: pcsOcxStartSession


3.     Use ‘pcsOcxDisconnectSession’ to disconnect from the session in the ActiveX Control.

Sample C# WinForm Application: pcsOcxDisconnectSession


4.     Use ‘pcsOcxConnectSession’ to re-connect with the session in the ActiveX Control.

Sample C# WinForm Application: pcsOcxConnectSession


5.    Build and execute the container application. In this container application, a PCOMM session gets embedded with the next available session ID.

Sample C# WinForm Application: Initialization

More information on IBM PCOMM ActiveX control can be found at below link:
https://www.ibm.com/support/pages/node/568007

Contact

For further information on Automation, Services offerings or Technical details in IBM HACP/HATS please connect with HCL mainframe Lab services.

Badal Burathoki
Senior Technical Architect
Mainframe Lab services

0 comments
8 views