Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi All, I want to create my own

Status
Not open for further replies.

Gorkem

Programmer
Jun 18, 2002
259
CA
Hi All,

I want to create my own components to use on my website, however I am not sure how to get the WINSOCK OCX component into my class module.. Any idea's? I'm sure everyone has run into the problem one time or another.

Thanks,

Gorkem.
 
OCX can not be bound to a class module. A OCX needs a form (parent window) as it uses the parent windows message pump to get its messages.
 
The following code snippet will allow you to create and use a winsock control in your class module. First create a form called frmWsk and place a Winsock control on this form (named Winsock1 in the example). In the class module, create a module level var that references a winsock object. In the class initialize event, set the variable to the Winsock control on the form. From then on, in your class, reference the var name (wskNet) just as you would a winsock control on a form. All properties can be set, methods called etc.

Because it is declared WithEvents, the events raised by the object can even be handled in the class module. If you go to your object pull down in the IDE, you will notice you get an object named wskNet. When this is selected, the events list in the IDE gives you all of the events you would normally get with the winsock control.


' Object decraration (before any code in class module)
Dim WithEvents wskNet As Winsock

' Class module initialize event
Private Sub Class_Initialize()
Set wskNet = frmWsk.Winsock1 ' Creates ref to control
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top