Editbox の背景の画像を取得するにはどうすればよいですか?
4217 次
1 に答える
14
これは非常に可能です。フォームで、定義します
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
。時間があれば、これをするかもしれません。(そして、サードパーティの会社から高価な (そしておそらくそれほど高品質ではない) コンポーネント パックを購入する必要がないことに注意してください。)
于 2010-12-02T19:23:27.987 に答える