Passing MDIForm and Controls to DLL
Can anyone shed some light on the following issue?
I created a dll that contains an interface (ITest) which defines a property that returns a control such as a toolbar as an object like this:
VB Code:
Public Property Get Toolbar() as Object
End Property
I created another class (GlobalClass) and defined it as GlobalMultiUse. In this class I created a public method that takes an ITest as a parameter as follows:
VB Code:
Public Sub Test(byref MDITestForm as ITest)
Dim MyMDI as VB.MDIForm
Dim MyToolbar as MSComctlLib.Toolbar
'Behaves Strangely
If TypeOf MDITestForm is VB.MDIForm Then
'Do Something
End If
'Behaves Strangely
If TypeOf MDITestForm.Toolbar is MSComctlLib.Toolbar Then
'Do Something Else
End If
End Sub
I then created a client project to use the dll. In this client project I added an MDIForm that implements the interface in the dll. Then I implemented the Toolbar property as required by the ITest interface as follows:
VB Code:
Private Property Get ITest_Toolbar() as Object
Set Get ITest_Toolbar = Me.Toolbar1
'Toolbar1 is a standard MS toolbar on the MDIForm
End Property
Somewhere else in the code of the MDI Form I call the Test method as follows:
If I compile my dll and the client exe on the same machine then the lines of code above (reprinted below) that are commented as behaving strangely both evaluate to True. However, if the dll is compiled on one machine and the client exe on another then those same two expressions will evaluate to False. Does anyone know why this happens and/or how to create consistent behavior. Thanks in advance for any help.
VB Code:
If TypeOf MDITestForm Is VB.MDIForm Then
If TypeOf MDITestForm.Toolbar Is MSComctlLib.Toolbar