读书人

关于鼠标坐标的有关问题

发布时间: 2012-02-29 16:44:10 作者: rapoo

关于鼠标坐标的问题
LPPOINT point;

GetCursorPos(
point // cursor position
);

CString str;

str.Format( "x=%d, y=%d ", point-> x,point-> y);


这段代码有什么问题,有什么限制没有。 当我测试时,点击按钮时,

没有任何值,point-> x,point-> y 发生异常


不知道,调用GetCursorPos时,是不是有什么限制


[解决办法]
指针没分配内存就使用了,当然异常了。

POINT point;

GetCursorPos(
&point // cursor position
);

CString str;

str.Format( "x=%d, y=%d ", point.x,point.y);
[解决办法]
楼上正确

读书人网 >C++

热点推荐