mfc - How to write multicast delegate in C++ -


i need call few button click events on single button click. how write it? can use multicast delegate concept here?

my scenario:

i have button named xyz. upon clicking , event handler have written other buttons of application must called 1 one.

can me out in this?
went through link : http://www.codeproject.com/articles/1077/delegates-in-managed-c doesnt work me :(

if you're limited microsoft visual c++ can use __event, it's similar event in managed world.

first declare method want make event prepending __event method:

__event void onbuttonclicked(...); 

then decorate class contains method with:

[event_source(native)] class myeventgenerator { public:     __event void onbuttonclicked(const void* psender, const void* parguments); }; 

to raise event call function (prepending __raise keyword optional it'll make clear in code you're raising event). note can raise event outside class because it's simple method call.

the class you'll use handle event must decorated with:

[event_receiver(native)] class cmyeventreceiver { public:     void onbuttonclicked(const void* psender, const void* parguments); }; 

to attach event not have sugar of += must write inside cmyeventreceiver class:

 __hook(&cmyeventgenerator::onbuttonclicked, peventgenerator,     &cmyeventreceiver::onbuttonclicked); 

note detach event handler have use __unhook keyword.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -