From fd54d7c12acc211d86d81ac4308c48f2bdd48dc4 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 17 Sep 2015 06:46:04 +0200 Subject: [PATCH] added util function to load shared res to btn --- src/ce_sharedres.pas | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/ce_sharedres.pas b/src/ce_sharedres.pas index f8ea6d8d..5d8521ce 100644 --- a/src/ce_sharedres.pas +++ b/src/ce_sharedres.pas @@ -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.