473,402 Members | 2,053 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,402 software developers and data experts.

adding a event handler in MFC application for c# event

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# dll
so how to do that
Here is my code..
#using <mscorlib.dll>

#using "ircConnect.dll" //This is the c# dll reference
__gc class GlobalObjects

{

#pragma push_macro("new")

#undef new

public: static ircConnect::IrcConnection *iIRC =new
ircConnect::IrcConnection();
public:

__event ircConnect::IrcConnection::MessageEventHandler* MessageIncome;

#pragma pop_macro("new")

};

void CMyMFCDlg::OnBnClickedOk()

{

#pragma push_macro("new")

#undef new

GlobalObjects* m_proxyChat;

m_proxyChat = new GlobalObjects();

GlobalObjects *MyX = new GlobalObjects();
m_proxyChat->MessageIncome += new
ircConnect::IrcConnection::MessageEventHandler(MyX ,GlobalObjects::OnMessageIncome);
//This is the event handler im trying to add

m_proxyChat->iIRC->Connect("testing");

m_proxyChat->iIRC->joinchannel("abhishek","abhishek","#guildae");

#pragma pop_macro("new")

}
Aug 30 '06 #1
2 1803
Hi Mayur!
ircConnect::IrcConnection::MessageEventHandler(MyX ,GlobalObjects::OnMessageIncome);
//This is the event handler im trying to add
And what is the problem or error message?
You are already inside the "GlobalObjects" class, or?

So you can just specify:

....MessageEventHandler(MyX, OnMessageIncome);

The following works for me:

__gc class Form1 : Form
{
static void Test()
{
Form1 *f = new Form1();
f->HandleCreated += new System::EventHandler(f, TestHandler);
}
void TestHandler(Object *sender, System::EventArgs *e)
{
}
};

Greetings
Jochen
Aug 30 '06 #2
Hi all,
actually the code is compiling well.but actually my function
OnMessageIncome() is not getting called when
that m_proxyChat->MessageIncome event occurs in my c# dll.
Thanking you.
"Jochen Kalmbach [MVP]" <no********************@holzma.dewrote in message
news:uS**************@TK2MSFTNGP05.phx.gbl...
Hi Mayur!
>ircConnect::IrcConnection::MessageEventHandler(My X,GlobalObjects::OnMessageIncome);
//This is the event handler im trying to add

And what is the problem or error message?
You are already inside the "GlobalObjects" class, or?

So you can just specify:

...MessageEventHandler(MyX, OnMessageIncome);

The following works for me:

__gc class Form1 : Form
{
static void Test()
{
Form1 *f = new Form1();
f->HandleCreated += new System::EventHandler(f, TestHandler);
}
void TestHandler(Object *sender, System::EventArgs *e)
{
}
};

Greetings
Jochen

Aug 30 '06 #3

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

Similar topics

2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
2
by: Tim Marsden | last post by:
Hi, This is what I am doing, please comment if this is the correct way. I need to add controls to a form dynamically. Within the Page_Load event (is not Postback) I run a routine to create the...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
6
by: Just Me | last post by:
I need to create a library sub that adds event handlers to a control. Public Shared Sub AddEvent(ByVal qq As Control, By?? ControlMouseMove As ??) So I need to pass the address of the handler or...
0
by: Mayur Gadhave | 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#...
5
by: J | last post by:
I am having problems dynamically adding more than one event handler to an input. I have tried the Javascript included at the bottom. The lines inp.attachEvent('onkeyup',...
1
by: The Eclectic Electric | last post by:
I'd be very grateful if anyone could help me with this. From my limited knowledge of Javascript I don't think it is possible, but I'll punt anyway. I downloaded and very slightly adapted this...
21
by: John Henry | last post by:
Hi list, I have a need to create class methods on the fly. For example, if I do: class Dummy: def __init__(self): exec '''def method_dynamic(self):\n\treturn self.method_static("it's...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.