掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
TLabelを半透明化するには? (ID:16744)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
Panel1 の上に Image1 を貼って、 Image1 の Align を alClient にし、 Panel1 の Border や Bevel を全部 None にし、 以下を実行すれば半透明のラベルのように見えます。 var H: HDC; R: TRect; X, Y: integer; C: TColor; bR, bG, bB: Byte; wR, wG, wB: Word; begin Panel1.Visible := False; Application.ProcessMessages; //パネルの背景をImageに描画 H := GetWindowDC(Handle); BitBlt(Image1.Canvas.Handle, 0, 0, Image1.Width, Image1.Height, H, Panel1.Left+4, Panel1.Top+23, SRCCOPY); //Imageを半透明化 for Y := 0 to Image1.Height - 1 do begin for X := 0 to Image1.Width - 1 do begin C := Image1.Canvas.Pixels[X, Y]; bR := GetRValue(C); wR := bR div 2 + 128; if wR > 255 then wR := 255; bG := GetGValue(C); wG := bG div 2 + 128; if wG > 255 then wG := 255; bB := GetBValue(C); wB := bB div 2 + 128; if wB > 255 then wB := 255; Image1.Canvas.Pixels[X, Y] := RGB(wR, wG, wB); end; end; //パネルのキャプションを真ん中に描画 R.Top := 0; R.Left := 0; R.Right := Image1.Width; R.Bottom := Image1.Height; Image1.Canvas.Brush.Style := bsClear; Image1.Canvas.Font := Panel1.Font; DrawText(Image1.Canvas.Handle, PChar(Panel1.Caption), Length(Panel1.Caption), R, DT_CENTER or DT_SINGLELINE or DT_VCENTER); Panel1.Visible := True; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.