How to set background image for Edit (Delphi)

how can i have a image for Editbox background ?

Answers


This is very possible, indeed. In your form, define

private
  { Private declarations }
  FBitmap: TBitmap;
  FBrush: HBRUSH;
protected
  procedure WndProc(var Message: TMessage); override;      

and do

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;

and

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;

Of course you can wrap this into a component of your own, say TEditEx. If I get time over, I might do this. (And, notice that there is no need to buy an expensive (and maybe not that high-quality) component pack from a third-party company.)


Need Your Help

bootstrap dropdown: prevent scroll to top of the page when <li> clicked

javascript jquery html css twitter-bootstrap

I have two dropdown menus (split buttons) which behave pretty much the same way, so I'll just post the code for one of them. So, when the dropdown is active, the user can press on numbers going fro...

How can I access data from a JSON object returned from API call?

php json

I want to create an array, json_encode it, then send it off via echo. The array needs to be created from the following server response I'm getting from an external API:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.