TTMSFNCBitmapContainer and procedure AddFromResource();

OS: Debian 10 (buster) LXDE
fpc 3.3.1
lazaraus 2.1

component: TTMSFNCBitmapContainer

Can you make an example of how to use
AddFromResource(

whether it is used
.lrs or .dcr
.png or .bmp

Hi,

When you are including a resource file, which has resources defined with the RT_RCDATA define, you can use the AddFromResource that is based on the name of the resource.

It fails me;
I don't seem to use it well.

source

...
{$DEFINE RT_RCDATA}

interface

...

bc:= TTMSFNCBitmapContainer.Create(Self);
bc.AddFromResource('ZCRibbonToolBarDBNavigator.lrs', 'TZCRIBBONDBNAVIGATORADD.PNG');
BitmapContainer := bc;

res := 'TZCRIBBONDBNAVIGATORADD';
FAdd := AddButton(24, 24, res, res+'LARGE');
FAdd.AllowFocus := False;
FAdd.ShortCutHint := 'A';
FAdd.AutoOptionsMenuText := 'Add';
FAdd.Stored := False;
FAdd.OnClick := @DataSetAdd;

...

Please read https://wiki.freepascal.org/Lazarus_Resources

This way I managed to get a picture:
FAdd.Bitmaps[0].Bitmap.Assign(GetDefaultGlyph(res));

When I run the program and bring the mouse, the image disappears.

We have tested this here and could not reproduce the issue. Please first read the link above and see how you can add bitmaps from resources. The code is working as expected.

Button01 Button02

Did you add an item to the HoverBitmaps collection?

Thank you,
That solved the problem.
Not add HoverBitmaps

1 Like

Thank you for the feedback!

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.