allow more ctrl types to be assignedto

This commit is contained in:
Basile Burg 2015-09-17 18:16:58 +02:00
parent 87fa0333fa
commit 546052732f
1 changed files with 6 additions and 4 deletions

View File

@ -3,23 +3,25 @@ unit ce_sharedres;
interface
uses
LResources, Controls, Buttons, Graphics;
LResources, Classes, Controls, Buttons, Graphics;
procedure AssignPng(ctrl: TControl; const resName: string);
procedure AssignPng(ctrl: TPersistent; const resName: string);
implementation
var
png: TPortableNetworkGraphic;
procedure AssignPng(ctrl: TControl; const resName: string);
procedure AssignPng(ctrl: TPersistent; const resName: string);
begin
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);
TCustomSpeedButton(ctrl).Glyph.Assign(png)
else if ctrl is TBitmap then
TBitmap(ctrl).Assign(png);
except
end;
end;