473,320 Members | 1,902 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,320 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 3072
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.