Winsock control in ActiveX DLL 
Author Message
 Winsock control in ActiveX DLL

Hello again,

I want to create a ActiveX DLL  that I can use as a reference in an Access
DB [or other VB projects]. I have the DLL part down pat, but am having
trouble references components that I dragged onto a form inside the project.
From research, someone said to create an "instance" of the form in the DLL.
I do not understand that terminology. If anyone has an example, that would
be awesome, and appreciated!

Thanks,

Rich
TechArts.com



Sat, 09 Apr 2005 03:00:32 GMT  
 Winsock control in ActiveX DLL
Something like this should work:

'** In your ActiveX DLL class module
Private WithEvents m_objSocket As Winsock

Private Sub Class_Initialize()
    '** <Your form name here>
    Dim frm As frmMain

    Set frm = New frmMain
    Load frm

    '** <Your Winsock Control name here>
    Set m_objSocket = frm.Winsock1
End Sub

Private Sub Class_Terminate()
    Set m_objSocket = Nothing
    Unload m_frmMain
End Sub

--
Good Luck,

Joe
----------------------------------------------------------------------------
See if your question has already been answered:

http://groups.google.com/advanced_group_search?q=group:*vb*&num=100
----------------------------------------------------------------------------


Quote:
> Hello again,

> I want to create a ActiveX DLL  that I can use as a reference in an Access
> DB [or other VB projects]. I have the DLL part down pat, but am having
> trouble references components that I dragged onto a form inside the
project.
> From research, someone said to create an "instance" of the form in the
DLL.
> I do not understand that terminology. If anyone has an example, that would
> be awesome, and appreciated!

> Thanks,

> Rich
> TechArts.com



Sat, 09 Apr 2005 08:34:16 GMT  
 Winsock control in ActiveX DLL
Awesome,

Thanks for your help!

Rich


Quote:
> Something like this should work:

> '** In your ActiveX DLL class module
> Private WithEvents m_objSocket As Winsock

> Private Sub Class_Initialize()
>     '** <Your form name here>
>     Dim frm As frmMain

>     Set frm = New frmMain
>     Load frm

>     '** <Your Winsock Control name here>
>     Set m_objSocket = frm.Winsock1
> End Sub

> Private Sub Class_Terminate()
>     Set m_objSocket = Nothing
>     Unload m_frmMain
> End Sub

> --
> Good Luck,

> Joe
> --------------------------------------------------------------------------
--
> See if your question has already been answered:

> http://groups.google.com/advanced_group_search?q=group:*vb*&num=100
> --------------------------------------------------------------------------
--



> > Hello again,

> > I want to create a ActiveX DLL  that I can use as a reference in an
Access
> > DB [or other VB projects]. I have the DLL part down pat, but am having
> > trouble references components that I dragged onto a form inside the
> project.
> > From research, someone said to create an "instance" of the form in the
> DLL.
> > I do not understand that terminology. If anyone has an example, that
would
> > be awesome, and appreciated!

> > Thanks,

> > Rich
> > TechArts.com



Sat, 09 Apr 2005 21:38:50 GMT  
 Winsock control in ActiveX DLL
Hello again,

I've been reviewing the code (haven't yet tried it), and am having a
brain-freeze. For example, if I were to call m_objSocket.Connect "URL", "80"
I will get it to connect and generate Winsock1_Connect. How do the events
happen, and do I have any control?

In a regular VB project, I have control over what happens with respect to
the control...but am confused if I have similar control in this form on the
DLL.

Thanks for helping!


Quote:
> Something like this should work:

> '** In your ActiveX DLL class module
> Private WithEvents m_objSocket As Winsock

> Private Sub Class_Initialize()
>     '** <Your form name here>
>     Dim frm As frmMain

>     Set frm = New frmMain
>     Load frm

>     '** <Your Winsock Control name here>
>     Set m_objSocket = frm.Winsock1
> End Sub

> Private Sub Class_Terminate()
>     Set m_objSocket = Nothing
>     Unload m_frmMain
> End Sub

> --
> Good Luck,

> Joe
> --------------------------------------------------------------------------
--
> See if your question has already been answered:

> http://groups.google.com/advanced_group_search?q=group:*vb*&num=100
> --------------------------------------------------------------------------
--



> > Hello again,

> > I want to create a ActiveX DLL  that I can use as a reference in an
Access
> > DB [or other VB projects]. I have the DLL part down pat, but am having
> > trouble references components that I dragged onto a form inside the
> project.
> > From research, someone said to create an "instance" of the form in the
> DLL.
> > I do not understand that terminology. If anyone has an example, that
would
> > be awesome, and appreciated!

> > Thanks,

> > Rich
> > TechArts.com



Sat, 16 Apr 2005 02:47:18 GMT  
 Winsock control in ActiveX DLL
RTL,

Don't do this. Do not wrap Winsock into DLL, because it will not work on
client machines.
Distributing controls on this manner require developer license for control
to be present on destination machine.

Basically, it will work on machines with VB installed...

Use DLL's written for this (search google) or place control on invisible
form in DLL.


Quote:
> Hello again,

> I've been reviewing the code (haven't yet tried it), and am having a
> brain-freeze. For example, if I were to call m_objSocket.Connect "URL",
"80"
> I will get it to connect and generate Winsock1_Connect. How do the events
> happen, and do I have any control?

> In a regular VB project, I have control over what happens with respect to
> the control...but am confused if I have similar control in this form on
the
> DLL.

> Thanks for helping!



> > Something like this should work:

> > '** In your ActiveX DLL class module
> > Private WithEvents m_objSocket As Winsock

> > Private Sub Class_Initialize()
> >     '** <Your form name here>
> >     Dim frm As frmMain

> >     Set frm = New frmMain
> >     Load frm

> >     '** <Your Winsock Control name here>
> >     Set m_objSocket = frm.Winsock1
> > End Sub

> > Private Sub Class_Terminate()
> >     Set m_objSocket = Nothing
> >     Unload m_frmMain
> > End Sub

> > --
> > Good Luck,

> > Joe

> --------------------------------------------------------------------------
> --
> > See if your question has already been answered:

> > http://groups.google.com/advanced_group_search?q=group:*vb*&num=100

> --------------------------------------------------------------------------
> --



> > > Hello again,

> > > I want to create a ActiveX DLL  that I can use as a reference in an
> Access
> > > DB [or other VB projects]. I have the DLL part down pat, but am having
> > > trouble references components that I dragged onto a form inside the
> > project.
> > > From research, someone said to create an "instance" of the form in the
> > DLL.
> > > I do not understand that terminology. If anyone has an example, that
> would
> > > be awesome, and appreciated!

> > > Thanks,

> > > Rich
> > > TechArts.com



Sat, 16 Apr 2005 03:10:35 GMT  
 Winsock control in ActiveX DLL
When you declare your Winsock object "WithEvents", you'll see a new
'm_objSocket' item in your control combo box (at the top of your main VB
Edit Window).  If you select 'm_objSocket' from the dropdown, you'll see you
have access to all the WinSock events (in the right-hand drop list) and can
place a handler for whichever events you want to handle.

Here's an example (my original post didn't work correctly -- some naming and
scope confusion):

'******** FROM ActiveX DLL Class Module ************
Option Explicit

Private m_frmMain As frmMain
Private WithEvents m_objSocket As Winsock

Private Sub Class_Initialize()
    '** <Your form name here>
    Set m_frmMain = New frmMain

    '** <Your Winsock Control name here>
    Set m_objSocket = m_frmMain.Winsock1
End Sub

Private Sub Class_Terminate()
    Set m_objSocket = Nothing
    Unload m_frmMain
End Sub

Private Sub m_objSocket_Connect()
    '** Do Whatever....
End Sub

Private Sub m_objSocket_DataArrival(ByVal bytesTotal As Long)
    '** Do Whatever....
End Sub

'--- etc, etc.

'*************************************************

Good Luck,

Joe


Quote:
> Hello again,

> I've been reviewing the code (haven't yet tried it), and am having a
> brain-freeze. For example, if I were to call m_objSocket.Connect "URL",
"80"
> I will get it to connect and generate Winsock1_Connect. How do the events
> happen, and do I have any control?

> In a regular VB project, I have control over what happens with respect to
> the control...but am confused if I have similar control in this form on
the
> DLL.

> Thanks for helping!



> > Something like this should work:

> > '** In your ActiveX DLL class module
> > Private WithEvents m_objSocket As Winsock

> > Private Sub Class_Initialize()
> >     '** <Your form name here>
> >     Dim frm As frmMain

> >     Set frm = New frmMain
> >     Load frm

> >     '** <Your Winsock Control name here>
> >     Set m_objSocket = frm.Winsock1
> > End Sub

> > Private Sub Class_Terminate()
> >     Set m_objSocket = Nothing
> >     Unload m_frmMain
> > End Sub

> > --
> > Good Luck,

> > Joe

> --------------------------------------------------------------------------
> --
> > See if your question has already been answered:

> > http://groups.google.com/advanced_group_search?q=group:*vb*&num=100

> --------------------------------------------------------------------------
> --



> > > Hello again,

> > > I want to create a ActiveX DLL  that I can use as a reference in an
> Access
> > > DB [or other VB projects]. I have the DLL part down pat, but am having
> > > trouble references components that I dragged onto a form inside the
> > project.
> > > From research, someone said to create an "instance" of the form in the
> > DLL.
> > > I do not understand that terminology. If anyone has an example, that
> would
> > > be awesome, and appreciated!

> > > Thanks,

> > > Rich
> > > TechArts.com



Sat, 16 Apr 2005 15:17:21 GMT  
 Winsock control in ActiveX DLL
Hi Ivan and Joe,

Thank you both for your insights. I actually implemented the hidden form
idea. That worked beautifully--only a slight "bug" Actually, more of a
quark, but it works reliably and fast.

Thanks again!

Rich


Quote:
> When you declare your Winsock object "WithEvents", you'll see a new
> 'm_objSocket' item in your control combo box (at the top of your main VB
> Edit Window).  If you select 'm_objSocket' from the dropdown, you'll see
you
> have access to all the WinSock events (in the right-hand drop list) and
can
> place a handler for whichever events you want to handle.

> Here's an example (my original post didn't work correctly -- some naming
and
> scope confusion):

> '******** FROM ActiveX DLL Class Module ************
> Option Explicit

> Private m_frmMain As frmMain
> Private WithEvents m_objSocket As Winsock

> Private Sub Class_Initialize()
>     '** <Your form name here>
>     Set m_frmMain = New frmMain

>     '** <Your Winsock Control name here>
>     Set m_objSocket = m_frmMain.Winsock1
> End Sub

> Private Sub Class_Terminate()
>     Set m_objSocket = Nothing
>     Unload m_frmMain
> End Sub

> Private Sub m_objSocket_Connect()
>     '** Do Whatever....
> End Sub

> Private Sub m_objSocket_DataArrival(ByVal bytesTotal As Long)
>     '** Do Whatever....
> End Sub

> '--- etc, etc.

> '*************************************************

> Good Luck,

> Joe



> > Hello again,

> > I've been reviewing the code (haven't yet tried it), and am having a
> > brain-freeze. For example, if I were to call m_objSocket.Connect "URL",
> "80"
> > I will get it to connect and generate Winsock1_Connect. How do the
events
> > happen, and do I have any control?

> > In a regular VB project, I have control over what happens with respect
to
> > the control...but am confused if I have similar control in this form on
> the
> > DLL.

> > Thanks for helping!



> > > Something like this should work:

> > > '** In your ActiveX DLL class module
> > > Private WithEvents m_objSocket As Winsock

> > > Private Sub Class_Initialize()
> > >     '** <Your form name here>
> > >     Dim frm As frmMain

> > >     Set frm = New frmMain
> > >     Load frm

> > >     '** <Your Winsock Control name here>
> > >     Set m_objSocket = frm.Winsock1
> > > End Sub

> > > Private Sub Class_Terminate()
> > >     Set m_objSocket = Nothing
> > >     Unload m_frmMain
> > > End Sub

> > > --
> > > Good Luck,

> > > Joe

> --------------------------------------------------------------------------
> > --
> > > See if your question has already been answered:

> > > http://groups.google.com/advanced_group_search?q=group:*vb*&num=100

> --------------------------------------------------------------------------
> > --



> > > > Hello again,

> > > > I want to create a ActiveX DLL  that I can use as a reference in an
> > Access
> > > > DB [or other VB projects]. I have the DLL part down pat, but am
having
> > > > trouble references components that I dragged onto a form inside the
> > > project.
> > > > From research, someone said to create an "instance" of the form in
the
> > > DLL.
> > > > I do not understand that terminology. If anyone has an example, that
> > would
> > > > be awesome, and appreciated!

> > > > Thanks,

> > > > Rich
> > > > TechArts.com



Mon, 18 Apr 2005 05:07:44 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Winsock Activex DLL and winsock events

2. Winsock Control - ActiveX DLL

3. Using a Winsock Control in a ActiveX DLL

4. Using a Winsock Control in a ActiveX DLL

5. Winsock control wrapped in ActiveX DLL?

6. call winsock DLL from an ActiveX DLL

7. ActiveX.exe or ActiveX DLL or ActiveX Control?????????????

8. Building ActiveX controls that will access activex.dll running on PWS

9. ActiveX dll vs ActiveX control - Whats the difference

10. Passing ActiveX control as a parrameter to ActiveX.dll

11. Can ActiveX DLL component contain ActiveX control?

12. Using Winsock in an ActiveX Dll

 

 
Powered by phpBB® Forum Software