Click here to Skip to main content
15,905,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi; how can i find a Coordinate of cursor and get x,y of that and set these in to two
int like i,j?
Posted
Comments
Captain Price 28-Dec-13 9:24am    
OS ? Framework ? Need to be more specific.

In pure C? No - it has no concept of a "cursor", just of an output stream, which has a position, but that is not translatable to screen coordinates (if only because the stream doesn't know what output device it is going to, so it doesn;t know it has lines, much less the "width" of those lines)

It may be possible to get the cursor position in some systems, but exactly how will be dependant on the environment, libraries used, and the compiler at the very least.
 
Share this answer
 
To get the cursor position you need a system call, or a library that does.
For Windows you can use the WINAPI Systemcall GetCursorPos().

You can get position of cursor like that:

C++
POINT cursorpPos
GetCursorPos(&cursorPos);

int x = (int) cursorPos.x;
int y = (int) cursorPos.y;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900