疯狂画线GDI
HPEN hPen = NULL;
HBRUSH hBrh = NULL;
HDC hdc = NULL;
RECT rect;
int i = 0;
//初始化画笔画刷等
int InitGDI()
{
hdc = GetDC(hWnd);
hPen = CreatePen(PS_SOLID,2,RGB(255,0,0));
SelectObject(hdc,hPen);
GetWindowRect(hWnd,&rect);
return 0;
}
int DrawLine(int x,int y,int xL,int yL)
{
hPen = CreatePen(PS_SOLID,2,RGB(rand()%255,rand()%255,rand()%255));
SelectObject(hdc,hPen);
MoveToEx(hdc,x,y,NULL);
LineTo(hdc,xL,yL);
DeleteObject(hPen);
return 0;
}
//
int Render()
{
if(i>100){
i = 0;
InvalidateRect(hWnd,&rect,true);
}
DrawLine(rand()%1024,rand()%768,rand()%1024,rand()%768);
i++;
return 0;
}
浙公网安备 33010602011771号