Advertisement

WindowsProc in C++

Started by November 06, 2000 11:06 AM
3 comments, last by JoeyBlow2 24 years, 2 months ago
In my windows class I have a WindowProc (to get windows messages coming to the window), and that is defined when you RegisterClass before the CreateWindow function. The thing is, the WindowProc variable for the RegisterClass doesn''t let you use a Class member function. It doesn''t cast correctly. I know you can define this WindowsProc function to be a static class function and it will cast correctly but in the WindowsProc you can''t access any class member variables because its static. Is there anyway around this? Can I get a WindowProc inside the class and allow it to use class member variables?
It will have to be static (Think about it), but you can get round this by passing the this pointer in your call to CreateWindow as the lpParam parameter.
Then your WNDPROC can access the members from the instance that called CreateWindow
Advertisement
I don''t think this has much to do with D3D or OpenGL.


Please state the nature of the debugging emergency.


sharewaregames.20m.com

Thanks. I didn''t know there was a parameter where you could pass information to the wndproc.
I do a similar thing in my Delphi game engine. I create the window and then use SetWindowLong to store a pointer to the object instance in the window data. In the normal WndProc, use GetWindowLong to read the data, typecast it to the object type and then pass all the parameters to the object method.


Steve ''Sly'' Williams
Tools Developer
Krome Studios
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers

This topic is closed to new replies.

Advertisement