张志峰的博客

水滴石川,积少成多。

导航

1.  画两次不就可以了。。第一次画大的,第二画小的。。

procedure   TForm1.Button1Click(Sender:   TObject);  
   
  begin  
        with   Canvas   do  
        begin  
            Rectangle(100,100,300,300);  
            Rectangle(150,150,250,250);  
            Brush.Color   :=   clRed;  
            FillRect(rect(150,150,250,250));  
        end;  
  end;

2.先创建出HRGH的区域,再用CombineRgn获取环带的区域,之后填充:  
   
  var   a,   b,   c:   HRGN;  
          hbr:   HBRUSH;  
  begin  
      //     Canvas.Rectangle(100,200,400,400);  
      //     Canvas.RoundRect(120,220,300,350,100,100);  
      hbr   :=   CreateSolidBrush(clRed);  
      a:=CreateRectRgn(100,200,400,400);  
      b:=CreateRoundRectRgn(120,220,300,350,100,100);  
      c:=CreateRectRgn(0,0,1,1);  
      CombineRgn(c,   a,   b,   RGN_DIFF);  
      FillRgn(Canvas.Handle,c,   hbr);  
  end;