WindowProc in a class - function and pointer problem
Simen Kjaeraas
simen.kjaras at gmail.com
Wed May 22 13:25:16 PDT 2013
On 2013-05-22, 21:30, D-sturbed wrote:
> Hello, is there a way to wrap a WindowProc (so "LRESULT WindowProc(HWND
> hWnd, UINT message, WPARAM wParam, LPARAM lParam) nothrow") in a class
> and to link it to a WindowClass without puting it as "static" ?
>
> Because defacto every datum used in the WindowProc must also be static.
> The problem technically is that if "static" is not specified, the
> compiler won't allow this: "MyWinClass.lpfnWndProc =
> &TheWindowProcInMyClass".
>
> I've also tried this: "MyWinClass.lpfnWndProc =
> (&TheWindowProcInMyClass).funcptr" but, while it compiles, it
> drastically fails at the run-time...
Not possible, no. What you *can* do is have some way to translate from
hwnd to class instance, and fetch the right instance inside the static
wndProc to call a member function on that.
--
Simen
More information about the Digitalmars-d-learn
mailing list