Using Winsock in an ActiveX Dll 
Author Message
 Using Winsock in an ActiveX Dll

I am trying to write an activeX dll that requires that there is a winsock
control in the project where the dll is being used.  This is because the
code in the Dll uses the winsock control.

Such as a Connect method in the Dll

Public Function Connect() as Boolean

    If Form1.Winsock1.State = sktClosed then
        ...
        ...
    Else
        Exit Sub
    End If

End Function

The problem is that I will not know the name of the Form or the Winsock
control. Is there a way to set this at run time using object vars??

I have tried using a WscCtrl and a FrmName property as objects in the Dll
but I can not seem to get it to work.  I would really appreciate any help
you could give me.

Please e-mail response to

 thanks
Bruce



Tue, 15 Jan 2002 03:00:00 GMT  
 Using Winsock in an ActiveX Dll
How about passing the form to the function

Public Function Connect(frm as form) as Boolean

You could then step thru the controls in a form (more coding I'm afraid) to
find the winsock control. I've never had to do that but you could probably
do something like

Public Function Connect(frm as form) as Boolean

    for each control in frm.controls
        if typeof control is winsock then
            ....
        else
            exit sub
        end if
    next

end function

Hope this helps

Steve

Quote:

>I am trying to write an activeX dll that requires that there is a winsock
>control in the project where the dll is being used.  This is because the
>code in the Dll uses the winsock control.

>Such as a Connect method in the Dll

>Public Function Connect() as Boolean

>    If Form1.Winsock1.State = sktClosed then
>        ...
>        ...
>    Else
>        Exit Sub
>    End If

>End Function

>The problem is that I will not know the name of the Form or the Winsock
>control. Is there a way to set this at run time using object vars??

>I have tried using a WscCtrl and a FrmName property as objects in the Dll
>but I can not seem to get it to work.  I would really appreciate any help
>you could give me.

>Please e-mail response to

> thanks
>Bruce



Wed, 16 Jan 2002 03:00:00 GMT  
 Using Winsock in an ActiveX Dll
Look at the CreateObject function.

Hope this helps,
Jason Bouzane


Quote:
> I am trying to write an activeX dll that requires that there is a winsock
> control in the project where the dll is being used.  This is because the
> code in the Dll uses the winsock control.

> Such as a Connect method in the Dll

> Public Function Connect() as Boolean

>     If Form1.Winsock1.State = sktClosed then
>         ...
>         ...
>     Else
>         Exit Sub
>     End If

> End Function

> The problem is that I will not know the name of the Form or the Winsock
> control. Is there a way to set this at run time using object vars??

> I have tried using a WscCtrl and a FrmName property as objects in the Dll
> but I can not seem to get it to work.  I would really appreciate any help
> you could give me.

> Please e-mail response to

>  thanks
> Bruce



Wed, 16 Jan 2002 03:00:00 GMT  
 Using Winsock in an ActiveX Dll
Thank you very much,  I should have thought of that but I guess I just had a
brain fart.  Thanks for getting me back on the right track ,  works great.

Bruce

:How about passing the form to the function
:
:Public Function Connect(frm as form) as Boolean
:
:You could then step thru the controls in a form (more coding I'm afraid) to
:find the winsock control. I've never had to do that but you could probably
:do something like
:
:Public Function Connect(frm as form) as Boolean

:>
:>
:
:



Wed, 16 Jan 2002 03:00:00 GMT  
 Using Winsock in an ActiveX Dll
Well an even better approach than that would be to make an invisible form in
your ActiveX DLL that had its own winsock control on it. To use it in your
class, you simply

Dim WithEvents Wsock as Winsock

Sub Class_Initialize()
  Load frmForm
  Set Wsock = frmForm.Winsock1
End Sub

Sub Class_Terminate()
  Set Wsock = nothing
  Unload frmForm
End Sub

Then you have all the functionality of a winsock control in your activex dll
and still keep no visible interface. If you need more than one of these
controls, you can have a form object variable declared as New frmForm.

Josh


Quote:
> Thank you very much,  I should have thought of that but I guess I just had
a
> brain fart.  Thanks for getting me back on the right track ,  works great.

> Bruce


> :How about passing the form to the function
> :
> :Public Function Connect(frm as form) as Boolean
> :
> :You could then step thru the controls in a form (more coding I'm afraid)
to
> :find the winsock control. I've never had to do that but you could
probably
> :do something like
> :
> :Public Function Connect(frm as form) as Boolean

> :>
> :>
> :
> :



Sat, 19 Jan 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Using Winsock in an ActiveX Dll

2. using Winsock in an ActiveX .DLL

3. Using Winsock from within a ActiveX DLL

4. Using a Winsock Control in a ActiveX DLL

5. Using a Winsock Control in a ActiveX DLL

6. activeX dll, using Winsock and some kind of a timer

7. activeX dll, using Winsock and some kind of a timer

8. Winsock Activex DLL and winsock events

9. call winsock DLL from an ActiveX DLL

10. ActiveX Exe Using ActiveX Dll?

11. Using ActiveX compnts to create ActiveX DLL

12. Winsock control in ActiveX DLL

 

 
Powered by phpBB® Forum Software