I have some problems trying to convert an EventHandler to a MouseEventHandler.
System::EventHandler^ method = gcnew System::EventHandler(this, &MainForm::Exit_Action);
if (e->trigger == "onmousedown") {
c->MouseDown += (MouseEventHandler^)(method); // error
(this refer to a System::Windows::Forms::Form class)
Is there a method to do the trick ?
Well,
EventHandleris not aMouseEventHandler(they are even not in the same inheritance hierarchy), so this shouldn’t work.Why not create a new (well, gcnew)
MouseEventHandlerinsideif? It’s cheap 🙂(In C# you usually create an implicit lambda by using something like
c.MouseDown += Exit_Action;but I don’t know if there’s a syntax like that in C++/CLI.)