void CXXXDlg::OnLButtonDown(UINT nFlags, CPoint point) { COLORREF color=RGB(rand()%255,rand()%255,rand()%255); CDC* dc=GetDC(); CPen pen(PS_SOLID,1,color); int r=rand()%80+10; CBrush brush(color); dc->SelectObject(brush); dc->SelectObject(pen); CPoint pt[15]; int type=rand()%6; int df; switch(type) { case 0: dc->Ellipse(point.x-r,point.y-r,point.x+r,point.y+r); break; case 1: dc->Rectangle(point.x-r,point.y-r,point.x+r,point.y+r); break; case 2: dc->RoundRect(point.x-r,point.y-r,point.x+r,point.y+r,20,20); break; case 3: case 4: case 5: df=rand()%7+3; for(int i=0;i<df;i++) { pt[i].x=point.x+(int)((float)r*cos((i-90)*3.1415926/((float)df/2.0))); pt[i].y=point.y+(int)((float)r*sin((i-90)*3.1415926/((float)df/2.0))); } CRgn hrgn; dc->BeginPath(); dc->MoveTo(pt[0]); for(i=0;i<df-1;i++) { dc->LineTo(pt[i+1]); } dc->LineTo(pt[0]); dc->CloseFigure(); dc->EndPath(); hrgn.CreateFromPath(dc); dc->FillRgn(&hrgn,&brush); } CDialog::OnLButtonDown(nFlags, point);}