Jump to content
  • Advertisement
Sign in to follow this  
Manolis

Need help with mouse

This topic is 5166 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 downloaded and read through the NeHe OpenGL tutorials but I am having trouble with the mouse. I have discovered how to read its position but I dont know how to detect if a button is being clicked. if im not mistaken Wndproc takes care of all the messages sent by windows and I think windows would post a mesage when the mouse is clicked I just dont know what the message is and I need some help to syntax it. Thanx ppl

Share this post


Link to post
Share on other sites
Advertisement
The message is WM_LBUTTONDOWN. It is sent when the user presses the left button down. There are also messages like WM_MBUTTONDOWN and WM_RBUTTONUP etc. See the MSDN (the Notifications section).

To handle the message just add something like the following case statement to your WndProc and return 0 when you're done handling the message.




LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int x, y;

switch (message)
{

....

case WM_LBUTTONDOWN:
/* the coordinates where the click happened */
x=LOWORD(lParam);
y=HIWORD(lParam);

/* wParam contains some info about certain keys
and the mouse buttons. Again, see the msdn. */


break;
....
}

return 0;




edit: corrected the example

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!