質問

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. 。時間を過ごしたら、これをするかもしれません。 (そして、サードパーティの会社から高価な(そしてそれほど高品質ではない)コンポーネントパックを購入する必要がないことに注意してください。)

Custom edit background

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top