椭圆按纽制作

TButtonTest   =   class(TGraphicControl)  
  public  
      constructor   Create(aOwner:   TComponent);   override;  
  protected  
      procedure   Paint;   override;  
  end;  
   
  constructor   TButtonTest.Create(aOwner:   TComponent);  
  begin  
      inherited;  
      Height:=50;  
      Width:=100;  
  end;  
   
  procedure   TButtonTest.Paint;  
  begin  
      inherited;  
      Canvas.Brush.Style:=bsClear;  
      Canvas.Pen.Color:=clBlue;  
      Canvas.Brush.Color:=clGreen;  
      Canvas.RoundRect(0,0,Width,Height,8,8);//圆角矩形  
      Canvas.Ellipse(0,0,Width,Height);//椭圆  
  end;  
   
  var   Btn:TButtonTest;  
   
  Btn:=TButtonTest.Create(self);  
  Btn.Parent:=Self;   
椭圆形按钮:  
  type  
      TRbutton=class(TButton)  
  private  
      .......  
  protected  
      procedure   CreateWnd;override;  
      ........  
      ........  
  procedure   TRbutton.CreateWnd;//在控件一建立就设置  
  var  
      hRgn   :THandle;  
  begin  
      inherited     CreateWnd;  
      hRgn:=CreateEllipticRgn(0,0,Width,Height);//创建一个椭圆剪裁域;  
      SetWindowRgn(Handle,hRgn,True);  
  end;   
   

 

posted @ 2009-03-12 16:34  谭志宇  阅读(174)  评论(0编辑  收藏  举报