掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
ボタンにグラデーションをつけるには? (ID:14969)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
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;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.