Hello.
I am having problems accessing methods from a class inside a static function.
I basically have two classes. One called CWindow that creates a window(obviously), which uses a callback function (also inside CWindow).
The other class is called CSkin which will be use the created window and draw things on it.
This is the thing. I want CSkin to call one of it's own methods (in this case PaintSkin(HDC hdc)) when the message WM_PAINT is sent to the window. But, I can't access anything from my CSkin class inside the callback function.
I can easily access them from other functions, but not in the callback function. Which I guess have something to do with it being static, it is however necessary or otherwise I receive a compile error.
My Window class:
Constructor-code, where I create an instance of my CSkin class:Code:class CWindow { public: CWindow(); ~CWindow(); int CreateWindow( ); ... private: ... CSkin *skin; static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); };
CreateWindow()-code, WndProc needs to be static:Code:CWindow::CWindow() { ... CWindow::skin = new CSkin; ... }
Callback-code, this is where I want the instance of CSkin to call it's PaintSkin()-method. But "CWindow::skin->" doesn't give me anything at all, and I can't access it.Code:int CWindow::CreateWindow() { ... wc.lpfnWndProc = (WNDPROC)(WndProc); ... }
Code:LRESULT CALLBACK CWindow::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_PAINT: ... if(CWindow::skin != NULL) // CWindow::skin->PaintSkin(ps.hdc); // Desired result ... } }
How shall I proceed?
(I am using VS.NET 2k5 and the Win32 API).
Thanks.




), which uses a callback function (also inside CWindow).
Reply With Quote