Help needed : VB code to TD (ActiveX)

forum.advanced.programming (1998-2005)
Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3522
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Help needed : VB code to TD (ActiveX)

Post by Dave Rabelink » 18 Feb 2005, 09:02

 Posted by:  Dave Rabelink 

I am trying to get this small piece of VisualBasic code
to work in TD3.1. I did try it in TD1.5.1 some time ago, but
i could not get it working. So i build the VB application as
a wrapper around the functionality i needed.

Now i ported the CTD1.5.1 application to TD3.1 and would like
to get rid of the VB application and implement it in TD3.1 all the way.
But again i get stuck on 1 line of code which is not 1:1 portable.

So here the VB code to access ActiveX (COM) :

**** VB code for Login on ActiveX server Desk *****

Dim Desk As New GsAgentDesktopInfo
Dim DeskConn As IGsConnectionInfo

Set DeskConn = Desk
DeskConn.Host = "HostName"
DeskConn.Port = "PortName"

Desk.Login

***********************************************

This works in VB perfectly. This actually does Desk.Login OK.
(There is more after this code, but not interesting for this problem).

I generate the ActiveX library in TD3.1 and all the classes show up.

Here the TD3.1 code :

If Desk.Create( )
Set DeskConn = uDesk
If DeskConn.PropSetHost( "HostName" )
If DeskConn.PropSetPort( "PortName" )
If Desk.Login( )

I get a "Assignent of different types" when compiling on the second line
(Set DeskConn = uDesk) !
I know the Set command is invalid. The Desk and DeskConn objects are not
from the same class and also no inheritance is present.

There is no method on Desk to get the DeskConn.

First, what does the "Set DeskConn = Desk" in VB do ?
Does it assign the pointer to Desk to DeskConn ?
Is there an equivalent in TD to assign COM objects like in VB ?

I tried this, but none of them works :

If DeskConn.Attach( Desk ) > returns FALSE
If Desk.GetInterface( DeskConn, IID_GsCfgInf_IGsAgentDesktopInfo ) > returns
TRUE, but methods of DeskConn do not work (automation error)
If Desk.GetInterface( DeskConn, IID_GsCfgInf_IGsConnectionInfo ) > returns
FALSE

So i'm stuck. I do not know how to translate "Set DeskConn = Desk" from VB
to TD !!!

Please help so i can uninstall VB from my workstation :wink:

Dave

Marco Villanova

Re: Help needed : VB code to TD (ActiveX)

Post by Marco Villanova » 18 Feb 2005, 12:52

 Posted by:  Marco Villanova 

Hi Dave

I think that it does a QueryInterface, because Desk is an object and
DeskConn an interface
( Dim Desk As New GsAgentDesktopInfo
Dim DeskConn As IGsConnectionInfo)

it returns TRUE, and so you have the pointer to the interface. I don't Know
why
you get an automation error, but this is the way that I use to access the
method
of a COM's interface.

Ciao Marco

cschubert
Germany
Posts: 867
Joined: 23 May 2018, 11:26
Location: Germany

Re: Help needed : VB code to TD (ActiveX)

Post by cschubert » 22 Feb 2005, 20:50

 Posted by:  Christian Schubert 

Dave,

just a wild guess (since I don't know what the classes look like):

Call SalActiveXGetObject( Desk, DeskConn )

HTH

Christian Schubert

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3522
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Help needed : VB code to TD (ActiveX)

Post by Dave Rabelink » 23 Feb 2005, 14:53

 Posted by:  Dave Rabelink 

Christian,

Thanks for your reply.

I tried it but it does not work. The SalActiveXGetObject function returns
FALSE.
(Also, the Desk object is not an ActiveX object but a COM proxy class)

I will explain in more detail the classes which are generated.
I omitted al other methods, just the ones needed i post below :

******* GENERATED COM CLASSES *********

IID_GsCfgInf_IGsAgentDesktopInfo =
'{B6670CC7-07E8-11D3-BD98-00105A056B0B}'
IID_GsCfgInf_IGsConnectionInfo =
'{B6670CB6-07E8-11D3-BD98-00105A056B0B}'

COM Proxy Class: GsCfgInf_GsAgentDesktopInfo
GUID: {BE514751-07E8-11D3-BD98-00105A056B0B}
Derived From
Class: GsCfgInf_IGsAgentDesktopInfo

Functional Class: GsCfgInf_IGsAgentDesktopInfo
Derived From
Class: Object

Functional Class: GsCfgInf_IGsConnectionInfo
Derived From
Class: Object
Class Variables
Instance Variables
Functions
Function: PropSetHost

*******************************

The code in CTD to set the host attribute is :

Local Variables:
GsCfgInf_GsAgentDesktopInfo: Desk
GsCfgInf_IGsConnectionInfo: DeskConn

Actions:
If Desk.Create( )
If Desk.GetInterface( DeskConn, IID_GsCfgInf_IGsAgentDesktopInfo )
If DeskConn.IsDispatchValid( )
If DeskConn.PropSetHost( "HOST1" )

The first three lines return TRUE so that seems to be OK.
Even the IsDispatchValid( ) method on DeskConn returns TRUE.

BUT on line 4 with setting the property for Host, i get this TD error
messagebox :

OLE automation runtime error
"Error code at invocation of : 80020003"

I tried using the IID_GsCfgInf_IGsConnectionInfo string on line 2, but then
the
GetInterface method returns FALSE.

I think the TD code is correct. Could it be a TD bug ?
Problem is that i can not log it as a bug, Gupta engineers can not reproduce
it because they
do not have the (third party) com components installed.

I have attached a zip file with the generated library and the test code.

How could i proceed further ? Are there any debugging options to see why i
get the error ?

Regards,
Dave Rabelink

You do not have the required permissions to view the files attached to this post.

Marco Villanova

Re: Help needed : VB code to TD (ActiveX)

Post by Marco Villanova » 24 Feb 2005, 14:16

 Posted by:  Marco Villanova 

Hi Dave

so you don't have the IGsConnectionInfo interface this is the reason of the
automation error.

Is there some method or property in the GsCfgInf_IGsAgentDesktopInfo
that "Return" an object of type GsCfgInf_IGsConnectionInfo? if so, I think
that you can try to use this method to get the DeskConn...
I hope this can help you

ciao Marco

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3522
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Help needed : VB code to TD (ActiveX)

Post by Dave Rabelink » 25 Feb 2005, 09:27

 Posted by:  Dave Rabelink 

Marco,

No, there is no attribute or method to get the DeskCon object.
Only the GsCfgInf_IGsConnectionInfo interface class is defined and no
references
are used in other classes to it.

In the VisualBasic example there is also no methos or property to get the
DeskCon object, and
the VB code works perfectly !

So there are two possibilities here :

1) VisualBasic code DeskCon = Desk is a feature which is not supported by
TD in any way.
Maybe VB offers more on COM programming than TD does. When this is the case
i'm a bit
dissapointed. I really thought TD3.1 would offer the same as VB COM
programming does.
In that case i can not get rid of Visual Basic for COM programming at all.
I'm curious what problems i will encounter when i get new COM projects to
build.

2) TD offers the same COM programming features, but in this case there is a
bug. How do i proceed further then ? How can i log a bug with third party
com components when i can not supply them for testing by Gupta engineers ?

DeskCon = Desk -> is that interface inheritance ?

How can VB assign an interface class object to another by not having proper
methods or properties ?

regards,

Dave

Return to “advanced.programming”

Who is online

Users browsing this forum: [Ccbot] and 0 guests