首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

关于鼠标坐标的有关问题

2012-02-29 
关于鼠标坐标的问题LPPOINTpointGetCursorPos(point//cursorposition)CStringstrstr.Format( x%d,y%

关于鼠标坐标的问题
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);
[解决办法]
楼上正确

热点排行