|
-
July 19th, 2010, 07:09 AM
#2
Re: Hook Event Handler
Create new C++/CLI Windows Forms application, add new button to the form and double-click on this button. Windows Form Designer adds this code to Form1.h:
Code:
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
...
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
...
}
button1 is event source instance.
Click is event
"this" is event receiver instance
button1_Click is receiver method used as event handler.
Every .NET event has a type, which is defined by some delegate. You can define your own delegate or use existing one, like EventHandler. EventHandler defines the following type: Void (Object^, EventArgs^). Click event has EventHandler type. Event handler function should have the same type.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|