c++显示多个图像 gid+
我试图在按下鼠标左键时显示图像。
我可以显示图像,但如果再次按下鼠标左键,旧图像将被删除。
这是我的代码
显示图像函数
{ Graphics graphics(hdc); POINT pt; GetCursorPos(&pt); ScreenToClient(hWnd, &pt); Image shot(L"RegularShots.png"); graphics.DrawImage(&shot, pt.x, pt.y); }
鼠标左键按下
case WM_LBUTTONDOWN: RegularShots=0; InvalidateRect(hWnd, rect, false); break;
wm_paint
case WM_PAINT: hdc = BeginPaint(hWnd, &ps); OnPaint(hdc, hWnd, 1); if(RegularShots==0) { RegularShot(hdc, hWnd); } EndPaint(hWnd, &ps); break;
有什么想法吗?
im trying to display image when left mouse button is down.
i can display the image but if the left mouse button is down again than the older image would be deleted.
here is my code
display image function
{ Graphics graphics(hdc); POINT pt; GetCursorPos(&pt); ScreenToClient(hWnd, &pt); Image shot(L"RegularShots.png"); graphics.DrawImage(&shot, pt.x, pt.y); }
left mouse button down
case WM_LBUTTONDOWN: RegularShots=0; InvalidateRect(hWnd, rect, false); break;
wm_paint
case WM_PAINT: hdc = BeginPaint(hWnd, &ps); OnPaint(hdc, hWnd, 1); if(RegularShots==0) { RegularShot(hdc, hWnd); } EndPaint(hWnd, &ps); break;
anyideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要存储每次按下鼠标按钮时添加的坐标集合(数组/向量等) - 然后在 WM_PAINT 中渲染时,在每个位置绘制图像。
You need to store a collection (array / vector etc.) of coordinates that is added to each time the mouse button is pressed - and then when rendering in WM_PAINT, draw an image at each of these locations.