Highlighted
Absent Member.
Absent Member.
1912 views

[archive] active-x objects

[Migrated content. Thread originally posted on 02 August 2007]

I am trying to write a cobol program using a com object. I have the sdk from the providing software company. After having problems even getting the vb6 example to work, the company sent me the following:

"All development partners should use late binding. Chameleon classes must be declared as objects." he gives the following example

dim objchameleon as Object
dim objApplication as Object
Set objchameleon = CreateObject("Chameleon.clsChameleon")

The def file is attached. Can someone tell me what this means and how to express it in Acucobol.
0 Likes
7 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] active-x objects

I am afraid this would not work if it is based on late binding as ACUCOBOL-GT does not support this.
However, the definition file you provide does not indicate this to be a late binding (in which case there should not be something to make a .def file for).
You do not state specifically what the problem is. But as for the lines you provide, try this:

77 myCarma USAGE HANDLE OF clsChameleon.
PROCEDURE DIVISION.
CREATE clsChameleon OF Chameleon HANDLE IN myCarma.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] active-x objects

The def file was created from an .exe file using adxfgen. I see the returnapplicaton method, but further down, I see nothing relating to .KeyByDisplayText. Is this due to the "late binding" and there being not def file for objapplication?

Complete Code snippet with the developing company's comments:

'We'll use this to return an instance of
'clsApplication in just a bit
Dim objChameleon As Object

'The main application object
Dim objApplication As Object

'Create an instance of the clsChameleon class
Set objChameleon = CreateObject("Chameleon.clsChameleon")

'Create a new instance of the clsApplication class,
'which in turn will start our application. If it's
'already running, return the starting application.
Set objApplication = objChameleon.ReturnApplication

'Assumes we're dealing with this object
'when using the .
With objApplication

'First, we need to check to see if a user is already logged in.
'If no one is, the username will be blank, otherwise it will be
'the currently logged in user's username.
If .UserName = "" Then

'If the user is not logged in, we will want to call the login
'function passing the username, password, and cabinet we want
'to log into. If Login fails we'll trap the error and exit.
If Not .Logon(True, "SYSOP", "ccs", "ap") Then
MsgBox .ErrorMessage
GoTo CleanUp
End If

End If

'Now, once we're all logged in and ready to go, let's
'do a search and display the matching invoices based on
'our search.
With .FieldDefinitions
.Item(.KeyByDisplayText("INVOICE#")).FieldValue = txtInvoiceNumber.Text
.Item(.KeyByDisplayText("VENDOR#")).FieldValue = txtVendorNumber.Text
End With

'Find and display the matching invoices
.LoadMatching

End With

CleanUp:
Set objChameleon = Nothing
Set objApplication = Nothing
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] active-x objects

The problem is, there is no definition for _clsFieldDefinitions. I suspect this is what they say is late binding then. For the rest of it, it is pretty straight forward. Of course I have no chance to test this as I do not have the component here. But this is as good as it gets.

77 objChameleon USAGE HANDLE OF clsChameleon.
77 objApplication USAGE HANDLE OF _clsApplication.
77 StrUser PIC X(1024).
77 NumRet PIC 9.
77 KeyInvoice PIC
PROCEDURE DIVISION.
CREATE clsChameleon OF Chameleon HANDLE IN objChameleon.
MODIFY objChameleon ReturnApplication() GIVING objApplication.
INQUIRE objApplication UserName IN StrUser.
If StrUser = SPACES
  MODIFY objApplication Logon(True, "SYSOP", "ccs", "ap") GIVING
         NumRet
  IF NumRet NOT = 1
   DISPLAY MESSAGE BOX TITLE "Error" "Could not log on"
   GOTO CleanUp
  END-IF
END-IF


It is odd though, if they mix late and early binding in one component. I can sort of not see the logic behind it.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] active-x objects

It appears I am not going to get a component with early binding. Do I have any other alternatives? Can I call the VB6 program which uses the late binding from an AcuCobol program? I would need to pass two parameters to the VB6 program then it could perform the function I wanted to do with AcuCobol. If this is possible could you point me to documentation or examples of AcuCobol calling VB6. Thanks,
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] active-x objects

You can make an ActiveX (windowless) with VB6 that exports methods that ACUCOBOL-GT can use, and then wrap the entire late binding inside VB6, absolutely.
If you make an ActiveX of the VB6 app, then there are plenty of examples around, also on this forum. Not because we have made so many examples of this for VB6 in particular, but because an ActiveX is an ActiveX, regardless of language.
Now, the reason I suggest you make an ActiveX is because this is the simplest thing to do with VB6. I believe you cannot make native Windows DLLs with VB6 and making a COM server is much more difficult than the ActiveX approach.

I suggest you make the ActiveX frontend in VB6 first and then I am sure we shall get you by the last mile.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] active-x objects

I have been a few weeks in responding as I have been studying examples, etc. I would just like to make sure I am going down the right path in trying to accomplish my objective. Any addtional advice is appreciated.

The vb6 code presented previously in this thread presents a window where the vendor and invoice number can be entered by the user. The program then calls the com object supplying the two data items and the com object will display a window the scanned file associated with the data supplied.

Since I cannot use this com product because of the late binding issue, you suggested I could write an active-x control in VB6 which would accept the two data fields from my acucobol program. This active-x control would then invoke the com object much the same way as the vb6 example I have except it would not present the user with the screen as the data would be passed to it from the acucobol program. I am not a vb6 programmer but I think I can learn enough from examples and texts to accomplish this,

First, am I on the right track here, 2nd, what do you mean exactly by windowless active-x? I assume it will work ok, when the com object itself displays a window, overlaying temporarily the acu-gt window?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] active-x objects

That the ActiveX is Windowless, is just a phrase stating it does not occupy any space on your form. The ActiveX itself is free to launch new windows.
For that matter, to avoid confusion, do not think about the windowless part, you can always make it invisible.
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.