Reputation: 193
In this scenario, I created a default button on my FireMonkey HD application via RADStudio XE2. I then created a custom style for the button, named "Style1". This style is very much similar to the default button style, however, it has a TImage control next to the TText control.
In simple words, a button with an image next to the text.
Now, I'll apply an image to the TImage control for the button? Because if I apply an image to the TImage control VIA the style designer, the other controls who use the style will also get the same image.
Upvotes: 1
Views: 1307
Reputation: 3234
you can do it at runtime.
at first you have to name your TImage style object, for ex. 'btnimg'
after that you can find it by name using FindStyleResource
:
procedure LoadImage(btn : TButton; imgFileName : string);
var img : TImage;
begin
img := btn.FindStyleResource('btnimg') as TImage;
if not assigned(img) then exit;
img.bitmap.LoadFromFile(imgFileName);
end;
Upvotes: 3