Link to home
Start Free TrialLog in
Avatar of Member_2_99151
Member_2_99151

asked on

Error EResNotFound when using custom component at runtime

Hi All,

I have written a delphi component package.
One of its components uses resources that are loaded at runtime using the following:

. . .
xPNGImage := TPNGImage.Create;
xPNGImage.LoadFromResourceName(FindClassHInstance(Self.ClassType), 'MyResName');
img := TImage.Create(ParComp);
img.Picture.Bitmap.Assign(xPNGImage);
. . .

Open in new window


Now, when I place this component on a form in another application, it works fine and the images display correctly.

When i try to run the app, I get EResNotFound when trying to load the resource!

I'm sure I am missing something obvious, but I cannot see it!

Any help would be appreciated.

Regards,

James
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Please try:

xPNGImage.LoadFromResourceName(HInstance, 'MyResName');

Open in new window

Avatar of Member_2_99151
Member_2_99151

ASKER

Thanks for the response.
I had HInstance in the orignal code, but had the same error.
I found an online resource that suggested changing this for FindClassHInstance(Self.ClassType) but to no avail...
This code would work fine in the same project, but as it is in a component, it seems to fail. Interestingly, it works fine in the IDE at design time :-O
ASKER CERTIFIED SOLUTION
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, that seems to do the trick...  :-)