简体   繁体   中英

GIf Resource in delphi

I'm trying to do a simple resource(GIF) opening in delphi, res.RC file :

Loading RCDATA "loadingAd.gif"

Code:

{$R *.dfm}
{$R res.RES}

procedure TForm1.Image1Click(Sender: TObject);
var h : THandle;
begin
   h := FindResource(HInstance, 'Loading', 'RCDATA');
   showmessage(IntToStr(h))
end;

But every time i get 0, i'm using XE4 so i tried maybe :

{$R *.dfm}
{$R res.RES}

procedure TForm1.Image1Click(Sender: TObject);
var h : THandle;
begin
   h := FindResource(HInstance, PChar('Loading'), PChar('RCDATA'));
   showmessage(IntToStr(h))
end;

Still getting "Resource not found".

You're searching for the resource under the wrong resource type. The string 'RCDATA' is not the same as the constant RT_RCDATA , which is actually the integer 10 coerced to have type PChar . Use that instead of the string literal. If the resource still isn't found, verify using a resource browser that your program really contains the resources you expect it to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM