編集用の背景画像を設定する方法(Delphi)
-
30-09-2019 - |
質問
editboxの背景の画像を作成するにはどうすればよいですか?
解決
確かにこれは非常に可能です。あなたの形で、定義します
private
{ Private declarations }
FBitmap: TBitmap;
FBrush: HBRUSH;
protected
procedure WndProc(var Message: TMessage); override;
そして、やります
procedure TForm1.FormCreate(Sender: TObject);
begin
FBitmap := TBitmap.Create;
FBitmap.LoadFromFile('C:\Users\Andreas Rejbrand\Pictures\AS20Utv.bmp');
FBrush := 0;
FBrush := CreatePatternBrush(FBitmap.Handle);
end;
と
procedure TForm1.WndProc(var Message: TMessage);
begin
inherited;
case Message.Msg of
WM_CTLCOLOREDIT, WM_CTLCOLORSTATIC:
if (Message.LParam = Edit1.Handle) and (FBrush <> 0) then
begin
SetBkMode(Message.WParam, TRANSPARENT);
Message.Result := FBrush;
end;
end;
end;
もちろん、これを自分のコンポーネントに包むことができます。 TEditEx
. 。時間を過ごしたら、これをするかもしれません。 (そして、サードパーティの会社から高価な(そしてそれほど高品質ではない)コンポーネントパックを購入する必要がないことに注意してください。)
所属していません StackOverflow