Skip to main content

Using a ACTIVEX with Visual Cobol - WPF

  • February 20, 2017
  • 15 replies
  • 0 views

Alberto Ferraz

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

15 replies

Chris Glazier
Forum|alt.badge.img+2

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

Your post has WPF at the end of it so I am assuming that this is a WPF managed COBOL project, correct? Most vendors these days provide a .NET equivalent control to any ActiveX or COM control that they produce. You do not mention who the vendor is but if this is the case then you should really be using the .NET version of the control in a managed code environment as ActiveX controls are really based on unmanaged technology.

However, you can incorporate ActiveX/COM controls into a managed project. After registering the ActiveX control on your system you can add a project reference to it by right-clicking on the References folder and selecting Add Reference and then use the COM tab to select your control from the list. You should then be able to instantiate the control and set its properties, invoke its methods etc using OO-COBOL syntax.

Alberto Ferraz
  • Author
  • Participating Frequently
  • February 21, 2017

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

Hi Cris,
Yes I am using a project in wpf.

The activex that I need to use is from a TCP / IP controller vendor and does not have the .NET version. It is already an old version of ActiveX and has not been updated.

I already added the Activex in the References but it appears with a (!) Sign. I do not know if something is missing or not.

Now regarding OO-COBOL is that I do not know anything so I still have to go search.

Can you send me an example that has a part of OO-COBOL so I can start to see how it's used?

Thanks agains
Alberto Ferraz

Alberto Ferraz
  • Author
  • Participating Frequently
  • February 21, 2017

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

Hi,

I have already installed ActiveX and no longer gives the REFERENCES error.

I send a print of the functions it allows to use.
Although I only need a few I think that when I can use one I can use all of them, it's just a matter of command and parameters.

I do not know if this information makes it easier for me to understand what I want.

 

 

Thanks

Alberto Ferraz


Chris Glazier
Forum|alt.badge.img+2

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

I am working with limited info here but it looks like you could do something like the following:

declare myIOBCtrl as type IOBCtrlClass = new IOBCtrlClass
declare myshort as binary-short = 5
invoke myIOBCtrl::Aboutbox
invoke myIOBCtrl::Beep("TEST", myshort)

Alberto Ferraz
  • Author
  • Participating Frequently
  • February 21, 2017

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

Thanks for the info. I think it will be a good start and I will start testing.

I only have the manual in Portuguese but I translated some of the functions that I will have to use.

To help some have the example in VB.

I think that with these instructions you can already have an idea of what is needed.

 


 

Comunications functions

 

• OpenCom – Initializes the communication between the terminal and the pc

 

Entry parameters:

o szIPAddress (String) – IP address of the terminal (usually 192.168.0.55)

o nPort (Inteiro) – Communications Port (usually 715)

 

Return value (Integer):

o 0 – Communication started, IP address found;

o 1 – Failed communication attempt (check connections and port)

o 2 – Communication started, IP address not found (check IP address)

o 3 – Memory error

 

Example (VB): nReturnCode = OpenCom (“192.168.0.55”, 715)

 



• CloseBoard – Close the communication between the terminal and the pc

 

Entry parameters:

o szIPAddress (String) – IP address of the terminal

 

Return value: none

 

Example (VB): CloseBoard “192.168.0.55”


 Beep – Activates the beetle with a predefined ring sequence.

 

Entry parameters:

o szIPAddress (String) – IP address of the terminal

o nType (Inteiro) – Sequence of rings can take values between 0 and 26. There are 27 predefined sequences

 

Return value: none

 

Example (VB): Beep “192.168.0.55”, 1 


 

Switch – Enables or disables terminal components.

 

Entry parameters:

o szIPAddress (String) – IP address of the terminal

o nType (Inteiro) – Component number. This number can be one of the following:

• 1 – Screen backlight (EO, EBO);

• 2 – Beep (IOB, IOX, EO, EBO);

• 3 – Out 220V (IOB, IOX, EO, EBO);

• 4 – Red Led (IOB);

• 5 – Yelow Led (IOB);

• 6 – Green Led (IOB, EO, EBO);

• 7 – Conector CN2 (IOB, IOX, MIO), Sirene (EO, EBO);

• 8 – Conector CN3 (IOB), Trinco (EO, EBO);

• 9 – Conector CN4 (IOB);

• 10 – Conector CN5 (IOB);

• 11 – External reader led 0 (IOB, MIO, EO, EBO);

• 12 – External reader led 1 (IOB, EO, EBO);

• 13 – Sensor Bio (EBO).

o bOnOff (True/False) – Enables / disables the component.

 

Legend: IOB – IOBoard, IOX – IOBox, MIO – miniIOBoard, EO – Evolution 3 Online,

EBO – Evolution 3 Bio Online. Commands only work on the specified terminals.

 

Return value: (True/False):

o True – Operation carried out successfully;

o False – Failed to send the message (check communications, IP address, value of

NType).


Events received from ioboard

 

• ComOpen – Indicates that communication between the terminals and the PC has started.

 

Output Parameters: None



• BoardOpen – Indicates that communication between one of the terminals and the PC has started.

 

Output Parameters:

o szIPAddress (String) – IP address of the terminal whose communication has started.



• BoardClosed – Indicates that communication between one of the terminals and the PC has stoped

 

Output Parameters:

o szIPAddress (String) – IP address of the terminal whose communication has started.

 



• ComClose – Indicates that communication between all of the terminals and the PC has stoped

Output Parameters: None 



• Keyboard – Indicates that a key on the keyboard has been pressed.

 

Output Parameters:

o szIPAddress (String) – IP address of the terminal that generated the event.

o szKey (String) – ASCII character corresponding to the key pressed. 

 



• Reader – Indicates an entry in a card reader.

 

Output Parameters:

o szIPAddress (String) – IP address of the terminal that generated the event.

o szValue (String) – Text sent by the reader.

o nReader (Inteiro) – Number of the player that generated the event (0 or 1).


Alberto Ferraz
  • Author
  • Participating Frequently
  • February 22, 2017

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

Hi
I was starting to do tests and when I use the command
Declare myIOBCtrl as type IOBCtrlClass = new IOBCtrlClass
Gives the error that IOBCtrlClass was not found

I do not know if you have to define anything before

Thanks

Alberto Ferraz
  • Author
  • Participating Frequently
  • February 27, 2017

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

Hi again,
I've already managed to overcome the compilation error by changing the statement to:

declare myIOBCtrl as type IOBCTRLLib.IOBCtrlClass = new IOBCTRLLib.IOBCtrlClass
declare szIPAddress as string = "192.168.1.1"
declare nport as binary-short = 715
declare myshort as binary-short = 5
invoke myIOBCtrl::OpenCom(szIPAddress, nPort)
invoke myIOBCtrl::Beep(szIPAddress, myshort)

Now running the application gives the following error at the first declare:
Failed to get COM's class factory from the component with CLSID {26D6FAA0-34E3-4623-8386-4C286E7E1B4D} due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
(This is more or less because the error message is in Portuguese).

Can you help me?

Thanks
Alberto Ferraz

Chris Glazier
Forum|alt.badge.img+2

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

The error indicates that it cannot locate the COM server through its registration. I noticed that your project was set to type anyCPU. This may not work for an ActiveX control. Is the control 32-bit or 64-bit? If it is 32-bit then you should change your project settings to use x86 instead of anyCPU.

Alberto Ferraz
  • Author
  • Participating Frequently
  • March 2, 2017

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

Hi Chris,
I have already changed Target to x86 and I have already exceeded the error I was giving because it already passes the statement "declare myIOBCtrl as type IOBCtrlClass = new IOBCtrlClass"
It looks like the ActiveX is 32 bits.

Now the problem is later: running the "invoke myIOBCtrl :: OpenCom (szIPAddress, nPort)" statement gives the following error: "
Catastrophic Failure (Exception HRESULT: 0x8000FFFF (E_UNEXPECTED)) ".

I do not know if it is because the "OpenCom (szIPAddress, nPort)" instruction has a return value and this is not being predicted.
The instruction in VB is "nReturnCode = OpenCom (zsIPAddress, nPort)".

How can I use the OpenCom statement and get the return value?

Already another question: what differences can there be in the application if it is configured for x86 or x64?

Thanks again for the help.

Best regards
Alberto Ferraz

Chris Glazier
Forum|alt.badge.img+2

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

Example (VB): nReturnCode = OpenCom (“192.168.0.55”, 715)

This in COBOL would be something like:

declare nReturnCode as binary-long = 0
declare szIPAddress as string = z"192.168.0.55" *> expecting null terminated string perhaps?
declare nPort as binary-long = 715

set nReturnCode to myIOBCtrl::OpenCom(szIPAddress, by value nPort)

Alberto Ferraz
  • Author
  • Participating Frequently
  • March 2, 2017

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

I've tried with the new instructions and unfortunately it gives the exact same error.

declare myIOBCtrl as type IOBCtrlClass = new IOBCtrlClass
declare szIPAddress as string = z"192.168.1.1"
declare nport as binary-long = 715
declare nReturnCode as binary-long = 0

set nReturnCode to myIOBCtrl::OpenCom(szIPAddress, by value nPort)


I think the variables are well defined.

I've been searching on NET and found nothing obvious.

I do not know what else to do. Do you have any more tips?

I can send the ActiveX file to try it if you think it's a possibility.

Chris Glazier
Forum|alt.badge.img+2

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

This appears to be a problem within the ActiveX module itself. Have you tried calling it from a simple VB.NET or C# program to see if the problem is specific to COBOL?

Can you provide me a link to where you got the ActiveX? I Googled the class name and didn't get any hits at all.

Alberto Ferraz
  • Author
  • Participating Frequently
  • March 2, 2017

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

I have no possibility or knowledge yet to do tests in VB.NET or C # so I need your help.

The link is this: acronym-it.com/iobcontrol
On the bottom of the screen is the IOBControl download.
Running the.exe creates an Acronym folder in c: \\ Program Files (x86).
Inside this folder has the .ocx, the manual and some examples.

Chris Glazier
Forum|alt.badge.img+2

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

I tested this under C# and I get the same error so it has nothing to do with COBOL. I actually get the same error when I try to invoke the simple AboutBox method which takes no parameters.

There is a test program that comes with the control which is a VB6 program which is extremely old but that appears to work correctly. This is of course native code and not managed. I tested from a native COBOL program as well and it also failed.

You should contact Acronym and ask them if they have an example of calling this from C# and then we can get it to work in COBOL.

Alberto Ferraz
  • Author
  • Participating Frequently
  • July 9, 2017

Hi,

I need to use an ActiveX from a vendor to control ioboards.

How do I incorporate ActiveX into my program?

Thanks

Alberto Ferraz

Good afternoon:
I return to the forum with the continuation of the problem I had but now I am going more advanced.
I bought a new IoBoard to a new vendor that has an API (NuxIOAPI.DLL) and now I can already enter it in the application and send some controls to it (type releto, activate a port, etc).

Now the problem I have is the reverse: how to receive an IoBoard event.
The command that is required and that is in the documentation is as follows:
ValueEnteredEvent (object sender, ValueEnteredEventArgs, and)

Can anyone help me?

Thank you
Alberto Ferraz