怎么来改变程序中的按钮的样式!比如把常规的方形的改为椭圆的!还就是改变按钮的颜色?比如把speedbutton原来的方形该为椭圆形的UP有分

解决方案 »

  1.   

    你可以使用1stCalss里面的按钮组件
      

  2.   

    ABC,1stclass之类的控件包都可以达到目的的,LMD也可以
      

  3.   

    有个空间叫BallButton可以, 你可以自己写一个呀。
      

  4.   

    用API函数吧。
    函数声明分别是:
        HRGN CreateRoundRectRgn(    int nLeftRect, // x-coordinate of the region's  upper-left corner 
        int nTopRect, // y-coordinate of the region's upper-left corner 
        int nRightRect, // x-coordinate of the region's lower-right corner 
        int nBottomRect, // y-coordinate of the region's lower-right corner 
        int nWidthEllipse, // height of ellipse for rounded corners 
        int nHeightEllipse  // width of ellipse for rounded corners 
       );int SetWindowRgn(    HWND hWnd, // handle to window whose window region is to be set
        HRGN hRgn, // handle to region 
        BOOL bRedraw // window redraw flag 
       );要在 uses 中使用 shellapi.pas,不然就不好用了。函数的具体的意思可以在SDK中找到。这里就不多说了。
    下面是一个例子//函数
    procedure RecttoRoundRect(Button:TButton);
    var
      myRgn:hrgn;
      HwndButton:hwnd;
    begin
      HwndButton:=Button.Handle;
      myRgn:=CreateRoundRectRgn(0,0,Button.Width,Button.Height,Button.Height,Button.Width);
      setwindowrgn(HwndButton,myRgn,true);
    end;//事件
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      RecttoRoundRect(Button1);
    end;
      

  5.   

    用API函数吧。
    函数声明分别是:
        HRGN CreateRoundRectRgn(    int nLeftRect, // x-coordinate of the region's  upper-left corner 
        int nTopRect, // y-coordinate of the region's upper-left corner 
        int nRightRect, // x-coordinate of the region's lower-right corner 
        int nBottomRect, // y-coordinate of the region's lower-right corner 
        int nWidthEllipse, // height of ellipse for rounded corners 
        int nHeightEllipse  // width of ellipse for rounded corners 
       );int SetWindowRgn(    HWND hWnd, // handle to window whose window region is to be set
        HRGN hRgn, // handle to region 
        BOOL bRedraw // window redraw flag 
       );要在 uses 中使用 shellapi.pas,不然就不好用了。函数的具体的意思可以在SDK中找到。这里就不多说了。
    下面是一个例子//函数
    procedure RecttoRoundRect(Button:TButton);
    var
      myRgn:hrgn;
      HwndButton:hwnd;
    begin
      HwndButton:=Button.Handle;
      myRgn:=CreateRoundRectRgn(0,0,Button.Width,Button.Height,Button.Height,Button.Width);
      setwindowrgn(HwndButton,myRgn,true);
    end;//事件
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      RecttoRoundRect(Button1);
    end;另外通过这种方法还可以实现不规则窗体等的一系列的问题。不知道你知不知道桌面动画?其实他就是这么实现的。如果有什么问题可以联系我,而且我也有一个桌面动画可以给你。E-mail:[email protected]
      

  6.   

    还是用 API  解决好一点
       可以写一个组件 以后自己用
      

  7.   

    没有这样的属性, 要自已写!  窗体放一个Panel. 和一个按钮
    加入下面的代码:unit RoundButton;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, ComCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Panel1: TPanel;
        procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      LastY, LastX : Integer;
      RegStr : TAtom;
    implementation{$R *.DFM}
    procedure DrawDownButton(Btnhandle : Hwnd; bDown : boolean);
    Const
      Border_Width = 5;
    var
      Rgn : HRGN;
      R : TRect;
      DC : HDC;
      hNewPen : HPen;
    begin
      windows.GetClientRect(Btnhandle,r);
      Rgn := CreateEllipticRgn(0,0,r.right,r.bottom);
      SetWindowRgn(Btnhandle,Rgn,True);
      DeleteObject(Rgn);
      SetWindowText(BtnHandle,'NewButton1');
      InvalidateRect(Btnhandle,nil,true);
      UpdateWindow(Btnhandle);
      DC := GetWindowDC(Btnhandle);
      if bDown then
        hNewPen := CreatePen(PS_SOLID,Border_Width,clSilver)//clWhite)
      else
        hNewPen := CreatePen(PS_SOLID,Border_Width,clBlack);
      SelectObject(Dc,hNewPen);
      Arc(DC,R.Left-Border_Width,R.Top-Border_Width,R.Right-Border_Width,
         R.Bottom-Border_Width,R.Left-Border_Width,R.Bottom-Border_Width,
         R.Right-Border_Width,r.Top-Border_Width);
      Arc(DC,R.Left,R.Top,R.Right,R.Bottom,R.Left,R.Bottom,R.Right,r.Top);
      if bDown then
        hNewPen := CreatePen(PS_SOLID,Border_Width,clBlack)
      else
        hNewPen := CreatePen(PS_SOLID,Border_Width,clSilver);
      SelectObject(Dc,hNewPen);
      Arc(DC,R.Left,R.Top,R.Right,R.Bottom,R.Right,R.Top,R.Left,r.Bottom);
      DeleteObject(hNewPen);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      DrawDownButton(Panel1.handle,false);
    end;
    procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      DrawDownButton(Panel1.handle,True);
    end;procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      DrawDownButton(Panel1.handle,False);
    end;
      

  8.   

    tshape没有按钮效果,还不能改变圆角的大小