Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Subotron

Making WindowProc part of a window wrapper class without using static

This topic is 5577 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m making a window wrapper class and it all works fine, except that I have make the windowproc function either extern or static inside the class. I want it to be non-static, but part of the class (it''ll be virtual later on) is there a(n) (easy) way to archieve this? I''ve seen a few articles on window wrappers, but they either use the way described above or they have some weird code I really don''t understand. Someone told me to declare the windowproc like this inside the class: class CWindow { public: WNDPROC WindowProc; }; is this the way to do it? But like this, it seems like a variable to me. How do I use it? How do I set it up make it virtual etc. please help me on this it''s been bugging me for (too) long now... Thanks in advance | Panorama 3D Engine | Contact me | | MSDN | Google | SourceForge |

Share this post


Link to post
Share on other sites
Advertisement
make it static and call another virtual function which can be overidden

[edited by - petewood on March 18, 2003 9:20:14 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if you make it static and call a virtual method from that you need a mechanism for the static method to get hold of the instance of your window class - eg a global var or something similar.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I looked into this a bit a while ago. I''m no Windows GUI developer - so it''s not something I know much about. However you are basically trying to wrap a C API (or subset of one) in a C++ OO framework. Win32 defines the function as C linkage - so you can''t get round the fact that it has to be a static function. You also can''t get round the fact that a static function, by its nature, will have no ''this'' pointer - so you have to work around it - by either making the class a singleton or having a global var. You can use macros to tidy it up a little tho.

I''d be interested in any other (nicer) solutions to this too.

Share this post


Link to post
Share on other sites
I ran into the same problem. What I did was leave the WindowProc function static. I created a structure to hold the windows message parameters

struct MESSAGE
{HWND hWnd;UINT uiMsg;WPARAM wParam;LPARAM lParam;}

I fill out an instance of this variable in the Base Class WindowProc function. I then handled the last message stored in a derived class WindowProc function, every frame.

Maybe not quite what you are looking for but it works all right.

I should probably be working now...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!