Sign in to follow this  
Matrinix

WndProc within a class

Recommended Posts

Hello everyone, I am trying to abstract WndProc into a cross-platform Window class I am writing. I saw this article (http://www.gamedev.net/reference/articles/article1810.asp) and this forum post (http://www.gamedev.net/community/forums/topic.asp?topic_id=303854) on how to do it. My question, is this method safe to use? I've read at places that the GWL_USERDATA can get overwritten by other applications (or by code you have not introduced). Also is this considered a fast way to do it? I want to use this to tie in with user input so I want to minimize the amount of time it takes to process a key or mouse event. Thanks for your help! -Matrinix

Share this post


Link to post
Share on other sites
Quote:
Original post by Matrinix

My question, is this method safe to use? I've read at places that the GWL_USERDATA can get overwritten by other applications (or by code you have not introduced).

If other code can do that, it might as well replace your window procedure wholesale with GWL_WNDPROC. In other words, not only it is not worth worrying about, there's nothing you could do to stop it.

Quote:
Also is this considered a fast way to do it? I want to use this to tie in with user input so I want to minimize the amount of time it takes to process a key or mouse event.

Yes. The handler is a simple trampoline function, and will be imperceptible in your application's performance, profiled or not.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this