How cand I include a bitmap in my custom component (if is possible)?

Marus Nebunu

I am writing a component (a button) which needs a bitmap to be displayed on it. I don't want to make an ImageList property and the user assigns an image. I want that button to have only the image chosen by me.

I tried to include the bitmap in a resource file but when I try to access it I get "Resource not found" error message. This is what I've done:

myres.rc

FIXED BMP "fixed.bmp"

I compiled the resource file with: brcc32 myres.rc

Then I included it in my component unit...

implementation
{$R .\resources\myres.res}

And access it with...

MyComponent.Glyph.LoadFromResourceName(HInstance,'FIXED');
// MyComponent = class(TSpeedButton)

Edit1: I deleted the {$R .\resources\myres.res} directive and I loaded the resource from menu Project -> Resources and it's working, both with HInstance or FindClassHInstance(MyComponent).

Using a resource editor I found that when I load the resource from the menu the resource appears with the name "FIXED" as it should, but when I load the resource compiled with brcc32 it appears with the name "0". It seems that brcc32 doesn't set the name correctly.

But I don't want to load it from menu, I want it to be loaded automatically with the component.

Edit2: Remy Lebeau is correct. I was using a wrong BMP format (the file starts with 'BM6' characters instead 'BM8' like Photoshop produce it, and it works).

Remy Lebeau

Change BMP to BITMAP in your RC file, and change HInstance to FindClassHInstance() in your code:

FIXED BITMAP "fixed.bmp"

Glyph.LoadFromResourceName(FindClassHInstance(MyComponent), 'FIXED');

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How cand i add swipe up/down detection on a viewPager?

From Dev

How can I see the Bitmap class component

From Dev

How can I size my custom component appropriately?

From Dev

AngularDart: How to include subcomponents in a custom component template

From Dev

AngularDart: How to include subcomponents in a custom component template

From Dev

How do I get MVCSiteMap to include all my custom generated pages in the sitemap.xml

From Dev

How can I create my own distro and include a custom kernel & packages?

From Dev

How do I get MVCSiteMap to include all my custom generated pages in the sitemap.xml

From Dev

How do i access android 'hint' style from my custom component?

From Dev

How do I use a custom ReactJs component inside my JSX file from ReactJs.Net

From Dev

Angular 2/4: How do I make readonly work with my custom component

From Dev

How to get all referenced pages where i used my custom lightning component?

From Dev

How can I include a port in my domain?

From Dev

How should I include in my static library?

From Dev

How do I get a Palette for my bitmap once Picasso Loads it?

From Dev

How can I save my bitmap correctly for second time?

From Dev

How can I save my bitmap correctly for second time?

From Dev

How do I sharpen the image quality of a bitmap in my Android App?

From Dev

How can I listen to a RactiveJS custom component?

From Dev

How to include a custom library from GitHub into my Android app?

From Dev

How to include a custom library from GitHub into my Android app?

From Dev

How can I conditionally include images in React Native Component?

From Dev

Why I'm getting "Access Violation" when I put another component as a property in my custom component?

From Dev

i recovered my formatted partitions, how is that possible?

From Dev

How do I separate my component and my service?

From Dev

Zend Framework 1 > OK, I've written a custom validator. Where do I put it? How does my Zend_Form include it?

From Dev

Zend Framework 1 > OK, I've written a custom validator. Where do I put it? How does my Zend_Form include it?

From Dev

WCF: How cand you add multiple MessageBodyMember to a MessageContract if one is Stream

From Dev

How can I stretch my custom ListBox?

Related Related

  1. 1

    How cand i add swipe up/down detection on a viewPager?

  2. 2

    How can I see the Bitmap class component

  3. 3

    How can I size my custom component appropriately?

  4. 4

    AngularDart: How to include subcomponents in a custom component template

  5. 5

    AngularDart: How to include subcomponents in a custom component template

  6. 6

    How do I get MVCSiteMap to include all my custom generated pages in the sitemap.xml

  7. 7

    How can I create my own distro and include a custom kernel & packages?

  8. 8

    How do I get MVCSiteMap to include all my custom generated pages in the sitemap.xml

  9. 9

    How do i access android 'hint' style from my custom component?

  10. 10

    How do I use a custom ReactJs component inside my JSX file from ReactJs.Net

  11. 11

    Angular 2/4: How do I make readonly work with my custom component

  12. 12

    How to get all referenced pages where i used my custom lightning component?

  13. 13

    How can I include a port in my domain?

  14. 14

    How should I include in my static library?

  15. 15

    How do I get a Palette for my bitmap once Picasso Loads it?

  16. 16

    How can I save my bitmap correctly for second time?

  17. 17

    How can I save my bitmap correctly for second time?

  18. 18

    How do I sharpen the image quality of a bitmap in my Android App?

  19. 19

    How can I listen to a RactiveJS custom component?

  20. 20

    How to include a custom library from GitHub into my Android app?

  21. 21

    How to include a custom library from GitHub into my Android app?

  22. 22

    How can I conditionally include images in React Native Component?

  23. 23

    Why I'm getting "Access Violation" when I put another component as a property in my custom component?

  24. 24

    i recovered my formatted partitions, how is that possible?

  25. 25

    How do I separate my component and my service?

  26. 26

    Zend Framework 1 > OK, I've written a custom validator. Where do I put it? How does my Zend_Form include it?

  27. 27

    Zend Framework 1 > OK, I've written a custom validator. Where do I put it? How does my Zend_Form include it?

  28. 28

    WCF: How cand you add multiple MessageBodyMember to a MessageContract if one is Stream

  29. 29

    How can I stretch my custom ListBox?

HotTag

Archive