我有点难以理解,如何在其他地方绘制之后移除绘制的椭圆。我需要一个圈子来随时关注我的鼠标,这就是程序应该做的所有事情。我得到鼠标位置并画出我的圈子,但我怎样才能删除最后一个?如何刷新/重画屏幕(不是程序窗口)
#include <Windows.h>
#include <iostream>
void drawRect(int a1, int a2){
HDC screenDC = ::GetDC(0);
//Draw circle at mouse position
::Ellipse(screenDC, a1, a2+5, a1+9, a2+14);
::ReleaseDC(0, screenDC);
//::InvalidateRect(0, NULL, TRUE); //<- I tried that but then everything flickers
//Also, the refresh rate is not fast enough... still some circles left
}
int main(void)
{
int a1;
int a2;
bool exit=false;
while (exit!=true)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
float x = 0;
x = cursorPos.x;
float y = 0;
y = cursorPos.y;
a1=(int)cursorPos.x;
a2=(int)cursorPos.y;
drawRect(a1, a2);
}
}
嗯,我读过关于此之前,但我不完全明白。正如我所说的,我第一次使用这个工具,而且我更像是一个系统管理员而不是程序员。你知道我可以看一些例子吗? – mohrphium
会尝试,但这需要一些时间来思考。第一个问题是:你想要简单的WinAPI或MFC的提示吗? – Forgottn
无论哪种方法更容易实现,因为我对其中任何一方都没有经验。 – mohrphium