Help with DLLs

Chr1s
04-13-2003, 03:48 PM
Hello,
I am making a program that require dll plugins, I've managed to load the plugins on runtime using CreateObject(), but now I've got a problem. I want the DLL plugins to be able to use controls that are in the Client Form is it possible?

For example in my Frmmain, I've got a Winsock can I make the DLL plugin using frmmain.winsock? is there any way?

Squirm
04-13-2003, 03:50 PM
Have the form pass the Winsock to the plugin class in a method or a property. The class can then store a reference to the Winsock and use it as it wishes.

Chr1s
04-13-2003, 03:52 PM
Thanks for the quick reply.

Can you explain how the property would work? In the DLL i'd have to reference the Winsock control and the property would be dim as Winsock wouldn't it? but it doesnt let me do that.

Squirm
04-13-2003, 03:54 PM
Public Property Set Socket(New_Socket As Winsock)
Set myinternalclassvariable = New_Socket
End Property

Obviously myinternalclassvariable is a variable inside the class declared as type Winsock.

Chr1s
04-13-2003, 03:56 PM
"Private Objects cannot be used in public object modules as parameters"

thats the error I get when I try to add Winsock as a parameter.

Squirm
04-13-2003, 03:57 PM
Well... its a slimy hack but this will work:

Public Property Set Socket(New_Socket As Object)
Set myinternalclassvariable = New_Socket
End Property

Chr1s
04-13-2003, 04:12 PM
In my form:

In my form_load after loading the DLL I put:

objPlugIn.MySocket = Winsock1
objPlugIn.MySocket.Connect "irc.freenode.net", 6667

Private Sub Winsock1_Connect()
MsgBox "the socket connected!"
End Sub

In my DLL:

Private mvarMySocket As Object
Public Property Set MySocket(ByVal vData As Object)
Set mvarMySocket = vData
End Property
Public Property Get MySocket() As Object
Set MySocket = mvarMySocket
End Property


It's not connecting ... Did I make a mistake somewhere?

edit: I've added 2 msgboxes in SET and GET and it seems like the SET isn't working..

Chr1s
04-13-2003, 04:21 PM
I fixed my problem I forgot to put SET = in my statement thx for the help.

Chr1s
04-13-2003, 04:30 PM
More help needed.. :(

Is it possible to use this same method to pass user-defined type variables?

Squirm
04-13-2003, 04:49 PM
Congrats, you managed to wait a full 16 minutes before bumping.
And no, it isn't possible to pass UDTs this way. Either turn the UDT into a class which both the application and the DLL know about (ie another DLL which they both reference) and do as you did with the Winsock, or pass each member of the UDT separately as properties or parameters to a method.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum