added util function to load shared res to btn

This commit is contained in:
Basile Burg 2015-09-17 06:46:04 +02:00
parent e9ca6f014a
commit fd54d7c12a
1 changed files with 23 additions and 1 deletions

View File

@ -3,10 +3,32 @@ unit ce_sharedres;
interface
uses
LResources;
LResources, Controls, Buttons, Graphics;
procedure AssignPng(ctrl: TControl; const resName: string);
implementation
procedure AssignPng(ctrl: TControl; const resName: string);
var
png : TPortableNetworkGraphic;
begin
png := TPortableNetworkGraphic.Create;
try
try
png.LoadFromLazarusResource(resName);
if ctrl is TCustomBitBtn then
TCustomBitBtn(ctrl).Glyph.Assign(png)
else if ctrl is TCustomSpeedButton then
TCustomSpeedButton(ctrl).Glyph.Assign(png);
except
end;
finally
png.Free;
end;
end;
initialization
{$I ../src/ce_icons.inc}
end.