Delphi6でボタンにグラデーションをつけられますか?
以下はいかが?
http://homepage2.nifty.com/Mr_XRAY/Delphi/plButton/index.htm
通常のTButtonは、ボタン表面の色すら変更不可能です。
# WindowsのBUTTONクラスがそういう仕様だったと思います。
他の方法としては
・自前でTCustomControlなどから作る。
・誰かが作ったコントロールを使う
ですね。
http://www.delphianworld.com/
http://www.torry.net/
このへんのリンクを押さえておくと、欲しいコンポーネントを探すのに便利です。
やっぱりないんですね。。。
ありがとうございます。
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;
ツイート | ![]() |