The Window procedure in the Win32 API must be a static \ global function because it cannot accept the class-object ( this ) parameter. You can, of course, use workarounds such as the hWnd-> object dictionary, etc.
I wonder if method D has its elegant solution, for example, to create a small copy of a member function for each object (call the real object handler) or an anonymous function that I can assign to WNDCLASS.lpfnWndProc (I know there are anonymous functions, but I donโt can I use the extern(Windows) property extern(Windows) on them)?
Can I do something like this:
class Window { extern (Windows) LRESULT delegate (HWND hWnd, UINT msg, WPARAM w, LPARAM l) MyWinProcDelegate; this() { MyWinProcDelegate = &Events; } extern (Windows) LRESULT Events (HWND hWnd, UINT msg, WPARAM w, LPARAM l) { MessageBoxA(null , "Success!!!" , null ,0); return DefWindowProcA(hWnd, message, wParam, lParam); } }
(Omitting registration \ creating \ msg-loop ...)
Events () do not seem to fire ... am I missing something?
source share