microsoftxiao

记忆 流逝

导航

疯狂画线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;
}

posted on 2006-10-03 14:39  龙巢NET刀  阅读(705)  评论(0)    收藏  举报