Highlighted
Absent Member.
Absent Member.
182 views

[archive] Passing Win Handle to VB.NET

[Migrated content. Thread originally posted on 16 February 2005]

I am using a VB.NET class (as an activex object) in a cobol program. The VB class eventually shows a windows form. The problem is that the form never receives focus...it always appears behind my cobol window.

I think I need to pass the handle of the cobol window to the VB class so I can set the cobol window as the owner of the vb form.

I added a property to the vb class of type object. This property appears as a type 12 variant in the def file for the class.

PROPERTY-PUTREF, 1610743810, @OwnerForm,
"VARIANT (Property Value)", TYPE 12

When I try to set this property from cobol with the cobol window handle, I get a memory access violation.

I am using INQUIRE WINDOW SYSTEM HANDLE to get the handle of the cobol window. I have tried passing the handle and passing a variant set to the value of that handle...neither work.

Any ideas?
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Passing Win Handle to VB.NET

First of all, it is difficult to state what really is your problem here. There may be a number of things and I am at first puzzled that you should need to set focus for an ActiveX. I suspect the real problem is here.

I would suggest to divide the problem in two: First, why won't your activex show, in order to determine that, we ought to have an example source to look at.

Your second issue that raise as a consequence of not managing issue 1, may also have various causes, I would like to see what your data definitions are and I would also like to suggest, as it seems to me you have the source for the component, can you use some sort of a debugging tool to check what your property is set as.

Aslo, as I always recommend when you do development of ActiveX yourself, go try it with other languages, and then not the originating language, the originating language (like if you made it with vb and then testing it with vb) tend to cover up for and forgive mistakes that would otherwise be disastrous. VB for instance is reknown for this. If you have Visual Studio installed, it has a sub folder Visual Studio Tools, in there is a tool named ActiveX test container. This gives you a great opportunity to test your tools.

Finally, how did you define your property to receive the window handle in the control? As a variant? That is not right, you should define it as a LONG or HANDLE.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Passing Win Handle to VB.NET

I had, perhaps, a similar problem using VB6. According to Acu Support:

In some cases this control would work if used upon a Modal window but does not on a Modeless window.
The issue went on to say that.......
Further investigation unveils that using modeless activex's like this, requires a technique called "Apartment model threading", which is not currently supported by ACUCOBOL-GT. Implementing such support is quite extensive, and as this technique is quite rarely implemented by activex controls, I am not so sure if it is likely we will support it either.


Our solution was:

frmForm1.show vbModal

I hope this help!
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.