   Win32 API and Classes :: WndProc inside class?
  Hello there. Thanks for reading my post. I hope you can offer me some help with this small problem.Well, actually I am creating an OpenGL framework that I can use when I develop apps. in OpenGL, but this question does not deal with game programming. I am using the Win32 API, and I have a class called 'CGLWindow' which creates the window, etc.Anyhow, I have a function for the 'wc.lpfnWndProc' member of the 'WNDCLASS' object when I register the window class. Here is what it looks like in the class declaration:virtual LRESULT CALLBACK glWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)The reason it is 'virtual' is so that I can keep the default (which is just rendering the scene from the 'Render' function; for basic applications) or I can override the function in my apps.Anyhow, when I setup the 'wndClass' object, I do this:wndClass.lpfnWndProc = (WNDPROC) glWndProc;And I get this error when I compile:GL Window.cpp(68) : error C2440: 'type cast' : cannot convert from '' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'I don't know what this means exactly. So therefore I don't know how to fix it. Can anyone give me a solution to this problem?Thanks in advance,    Matt U. =)P.S.:    I'm using Microsoft Visual C++ 6.0 Standard for this project (on Win98, but I don't think that matters in this case =P)   
  Has to be static. And frankly, I have no idea if it will work with it being virtual, like that.   ;  Nope, I already tried that. It doesn't work (can't be static AND virtual as you said). If there is no possible way to fix the error, then what CAN I do?   ;  I see no reason for it not to work if it was static. Or did you try static but not virtual (can't really tell from your post)? It definitely will not work if it's not static. If it has to also be virtual (or act virtual, anyway), I'd recommend you emulate it with a pointer to a static function, or something.   ;  I mean, I can't declare it as static and virtual at the same time. But can I override the function if it is static?   ;  You may follow  Oluseyi's Win32 wrapper class article. He describled exactly what you should do.Good luck.   ;  This question gets asked at least once a week.What you need is:To register the window classes corresponding to each window handle as the window is created (I use a static std::map<HWND,window_class*>).A virtual window proc member function - this implements the required behaviour.A static window proc that you pass to the win 32 API - this function looks up the correct window_class pointer in whatever you've registered the HWND to window_class relationship with. This function should also so something sensible in the event that no window_class is related to the HWND passed - you can't throw an exception (or at least you shouldn't) from a win32 callback function.   