Resource not found in custom component after migrating to Delphi 10.2


My custom component loads two bitmaps from resource file. It does work fine in Delphi XE4. Now in Delphi 10.2.1 Tokyo it doesn't work

I link the resource file via following command in the source code of the component:

{$R StateImage.res StateImage.rc}

Where StateImage.rc contains:

BITMAP1 BITMAP "StateImageOn.bmp"
BITMAP2 BITMAP "StateImageOff.bmp"

I examined the compiled packages in a resource editor for both versions: The .BPL do contain the bitmaps in Delphi XE4, but doesn't in Delphi 10.2.1. So I used then the command "Project > Resources and Images..." and added the bitmaps in this way to the package project. After that the bitmaps were included in the compiled .BPL. The component can be placed on a new form and shows images while design-time. But when running, it generates "Resource not found".

When I check the compiled sample .EXE for resources, the bitmaps are missing in Delphi 10.2.1. The version compiled in Delphi XE4 includes the bitmaps.

The project options are identical, list of runtime packages, library and search paths too.

The bitmaps are loaded with

bmp.LoadFromResourceName(HInstance, 'BITMAP1');

And it works as soon as I add the resource file manually to the sample unit with {$R ...}. But this resource file belongs to the component/package and should be linked by the compiler automatically...

Why the compiler doesn't includes the component's resource into the resulting .EXE on Delphi 10.2.1?

Responses (0)
  • There are no replies here yet.
Your Reply

Please login to post a reply