Mouse Input???

Started by
0 comments, last by UriKiller 18 years, 9 months ago
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.
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

This topic is closed to new replies.

Advertisement