ボタンにグラデーションをつけるには?

解決


ニッシュ  2005-05-24 01:18:25  No: 14965

Delphi6でボタンにグラデーションをつけられますか?


通り縋り  2005-05-24 01:38:30  No: 14966

以下はいかが?
http://homepage2.nifty.com/Mr_XRAY/Delphi/plButton/index.htm


にしの  2005-05-24 02:20:32  No: 14967

通常のTButtonは、ボタン表面の色すら変更不可能です。
# WindowsのBUTTONクラスがそういう仕様だったと思います。

他の方法としては
・自前でTCustomControlなどから作る。
・誰かが作ったコントロールを使う
ですね。

http://www.delphianworld.com/
http://www.torry.net/
このへんのリンクを押さえておくと、欲しいコンポーネントを探すのに便利です。


ニッシュ  2005-06-09 03:38:51  No: 14968

やっぱりないんですね。。。
ありがとうございます。


deldel  2005-06-09 17:52:30  No: 14969

TSpeedButton ならできますよ。

var
  saCap: AnsiString;
  StartColor: integer;
  EndColor: integer;
  sR, sG, sB: Byte;
  eR, eG, eB: Byte;
  R, G, B: Byte;
  iwH: Word;
begin
  saCap := SpeedButton1.Caption;
  SpeedButton1.Caption := '';

  SpeedButton1.Glyph.Height := SpeedButton1.Height;
  SpeedButton1.Glyph.Width := SpeedButton1.Width;
  with SpeedButton1.Glyph do begin
    //上部の色
    StartColor := clBlue;

    //下部の色
    EndColor := clLime;

    //上部のRGB色
    sR := StartColor and $FF;
    sG := (StartColor shr 8) and $FF;
    sB := (StartColor shr 16) and $FF;

    //下部のRGB色
    eR := EndColor and $FF;
    eG := (EndColor shr 8) and $FF;
    eB := (EndColor shr 16) and $FF;

    for iwH := 0 to SpeedButton1.Glyph.Height-4 do begin
      R := sR + Trunc((eR - sR) / (SpeedButton1.Glyph.Height-3) * iwH) mod 256;
      G := sG + Trunc((eG - sG) / (SpeedButton1.Glyph.Height-3) * iwH) mod 256;
      B := sB + Trunc((eB - sB) / (SpeedButton1.Glyph.Height-3) * iwH) mod 256;

      Canvas.Brush.Color := RGB(R, G, B);
      Canvas.FillRect(Rect(0, iwH, SpeedButton1.Glyph.Width-3, iwH + 1));
    end;

    Canvas.Brush.Style := bsClear;
    Canvas.Font := SpeedButton1.Font;
    Canvas.TextOut((Width - Canvas.TextWidth(saCap)) div 2,
                   (Height - Canvas.TextHeight(saCap)) div 2,
                   saCap);
  end;
end;


※返信する前に利用規約をご確認ください。

※Google reCAPTCHA認証からCloudflare Turnstile認証へ変更しました。






  このエントリーをはてなブックマークに追加