468,772 Members | 2,318 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,772 developers. It's quick & easy.

Create an ActiveX Control in .NET and use it under VB6

Hello

Is it Possible to build an ActiveX Control with NET ?

I want to take a NET UserControl and use it with VB6.

I found a solution how to embbed a NET UserControl into
a WebPage (Like it was possible with ActiveX Control)

http://www.vbdotnetheaven.com/Code/Jun2003/2067.asp

Maybe that is the halve way.

Any Idea ?


Nov 20 '05 #1
4 1248
* "Captain Chaos" <no****@nospam.com> scripsit:
Is it Possible to build an ActiveX Control with NET ?
No.
I want to take a NET UserControl and use it with VB6.

I found a solution how to embbed a NET UserControl into
a WebPage (Like it was possible with ActiveX Control)

http://www.vbdotnetheaven.com/Code/Jun2003/2067.asp

Maybe that is the halve way.


"Forget it."

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
That's not the answer I want to hear :-)

I am 1000% sure there may be a proper solution
but I only know a very dirty one that I don't like......

For example I could create a NET Window, put the NET Control in it.
The create a COM Interface.
Then Create a VB6 ActiveX Control an call the COM Interface.
Then open the Window, getting the Windows Handle of the Control
and place the Control via Windows API (setParent) in the VB6 ActiveX
Control.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schrieb im Newsbeitrag
news:uq**************@TK2MSFTNGP12.phx.gbl...
* "Captain Chaos" <no****@nospam.com> scripsit:
Is it Possible to build an ActiveX Control with NET ?


No.
I want to take a NET UserControl and use it with VB6.

I found a solution how to embbed a NET UserControl into
a WebPage (Like it was possible with ActiveX Control)

http://www.vbdotnetheaven.com/Code/Jun2003/2067.asp

Maybe that is the halve way.


"Forget it."

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
Ok, i found some kind of solution myself:

First Create a COM Class with DOT NET.
Menu "Project" - "AddNew Item" - Com Class.

But the Code from there into your UserControl

It look something like this the:
<ComClass(UserControl1.ClassId, UserControl1.InterfaceId,
UserControl1.EventsId)> _
Public Class UserControl1
Inherits System.Windows.Forms.UserControl
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "4E194D65-C09C-4378-B47F-CAAF521EB8EC"
Public Const InterfaceId As String =
"F9913483-3444-4989-A4D1-F1D4D23955BA"
Public Const EventsId As String = "F05903BF-31A7-47F6-AF5F-67C230D1F172"
#End Region

Windows Form Designer generated code

Public Sub Test()

End Sub

End Class

If you compile the whole thing you there is a *.TLB File created.

Now start VB6:

Make a reference to the TLB File.

Then in the VB 6 User Control you can load your DOT NET Control Dynamicly:

Dim vlob_UserCtrl As Object

Set vlob_UserCtrl = Controls.Add("ClassLibrary5.UserControl1", "HeadCtrl")
vlob_UserCtrl.Left = 0
vlob_UserCtrl.Top = 0
vlob_UserCtrl.ZOrder 0
vlob_UserCtrl.Visible = True
ClassLibrary5.UserControl1 = Namespace and Controlname of the DOT Net
Control

"Captain Chaos" <no****@nospam.com> schrieb im Newsbeitrag
news:bt*************@news.t-online.com...
Hello

Is it Possible to build an ActiveX Control with NET ?

I want to take a NET UserControl and use it with VB6.

I found a solution how to embbed a NET UserControl into
a WebPage (Like it was possible with ActiveX Control)

http://www.vbdotnetheaven.com/Code/Jun2003/2067.asp

Maybe that is the halve way.

Any Idea ?

Nov 20 '05 #4

In Addition:

To Handle Events and Set/Get Properties use Code like this:
Dim vlob_UserCtrl As Object
Dim WithEvents vlob_UserCtrl2 As ClassLibrary5.UserControl1

Private Sub Command1_Click()

Set vlob_UserCtrl = Controls.Add("ClassLibrary5.UserControl1", "HeadCtrl")
vlob_UserCtrl.Left = 0
vlob_UserCtrl.Top = 0
vlob_UserCtrl.Height = 100
vlob_UserCtrl.ZOrder 0
vlob_UserCtrl.Visible = True

Set vlob_UserCtrl2 = vlob_UserCtrl.object

'With vlob_UserCtrl2 you can now handle the Events and set/Get
Properties/Call Methodes aso.

End Sub
"Captain Chaos" <no****@nospam.com> schrieb im Newsbeitrag
news:bt*************@news.t-online.com...
Hello

Is it Possible to build an ActiveX Control with NET ?

I want to take a NET UserControl and use it with VB6.

I found a solution how to embbed a NET UserControl into
a WebPage (Like it was possible with ActiveX Control)

http://www.vbdotnetheaven.com/Code/Jun2003/2067.asp

Maybe that is the halve way.

Any Idea ?

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mr Seth T | last post: by
1 post views Thread by JUN | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.