473,386 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

RaiseEvent in DOT .NET so that VB6 can respond

I created a user control in VB .NET and put a COM wrapper around the
control so that a VB6 client could dynamically add the control to a
form. The only thing I haven't figured out is if the VB .NET user
control can raiseevent and have the VB6 container respond to that
event.
I've tried the following:

<ComClass(UserControl1.ClassId, UserControl1.InterfaceId,
UserControl1.EventsId)> _
Public Class UserControl1
Inherits System.Windows.Forms.UserControl
Public Event TestEvent()

....
...

#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 =
"CF573EBC-804F-4086-A08F-2239E56BADFE"
Public Const InterfaceId As String =
"D9F75135-7D89-44FE-AA2C-21E742A187FB"
Public Const EventsId As String =
"E8FECC77-2988-4C29-9A7B-04F9ED2909BA"
#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
RaiseEvent TestEvent()
End Sub

Friend WithEvents Button1 As System.Windows.Forms.Button
end class

------------------

Now in the VB6 app I've done the following:

Option Explicit

Private oMyControl As New TestControl.UserControl1
Private WithEvents theEvent As TestControl.UserControl1

Private oUserControl As Object

Private Sub Form_Load()
Set oUserControl = Controls.Add("TestControl.UserControl1",
"doesntmatter")
oUserControl.Left = 0
oUserControl.Top = 0
oUserControl.ZOrder 0
oUserControl.Visible = True

Set theEvent = oMyControl
End Sub

Private Sub theEvent_TestEvent()
MsgBox "this is the vb 6.0 event"
End Sub

I never get to the VB 6.0 event handler when I click the button inside
the DOT Net control
Anyone have any ideas?

Thanks!

Jeff
Nov 20 '05 #1
3 2227
DOT .NET

is that like saying

...NET?

"JeffR" <Je***********@us.ing.com> wrote in message
news:49*************************@posting.google.co m...
I created a user control in VB .NET and put a COM wrapper around the
control so that a VB6 client could dynamically add the control to a
form. The only thing I haven't figured out is if the VB .NET user
control can raiseevent and have the VB6 container respond to that
event.
I've tried the following:

<ComClass(UserControl1.ClassId, UserControl1.InterfaceId,
UserControl1.EventsId)> _
Public Class UserControl1
Inherits System.Windows.Forms.UserControl
Public Event TestEvent()

...
..

#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 =
"CF573EBC-804F-4086-A08F-2239E56BADFE"
Public Const InterfaceId As String =
"D9F75135-7D89-44FE-AA2C-21E742A187FB"
Public Const EventsId As String =
"E8FECC77-2988-4C29-9A7B-04F9ED2909BA"
#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
RaiseEvent TestEvent()
End Sub

Friend WithEvents Button1 As System.Windows.Forms.Button
end class

------------------

Now in the VB6 app I've done the following:

Option Explicit

Private oMyControl As New TestControl.UserControl1
Private WithEvents theEvent As TestControl.UserControl1

Private oUserControl As Object

Private Sub Form_Load()
Set oUserControl = Controls.Add("TestControl.UserControl1",
"doesntmatter")
oUserControl.Left = 0
oUserControl.Top = 0
oUserControl.ZOrder 0
oUserControl.Visible = True

Set theEvent = oMyControl
End Sub

Private Sub theEvent_TestEvent()
MsgBox "this is the vb 6.0 event"
End Sub

I never get to the VB 6.0 event handler when I click the button inside
the DOT Net control
Anyone have any ideas?

Thanks!

Jeff

Nov 20 '05 #2
Oops.. a bit redundant.

I really meant .NET or DOT NET. Do you have any ideas on my issue?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
It should work just fine using RaiseEvent... I don't see any reason why it
wouldn't, events are supported through the interop.

-cJ
"Jeffrey Reese" <je***********@us.ing.com> wrote in message
news:ur**************@TK2MSFTNGP11.phx.gbl...
Oops.. a bit redundant.

I really meant .NET or DOT NET. Do you have any ideas on my issue?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Guille | last post by:
Hi all! I'm having some weird behaviour in a .NET application i'm developing. I'll try to explain: I've created a Class that wraps an asynchronous socket. When connect callback is called, i...
8
by: Nicolas | last post by:
How do I do a RaiseEvent in csharp I'm ok in VB but csharp confused me a lot. ******* code ******** private FileSystemWatcher watcher = new FileSystemWatcher(); public delegate void...
2
by: Carl tam | last post by:
Hi everyone, I got a quite interesting problem myself and got stuck. I have an aspx page with a windows user control with it. in the Windows Control. I have a RaiseEvent statement, say...
2
by: Lim | last post by:
I've developed a program that raise an event. This program works fine on a Windows 2000 Professional PC. However when I try to run the program on a Windos XP Professional PC, the program will not...
12
by: Ron | last post by:
Greetings, I am trying to understand the rational for Raising Events instead of just calling a sub. Could someone explain the difference between the following 2 scenarios? Why would I want to...
2
by: dmoonme | last post by:
I'm trying to rename some files in a directory. Pretty basic stuff - renaming the files works fine but the problem I have is updated the text in textbox. All I want to do is appendtext to a...
7
by: Onokiyo | last post by:
Hello, I have the code below and somehow the message from RaiseEvent doesn't pop up at all. Can someone help me please? '------CODE '------/form1.vb/VB2005/Framework20--------- Imports...
3
by: Martin | last post by:
Hi all, I'm having a problem when trying to raise an event in my custom control when a toolstripbutton enable state changes. The problem is that although the code to raise the event executes, my...
1
by: Terry Olsen | last post by:
I have a program with a couple of long running processes that i'm calling on a separate thread. When the process is completed, I want to raise an event to tell the main thread that it's done. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.