Events Sample that I can then use in VB with With Evnets keyword

B

Bruce

I have a DotNet C++ class that I would like to fire an event to then be
used by VB.Net using the With Events keyword. I have experience
creating connection point events for ActiveX controls, it is actually
very easy with the ATL wizard but I am lost when it comes to C++ .Net's
events.


Can anyone please point me to an example in VC++ .Net that allows me to
then use the component in VB with the With Events keyword?


Bruce
 
B

Bruno van Dooren [MVP VC++]

I have a DotNet C++ class that I would like to fire an event to then be
used by VB.Net using the With Events keyword. I have experience creating
connection point events for ActiveX controls, it is actually very easy
with the ATL wizard but I am lost when it comes to C++ .Net's events.


Can anyone please point me to an example in VC++ .Net that allows me to
then use the component in VB with the With Events keyword?

Hi,
do a search on www.codeproject.com. you will find lots of examples.
that site is always my starting point when i need samples.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
B

Bruce

Bruno said:
Hi,
do a search on www.codeproject.com. you will find lots of examples.
that site is always my starting point when i need samples.

Thanks Bruno. Code Project is a wonderful website but I have yet to
find an example that has a really good sample of events.

After some searching, I would this one:

http://groups.google.com/group/micr...&q=__event++vb+sAMPLE&rnum=3#d21a58507e01e84e

But it does not show how to use the class with, With Event keyword in VB.

Also the delegate is declared outside the class that is the source of
the event. Is this normal?


Bruce
 
B

Bruno van Dooren [MVP VC++]

Hi,
Thanks Bruno. Code Project is a wonderful website but I have yet to find
an example that has a really good sample of events.

After some searching, I would this one:

http://groups.google.com/group/micr...&q=__event++vb+sAMPLE&rnum=3#d21a58507e01e84e

But it does not show how to use the class with, With Event keyword in VB.

For that you could ask in the vb group. I wouldn't know how to do something
specific in VB.

For testing this part of your problem, you could create a C# class that
exports an event.
That would probably easier for you to find info about.

For using a .NET event in a specific way, it does not matter which language
the assembly was created with.
Also the delegate is declared outside the class that is the source of the
event. Is this normal?

This should not be a problem. It could be a generic delegate that is used in
lots of classes
Btw, that sample is for MC++, which is a deprecated syntax.
C++/CLI is the definite way for using .NET in C++.
do a search for C++/CLI event, and you should get some positive hits.

these 2 things should be a lot easier to figure out separately.
Once you know them both you can then combine them.
Hope this helps.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
B

Bruce

Bruno said:
For that you could ask in the vb group. I wouldn't know how to do something
specific in VB.

For testing this part of your problem, you could create a C# class that
exports an event.
That would probably easier for you to find info about.

For using a .NET event in a specific way, it does not matter which language
the assembly was created with.


This should not be a problem. It could be a generic delegate that is used in
lots of classes
Btw, that sample is for MC++, which is a deprecated syntax.
C++/CLI is the definite way for using .NET in C++.
do a search for C++/CLI event, and you should get some positive hits.

these 2 things should be a lot easier to figure out separately.
Once you know them both you can then combine them.
Hope this helps.

Thanks again Bruno,

I am still using VC7. (Too cheap to upgrade to VC8, though I do have
the Express Version). Does C++/CLI events work for VC7?

I am still searching for some sample code.

Bruce
 
B

Bruce

Bruno said:
Hi,

For that you could ask in the vb group. I wouldn't know how to do something
specific in VB.

For testing this part of your problem, you could create a C# class that
exports an event.
That would probably easier for you to find info about.

For using a .NET event in a specific way, it does not matter which language
the assembly was created with.
This should not be a problem. It could be a generic delegate that is used in
lots of classes
Btw, that sample is for MC++, which is a deprecated syntax.
C++/CLI is the definite way for using .NET in C++.
do a search for C++/CLI event, and you should get some positive hits.

these 2 things should be a lot easier to figure out separately.
Once you know them both you can then combine them.
Hope this helps.


P.S. I must use C++ because I am building a managed wrapper for an
existing C++ unmanaged library.
 
B

Ben Voigt

Bruce said:
Thanks again Bruno,

I am still using VC7. (Too cheap to upgrade to VC8, though I do have the
Express Version). Does C++/CLI events work for VC7?

VC8 Express beats VC7 any version for almost any purpose.
 
T

Tamas Demjen

Bruce said:
Does C++/CLI events work for VC7?

The C++/CLI language was introduced in VC8. VC7 requires you to use the
old MC++ syntax, not the new C++/CLI one.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top