I'm trying to write a C#-based WPF application that uses a C++ DLL. The C# application is for the user interface and it has all advantages of WPF. The C++ DLL uses Win32 functions (for example to enumerate windows).
Now I want the C++ DLL to raise event that can be handled in the C# application. This is what I've tried (based on this article):
//cpp file
#using <System.dll>
using namespace System;
struct WIN {
HWND Handle;
char ClassName;
char Title;
};
delegate void wDel(WIN);
event wDel^ wE;
void GotWindow(WIN Window) {
wE(Window);
}
When I try to compile this code, these errors are thrown:
C3708: 'wDel': improper use of 'event'; must be a member of a compatible event source
C2059: syntax error: 'event'
C3861: 'wE': identifier not found