Jump to content
  • Advertisement
Sign in to follow this  
Basket Case

Mouse Input???

This topic is 4825 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 program that is in console, and I want to be able to check if a user clicks in a certain rectangle on the screen. I'm using GDI to draw text to the screen, is there a certain function that allows me to check if someone clicks there? Since I don't have a window I can't use The win32 API, and for this size of project it really isn't necesarry to use DirectInput, so does anyone else have another soloution...an explanation, code, or a tutorial would be nice. Thanks in advance, and tell me if you need any other information.

Share this post


Link to post
Share on other sites
Advertisement
When you make a console project you can still use Win32 functions.
In a loop or timer check where the mouse cursor is located, use GetCursorPos ().
If the x and y of the mouse are inside the rect, you can check if the left mouse button is down, use GetAsyncKeyState (VK_LBUTTON).
The number that GetAsyncKeyState () returns contains not only the key state (or mouse button state) so to check only if the key is up or down you need to check the most significant bit as following:
(GetAsyncKeyState () & 0x8000).
For more informaion about this function look here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getasynckeystate.asp

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!