• Advertisement

Archived

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

Adventures with statics -or- I need my lparam to get the mouseposition damnit!

This topic is 5559 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 have a problem right now. My WinProc is created as a static in a window-class I allocate/create when the program starts. I never thought much of this earlier when I created the functions and classes, but now I need the lparam contained in it to get Windows current mouseposition. The static nature of this function is now disturbing since I really need to get to the lparam. But what should I do? I tried moving the callback out of the class but in the end it was just too cumbersome and required a high number of ugly solutions to be worth it, with time and a shitload of work I might resolve the issue in a nicer way but it requires too much work and time so I''m currently looking for another solution. -so- The only thing I really need is to get the mouseposition from Windows, but I haven''t found a good way to do that. Can anyone help me with this?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
GetCursorPos() is your saviour.
Messages suck for game input.

Share this post


Link to post
Share on other sites
Yeah, but framerate/speed is not an issue here, it''s just a 2d boardgame I''m making so framerate is not an issue right now.
But thanks, I''ll look into GetCursorPos!

Share this post


Link to post
Share on other sites
Check this out:

http://www.gamedev.net/reference/programming/features/win32wrapper/

Using the message router concept will eliminate the problems caused by the static member function WinProc (if i understand your problem correctly =] )

Share this post


Link to post
Share on other sites
I''m not quite sure what your problem is ... the WinProc function is global ... but so what ... each call is done with an hWnd parameter ... which is basically a "this" pointer ...

but none of that matters really -

if you have only one main window, then everytime you recieve a mouse message, just store the coordinate into a global variable - for everyone to access - cause a mouse is a global resource, just like your primary surface, and your sournd hardware, so just make a global / singleton object, and anyone who wants to use it, can.

Share this post


Link to post
Share on other sites

  • Advertisement