我很难弄清楚如何在其他地方绘制椭圆后删除它。我需要一个圆圈来一直跟随我的鼠标,这就是程序应该做的所有事情。我得到了鼠标位置并画了我的圆圈,但我怎样才能删除最后一个?
#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);
}
}