光标坐标 [英] Coordinate of cursor

查看:84
本文介绍了光标坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜;我怎样才能找到一个光标坐标并获得x,y并将其设置为两个

int如i,j?

解决方案

< blockquote>在纯C?不 - 它没有光标的概念,只是输出流的概念,它有一个位置,但不能转换为屏幕坐标(如果只是因为流不知道它将输出什么输出设备,所以它不知道它有线条,更不用说那些线条的宽度了。



有可能在某些系统中获得光标位置,但确切地说将如何依赖于环境,使用的库和编译器。


要获得光标位置,您需要进行系统调用,或者需要进行系统调用。

对于Windows,您可以使用WINAPI Systemcall GetCursorPos()。



您可以获得光标的位置:



 POINT cursorpPos 
GetCursorPos(& cursorPos);

int x =( int )cursorPos.x;
int y =( int )cursorPos.y;


请参阅 http: //msdn.microsoft.com/en-us/library/windows/desktop/ms682073(v=vs.85).aspx [ ^ ]。


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?

解决方案

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.


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:

POINT cursorpPos
GetCursorPos(&cursorPos);

int x = (int) cursorPos.x;
int y = (int) cursorPos.y;


See http://msdn.microsoft.com/en-us/library/windows/desktop/ms682073(v=vs.85).aspx[^].


这篇关于光标坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆