得到奇怪的光标位置
好的,今天我正在使用矢量,耶耶!
嗯,我也在使用 getcursorpos()
并且得到了奇怪的结果。
这是代码:
VOID fRegularShot(HDC hdc, HWND hWnd)
{
Graphics graphics(hdc);
Image shot(L"RegularShots.png");
long index=0;
while(index<=(long)pRegularShots.size())
{
index+=2;
int x=pRegularShots.at(index);
int y1=index+1;
int y=pRegularShots.at(y1);
graphics.DrawImage(&shot, x, y);
}
}
///////////////////////////////////////////////////
event
case WM_LBUTTONDOWN:
iRegularShots=0;
POINT pt;
GetCursorPos(&pt);
pRegularShots.insert(pRegularShots.begin()+1, pt.y);
pRegularShots.insert(pRegularShots.begin()+1, pt.x);
InvalidateRect(hWnd, rect, false);
break;
基本上,函数 fregularshots()
被调用并使用包含光标位置的向量元素,然后在光标位置绘制图像。
但它似乎没有将其绘制在光标位置上。
有什么想法吗?
Ok so I'm working with vectors today yaya!
well im also working with getcursorpos()
and i get weird results.
here is the code:
VOID fRegularShot(HDC hdc, HWND hWnd)
{
Graphics graphics(hdc);
Image shot(L"RegularShots.png");
long index=0;
while(index<=(long)pRegularShots.size())
{
index+=2;
int x=pRegularShots.at(index);
int y1=index+1;
int y=pRegularShots.at(y1);
graphics.DrawImage(&shot, x, y);
}
}
///////////////////////////////////////////////////
event
case WM_LBUTTONDOWN:
iRegularShots=0;
POINT pt;
GetCursorPos(&pt);
pRegularShots.insert(pRegularShots.begin()+1, pt.y);
pRegularShots.insert(pRegularShots.begin()+1, pt.x);
InvalidateRect(hWnd, rect, false);
break;
Well basically function fregularshots()
get called and use the vector elements which contains the positions of the cursor than draws the image on the cursor positions.
but it doesn't seem to draw it on the cursor positions.
any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GetCursorPos 返回屏幕坐标中的光标位置。使用 ScreenToClient(hWnd, ...) 将其转换为窗口客户端坐标。
您也可以在没有 GetCursorPos 函数的情况下工作。当收到 WM_LBUTTONDOWN 通知时,lParam 包含窗口客户端鼠标坐标:x 为低位字,y 为高位字:
编辑:
让我们让这段代码变得更简单。
GetCursorPos returns cursor position in screen coordinates. Use ScreenToClient(hWnd, ...) to convert it to window client coordinates.
You can work also without GetCursorPos function. When WM_LBUTTONDOWN notification is received, lParam contains window client mouse coordinates: x in low-order word, y in high-order word:
Edit:
Let's make this code more simple.