Solved

reading a gif file from .res resource

Posted on 1998-07-09
4
303 Views
Last Modified: 2010-04-04
hi,

I made a res file as follows using brcc32
gif.rc =>
gif gif 0.gif

But I cannot get it to load, I always get a read of adress error. So I must be doing something wrong.
Can anyone show me how to load it.

Procedure Tform1.FormCreate(Sender: TObject);
var
?
begin
?
GifImage1.FileName := ?
end;

Thanks
0
Comment
Question by:hellfire052497
  • 2
4 Comments
 
LVL 3

Expert Comment

by:vladika
ID: 1357466
What is GifImage?
If it is nonstandart component, where can I find it?

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1357467
Vladika, If you go to Torrys page (http://bes.trendline.co.il/torry/), you can find dozens of components that read GIF and all sorts of graphics. I thought that at leas some of them can read files from resources, but I didn't find aything...
0
 
LVL 3

Accepted Solution

by:
vladika earned 100 total points
ID: 1357468
I think you use TGifImage from Torrys page

1) create gif.rc as you write
gif.rc =>
gif gif 0.gif

2) compile it with brcc32 -> you get gif.res
Now gif.res include gif file as resource (type='GIF', name='GIF')

3) create new project and set GifImage on Form1

4) in your program

{$R gif.res}  // include resource into exe - do not forget !!!

procedure TForm1.FormCreate(Sender: TObject);
begin
  GifImage1.LoadFromResourceName(hInstance, 'GIF'); // 'GIF' - resource name
end;

5) also you can use TResourceStream

{$R gif.res}  // include resource into exe - do not forget !!!

procedure TForm1.FormCreate(Sender: TObject);
var RS: TResourceStream;
begin
  RS := TResourceStream.Create(hInstance, 'GIF', 'GIF'); // Name - 'GIF', Type - 'GIF'
  try
    GifImage1.LoadFromStream(RS); // load from resource stream RS
  finally
    RS.Free;
  end;
end;

0
 

Author Comment

by:hellfire052497
ID: 1357469
The first option works. It is easier then I thought. Thanks.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now