I am playing with vc++.net and wrapping the joy* api into a class. The method I want to use is to have a msgloop and event structure in the class so that when it is used in vb.net or C# the user won't need to worry about a callback function.
the C++ Concept is very simple.
compiles fine...Code:#using <mscorlib.dll> using namespace System; namespace IO{ [event_source(managed)] public __gc class JoyStick{ public: __event void ButtonPress(); void RaiseButtonPress(){ ButtonPress(); } }; }
left this out before
VB Code:
Module x Private xx As New Magiaus.IO.JoyStick() Sub Main() xx.__Delegate_ButtonPress.CreateDelegate(Type.GetType("Magiaus.IO.JoyStick"), xx, "Msg", True) xx.RaiseButtonPress() End Sub Sub Msg() MsgBox("Test") End Sub End Module
But, when I get into VB.Net and I try to setup a delegate using the __Delegate_ButtonPressed method that is shown in my intelsense I get a can't be null error. It just ccued to me that it could be because its void but I don't think so.
If any of you guys have done anything like this let me know. personally i was hopeing that i could just use AddHandler somehow... i have exmple of useing this c++ to c++ but nothing on doing it in vb.net or c#... I know it should work. But if it proves to hard I will just change the design i have and make a QueryState method or something.
Any sugestions on the object structure appriciated.




Reply With Quote