PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

how to encapsulate WndProc in a class like GapiDraw

Hi there..
i dunno is this is the right place to ask this, but since GapiDraw has this feature im asking it here.. maybe the creators can help me..

im trying to encapsulate my Message Procedure in my CWindow class, but im having some problems..

anyone know how GapiDraw encapsulates its MessageProc in the CGapiApplication class without the need to have a external function to the class that gives a pointer to the window ?
like:

class CWindow
{
public:
static CWindow *wnd;

virtual HRESULT WindowProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
static LRESULT CALLBACK MessageProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
};

inline GetWindow()
{ return CWindow::wnd; }



now MessageProc handdles our message proc
LRESULT CALLBACK CWindow::MessageProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
return GetWindow()->WindowProc( hWnd, msg, wParam, lParam );
}

and WindowProc handles our specific msgs, like KEYDOWN, KEYUP, etc etc..

as you see i still need to create a pointer to our class.. i dont see GapiDraw doing it this way.. looks like MFC way.. i tried to use their code but it fails me.. doesnt accept my calls..
anyone feels confortable with their method that could explain it to me ?
thanks in advance...
When you create the window, stuff a pointer to the class that wraps it into the window's extra bytes. Look at the docs for Get/SetWindowLong(GWL_USERDATA).