473,387 Members | 1,611 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,387 software developers and data experts.

Sink CUSTOM Windows Forms Events from Native C++ Classes?

I've managed to have my c++ CWinFormsDialog<...class handle a standard
click event from my c# code as in:
http://msdn2.microsoft.com/en-us/lib...7d(VS.80).aspx

Is it possible to handle you own custom events with your own EventArgs in
the same way?

I get all sorts of strange compilation errors when I try:
GetControl()->MyEvent += MAKE_DELEGATE(System::EventHandler,
OnMyEventHandler);

void MyClass::OnMyEventHandler(System::Object^ pSender,
MYUSERCONTROL::MyEventArgs^ pEventArgs)
{
....
}
error C2870: 'MYNAMESPACE' : a namespace definition must appear either at
file scope or immediately within another namespace definition

error C4694: 'MYNAMESPACE::HelperFunctions': a sealed abstract class cannot
have a base-class 'System::MulticastDelegate'
Jul 3 '07 #1
2 3075
I guess you need to use System::EventHandler<MYUSERCONTROL::MyEventArgsas
the delegate type

--
Sheng Jiang
Microsoft MVP in VC++
"James" <Ja***@discussions.microsoft.comwrote in message
news:11**********************************@microsof t.com...
I've managed to have my c++ CWinFormsDialog<...class handle a standard
click event from my c# code as in:
http://msdn2.microsoft.com/en-us/lib...7d(VS.80).aspx

Is it possible to handle you own custom events with your own EventArgs in
the same way?

I get all sorts of strange compilation errors when I try:
GetControl()->MyEvent += MAKE_DELEGATE(System::EventHandler,
OnMyEventHandler);

void MyClass::OnMyEventHandler(System::Object^ pSender,
MYUSERCONTROL::MyEventArgs^ pEventArgs)
{
...
}
error C2870: 'MYNAMESPACE' : a namespace definition must appear either at
file scope or immediately within another namespace definition

error C4694: 'MYNAMESPACE::HelperFunctions': a sealed abstract class
cannot
have a base-class 'System::MulticastDelegate'


Jul 3 '07 #2
Thanks, you can do it.
EVENT_DELEGATE_ENTRY( OnMyEventHandler, System::Object^,
MYUSERCONTROL::MyEventArgs^ );

Something weird was going on with my solution.
I'd done a rebuild on it, but doing a clean, closing and reopening visual
studio, and rebuilding seemed to sort things out...

I hope all these problems are finally sorted out in VS2008, but then again
we were promised they would be in vs2005

"Sheng Jiang[MVP]" wrote:
I guess you need to use System::EventHandler<MYUSERCONTROL::MyEventArgsas
the delegate type

--
Sheng Jiang
Microsoft MVP in VC++
"James" <Ja***@discussions.microsoft.comwrote in message
news:11**********************************@microsof t.com...
I've managed to have my c++ CWinFormsDialog<...class handle a standard
click event from my c# code as in:
http://msdn2.microsoft.com/en-us/lib...7d(VS.80).aspx

Is it possible to handle you own custom events with your own EventArgs in
the same way?

I get all sorts of strange compilation errors when I try:
GetControl()->MyEvent += MAKE_DELEGATE(System::EventHandler,
OnMyEventHandler);

void MyClass::OnMyEventHandler(System::Object^ pSender,
MYUSERCONTROL::MyEventArgs^ pEventArgs)
{
...
}
error C2870: 'MYNAMESPACE' : a namespace definition must appear either at
file scope or immediately within another namespace definition

error C4694: 'MYNAMESPACE::HelperFunctions': a sealed abstract class
cannot
have a base-class 'System::MulticastDelegate'


Jul 4 '07 #3

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

Similar topics

1
by: Dejun Yang | last post by:
Could anybody help me? How to sink an event from C++.NET in C#? For example, for following CSource, how to sink EventTest in C#? #pragma once #include <windows.h> using namespace System; ...
0
by: Michael Cleroux | last post by:
Hi there, I read this in the Access 2002 help file: 'The class that raises an event is the event source, and the classes that implement the event are the sinks. An event source can have...
5
by: ross kerr | last post by:
Hi All, I am extending the combobox to create a control that selects an item based on the text the user is typing into the text area of the control. I have an issue that occurs only when i...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
7
by: Don | last post by:
Getting errors after following the MSDN article on using VB.NET (and VS2005) for "Implementing a Managed OnSave Event Sink" for Exchange Server 2007. Not sure, but part of the problem may be that...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
0
by: =?Utf-8?B?SmFtZXM=?= | last post by:
I've managed to have my c++ CWinFormsDialog<...class handle a standard click event from my c# code as in: http://msdn2.microsoft.com/en-us/library/af8w7d7d(VS.80).aspx Is it possible to handle...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.