Re: Interfaces : Is int that a USer CONTROL??!
hey!, in your first post you said ICMSPassowrd is a user Control!. and how can you do a createObject on a user control, It works only for server classes/objects.
Either you do a "set" to an existing instance of a control or you create a run time instance using Me.Controls.add ( VB 6.0) .
Also you said "The "Set objPlugin =" line works and gets the ICMSPlugin interface."..
this is the reference of which instance of interface? Meaning, an interface has be have an implementation right? So to which class/control is this refering to after that line?
II. Back to yout first post :
ICMSPassword is a class that implemets the ICMSPlugin Interface, which means
you can NEVER say
dim objPass as ICMSPassword
dim objPlugin as ICMSPlugin
...
set objPass = objPlugin. ' IS WRONG
Infact it is the other way:
set objPlugin = objPass
because IMPLEMENTS means "is a" relationship holds. So where ever a ICMSPLugin object is required, you can use an instance of ICMSPassword, but you can never use a ICMSplugin where ICMSpassword is required!!.
ICMSPassowrd : Implements ICMSPlugin.
so if there is a function that takes the class/interface CMSPLugin you can pass a
a reference to CMSPassword, because CMSPLugin is wholely contained in CMSPassword.
Think abt it!
RK
Re: Interfaces : Is int that a USer CONTROL??!
You're thinking strictly VB here. We're dealing with the world of COM. An object has multiple interfaces. From any interface on an object, you can call QueryInterface(...) and get a reference to any other interface on the object. This is one of the rules of COM. VB handles the grunt work of calling QueryInterface for you behind the scenes. All you have to do is assign an interface reference variable to a variable of another interface type and VB will call QueryInterface on the assigned interface to request the new interface. If it fails... Type Mismatch. If it doesn't fail, you have a reference to the other interface on the same object. That's how VB handles COM and multiple interfaces.
As to your other comment, an ActiveX control *IS* a COM server and should therefore be able to be created with CreateObject(<servers ProgID>) with no problem. When you do Me.Controls.Add("<controls ProgID>"), that's essentialy what VB is doing. It's creating an instance of the server dynamically by looking it's ClassID up in the registry via it's ProgID. After all, an .OCX is still an in-proc COM server (ActiveX DLL, whatever you want to call it) it's just renamed to .OCX. The main difference between VB's ActiveX DLL and ActiveX Control project types are what COM interfaces they implement. An ActiveX Control implements a lot of OLE interfaces to all it to be imbedded in a container.
-----
Lee Perkins
TigerBase Technologies
Re: Interfaces : Is int that a USer CONTROL??!
It may be the ooly World of com!. but still it has stick together right?
In your example, your ICMSPlugin doesnot implement the interface ICMSPassword!. and hence it fails.. simple.. (infact it is the other way!)
>"You're thinking strictly VB here.".
VB may be doing the CreateObject and other grunt work of Com behind the scenes. I too understand (some of)the intercasies , it may be doing all but and a "little more", which could be causing the touble :
and my simple point is:
If you program in VB, do the VB way!.
VBs way of query interface is 'TypeOf'.
To know if an object implements an interface or not, Use "is typeof ".
RK
Re: Interfaces : Is int that a USer CONTROL??!
I think I'm starting to understand what's going on (read my latest reply to czimmerman in this thread). Sorry if I sounded abrupt before, it's just getting late and I'm too close to a dead line to still be sane. :)
-----
Lee Perkins
TigerBase Technologies