Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / August 2006

Tip: Looking for answers? Try searching our database.

adding a event handler in MFC application for c# event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mayur Gadhave - 30 Aug 2006 07:37 GMT
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")

}
Jochen Kalmbach [MVP] - 30 Aug 2006 07:57 GMT
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
Mayur - 30 Aug 2006 08:14 GMT
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.
> Hi Mayur!
>
[quoted text clipped - 24 lines]
> Greetings
>   Jochen

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.