?
Solved

reading a gif file from .res resource

Posted on 1998-07-09
4
Medium Priority
?
338 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month8 days, 13 hours left to enroll

764 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