473,387 Members | 1,745 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.

creting event handler client in vc++ for Source c# event

Hello all,

Can any one have the source of How to add event handler in unmanaged MFC
application for
event source which is in Managed(c# class library).

Here is the Event Source code
:
namespace ircConnect

{

public class IrcConnection

{

public delegate void MessageEventHandler(object sender,MessageEventArgs e);

public event MessageEventHandler MessageIncome;

}End Class



Event Client

void CADONET_MFCDlg::OnFilling() //This is the MFC dialog box event

{

#pragma push_macro("new")

#undef new

try

{

m_IrcConnection =new IrcConnection();

FileWatcherEvents *f=new FileWatcherEvents();

m_IrcConnection->add_MessageIncome=new
IrcConnection::MessageEventHandler(m_IrcConnection ,OnMessageIncome);

};

im using gcroot template
gcroot<IrcConnection*m_IrcConnection;

gcroot<IrcMessage*m_IrcMessage;

void static OnMessageIncome( Object* sender,
IrcConnection::MessageEventHandler* e );

but the compile time error generated as follows

error C3363: 'void CADONET_MFCDlg::OnMessageIncome(System::Object __gc
*,ircConnect::IrcConnection::MessageEventHandler __gc *)' : cannot create a
delegate handler for 'ircConnect::IrcConnection::MessageEventHandler' from a
non-member function or a member of an unmanaged class


Sep 1 '06 #1
1 1523

"Mayur" <ma***@activelement.comwrote in message
news:un**************@TK2MSFTNGP04.phx.gbl...
| Hello all,
|
| Can any one have the source of How to add event handler in unmanaged MFC
| application for
| event source which is in Managed(c# class library).
|
| Here is the Event Source code
| :
| namespace ircConnect
|
| {
|
| public class IrcConnection
|
| {
|
| public delegate void MessageEventHandler(object sender,MessageEventArgs
e);
|
| public event MessageEventHandler MessageIncome;
|
| }End Class
|
|
|
|
|
|
|
| Event Client
|
| void CADONET_MFCDlg::OnFilling() //This is the MFC dialog box event
|
| {
|
| #pragma push_macro("new")
|
| #undef new
|
| try
|
| {
|
| m_IrcConnection =new IrcConnection();
|
| FileWatcherEvents *f=new FileWatcherEvents();
|
| m_IrcConnection->add_MessageIncome=new
| IrcConnection::MessageEventHandler(m_IrcConnection ,OnMessageIncome);
|
| };
|
|
|
| im using gcroot template
| gcroot<IrcConnection*m_IrcConnection;
|
| gcroot<IrcMessage*m_IrcMessage;
|
|
|
| void static OnMessageIncome( Object* sender,
| IrcConnection::MessageEventHandler* e );
|
| but the compile time error generated as follows
|
| error C3363: 'void CADONET_MFCDlg::OnMessageIncome(System::Object __gc
| *,ircConnect::IrcConnection::MessageEventHandler __gc *)' : cannot create
a
| delegate handler for 'ircConnect::IrcConnection::MessageEventHandler' from
a
| non-member function or a member of an unmanaged class
|
|
|
|

THis is not a C# issue, please post C++ questions to the vc NG
<microsoft.public.dotnet.languages.vc, that said, the error message tells
it all, your MessageEventHandler' delegate must be created from a managed
class.

Willy.
Sep 1 '06 #2

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

Similar topics

0
by: Andy Read | last post by:
Hello all, I have the requirement to produce source code that produces an object hierarchy. Example: Root | Folder 1
2
by: TogaKangaroo | last post by:
Hi, I'm trying to get intimate with my new copy of the .NET Pro developing environment, specifically C++ Visual Studio. I have a book (VC++ in 21 days) that I am going through following their...
0
by: Arnaud Debaene | last post by:
Hello all. I've got a bunch of existing, non managed, C++ DLLs that export types with, among other things, public events implemented using the boost::signals library. Now, I need to have...
3
by: Ashok Kumar K | last post by:
Hi all, Where can I get some insight on using the __hook, __unhook, event_source and event_receiver for specifically COM events. The documentation given in MSDN is very minimal. I have the...
0
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it...
0
by: Mayur | last post by:
Hello all, Im trying to call my .net c# library functions from my unmanaged vc++(dialog based MFC) application . From that application i want add the event handler for the event generated in c#...
2
by: Mayur | last post by:
Hello all, Can any one have the source of How to add event handler in unmanaged MFC application for event source which is in Managed(c# class library). Here is the Event Source code :...
19
by: Daniela Roman | last post by:
Hello, I try to fire an event under a button click event and maybe anybody can give a clue please. I have let's say a WEB grid with PageIndexChanged event: private void...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
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: 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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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.