December 27, 2011 Is there a way to create an elegant class-member window-function? | ||||
---|---|---|---|---|
| ||||
The Window-Procedure in the Win32 API must be static \ global function since it cannot take a class-object (the this) parameter. One can of-course use workarounds like a hWnd->object dictionary and such. I wonder if D has a way to elegantly solve it, like create a tiny member function copy for each object (to call the object's real handler) or anonymous function that I can assign to WNDCLASS.lpfnWndProc (I know there are anonymous functions, but I cannot use the extern(Windows) property on them) ? |
December 27, 2011 Re: Is there a way to create an elegant class-member window-function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tal | I don't know of any /elegant/ way of doing it, but a hash mapping HWND's to Objects is usually how it's done. This is how DFL, DGUI, and Harmonia work. You can check out the function "winDispatch" in my sample win32_window_framework here: https://github.com/AndrejMitrovic/cairoDSamples Alternatively see those GUI libs to see how it's done. |
Copyright © 1999-2021 by the D Language Foundation