开发者

Problem to load from ID of a resource file in Delphi

开发者_StackOverflowWhen I use the method LoadFromResourceName(HInstance, 'PNGImage0') it works, but when I use LoadFromResourceID(Hinstance, 0) don't. It returns me an exception EResNotFound with message 'Resource 0 not found'.

I'd like to know what's the problem?

Edit

My RC File:

PNGImage0 RCDATA "Image0.png"
PNGImage1 RCDATA "Image1.png"
PNGImage2 RCDATA "Image2.png"
PNGImage3 RCDATA "Image3.png"
PNGImage4 RCDATA "Image4.png"
PNGImage5 RCDATA "Image5.png"
PNGImage6 RCDATA "Image6.png"


AFAIK a resource is identified either by name or by ID. You probably have an resource script (*.rc) that identifies the image by name like

PNGImage0 RCDATA "FileName.png"

where PNGImage0 is not defined as a number.

To define PNGImage0 as a number, just have

const
  PNGImage0 = 1;

in a unit (say YourResDefines.pas) and put #include "YourResDefines.pas" at the top of the *.rc file. Then you have to use LoadFromResourceID(HInstance, PNGImage0) without the single quotes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜