已知三角形三个顶点,要求用绿色填充该区域。我用fillrgn和CreatePolygonRgn弄了半天也没弄明白。那位高人帮帮我,给我一个例子(不要填充长方形的);

解决方案 »

  1.   

    you     can use      win APIGradientFill
    The GradientFill function fills rectangle and triangle structures. BOOL GradientFill(
      HDC hdc,                   // handle to DC
      PTRIVERTEX pVertex,        // array of vertices
      ULONG dwNumVertex,         // number of vertices
      PVOID pMesh,               // array of gradients
      ULONG dwNumMesh,           // size of gradient array
      ULONG dwMode               // gradient fill mode
    ); 
      

  2.   

    给个例子,我刚学,看不太明白msdn
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      Dc : HDC;
      Pt : Array [0..2] of TPoint ;
      Count1, count2 : Integer;
      Brush : TLogbrush;
      hBrush : LongInt;
    begin
      pt[0].x := 100;
      pt[0].y := 100;
      pt[1].x := 50;
      pt[1].y := 150;
      pt[2].x := 150;
      pt[2].y := 150;
      Dc := GetDC(handle);
      Brush.lbStyle := BS_SOLID;
      Brush.lbColor := clGreen;
      Brush.lbHatch := 0;
      hBrush := SelectObject(Dc,CreateBrushIndirect(Brush));
      Polygon(DC,pt,3);
      SelectObject(DC, hBrush);end;
      

  4.   

    easy!方法如下:画你所说的三角形,把填充颜色(即brush的颜色)设为你想要填充的颜色就是。