怎么把一个控件简单的改成圆形?

解决方案 »

  1.   

    API,自己去查吧,论坛里想必很多HGDIOBJ SelectObject(    HDC hdc, // handle of device context 
        HGDIOBJ hgdiobj  // handle of object  
       );
     
    Region CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect
      

  2.   

    重新处理paint事件,爱怎样画就怎样画吧!!
      

  3.   

    怎样能把button画成圆形外观
    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;