How to register class member function as lpfnWndProc? Cannot convert delegate to function
Andrej Mitrovic
andrej.mitrovich at gmail.com
Fri Sep 28 14:13:08 PDT 2012
On 9/28/12, Maxim Fomin <maxim at maxim-fomin.ru> wrote:
> try to make it static function
If only one app is ever supposed to be instantiated you can use a
static function and a static reference to the class instance:
http://dpaste.dzfl.pl/b1497fa1
Otherwise you could use a hashmap to redirect wndProc's to class
instances by using a HWND as the key and App as the value, something
like:
App[HWND] apps;
extern (Windows)
LRESULT winDispatch(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
auto app = hwnd in apps;
if (app !is null)
{
return app.wndProc(hwnd, message, wParam, lParam);
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
apps would be written to any time a new App instance is created.
Anyway there are multiple ways of doing this, it depends on what you need.
More information about the Digitalmars-d-learn
mailing list