Recent

Author Topic: Icon from Lazarus icons resource  (Read 10847 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Icon from Lazarus icons resource
« on: April 11, 2009, 08:37:15 pm »
Hi,
Lazarus have very nice collection of icons (I guess "Tango icons"?). Some icons are included in project exe file (like bitbuttons glyps). Can I somehow use this icons at runtime? I can't find any resource using resource explorer (PE Explorer, Reshack). Example, I want use some icons from bitbutton in my graphic control or speedbutton. I found LoadFromLazarusResource function in TBitmap but I don't know ResName values of this icons. I just don't want clutter resources by adding this same icons.
Regards

Paul Ishenin

  • Sr. Member
  • ****
  • Posts: 274
Re: Icon from Lazarus icons resource
« Reply #1 on: April 12, 2009, 07:09:19 am »
Look for names at lcl\btn_icons.lrs, lcl\dialog_icons.lrs.

Icon sources are places in lcl\images

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: Icon from Lazarus icons resource
« Reply #2 on: April 12, 2009, 02:45:26 pm »
Thanks for reply!
I have some technical dillema. This is the code:
Code: [Select]
SpeedButton1.Glyph := LoadBitmapFromLazarusResource(BitBtnResNames[bkOK]);Must I free SpeedButton1.Glyph before LoadBitmapFromLazarusResource? Because this function create new bitmap instance (Result := TBitmap.Create), but when I do this:
Code: [Select]
SpeedButton1.Glyph.Free;
SpeedButton1.Glyph := LoadBitmapFromLazarusResource(BitBtnResNames[bkOK]);   
... I have access violation. What about memory leaks?

Paul Ishenin

  • Sr. Member
  • ****
  • Posts: 274
Re: Icon from Lazarus icons resource
« Reply #3 on: April 12, 2009, 04:15:39 pm »
SpeedButton.Glyph is a property. This property has setter method. In that setter method Assign() call is used to replace old bitmap content with new. Thus you cannot destroy SpeedButton.Glyph. You need to use temporary variable:

Code: [Select]
B := LoadBitmapFromLazarusResource(BitBtnResNames[bkOK]);
SpeedButton1.Glyph := B;
B.Free;

Or better use next call:
Code: [Select]
SpeedButton11.LoadGlyphFromLazarusResource(BitBtnResNames[bkOK]);

 

TinyPortal © 2005-2018