Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How control TImage loading/unloading?

Posted on 1997-05-04
3
Medium Priority
?
292 Views
Last Modified: 2010-04-06
I think this is a simple one:

I am developing a small database application (not using BDE, but record ... end;) A TImage component is placed on the main form and when it's time to update the current record a certain image should be read from disk using LoadFromFile. The filename of the picture is built from the information in the database and can not be altered.

   Now, here's the question: If the file that is requested can not be found on disk (perfectly alright), how should I proceed? The TImage component should then be blank instead, but at the next update it should be able to contain a new picture. Should I solve it like this:

Image1.Picture.Free;
Image1.Picture := Nil;

or just like this:

Image1.Picture := Nil;

   If I free the Picture property, can I safely use LoadFromFile again when it's time to show another picture?
   If I just set the Picture property to Nil, does the LoadFromFile method use the same allocated memory the next time or does it allocate new memory since I didn't free the old chunk?

If I have not made myself clear, please tell me and I will explain it further. I consider this a very easy question, but I'm having some problem expressing myself since English's not my native language... ;-)

Thanks for your help.

Daniel, Malmoe, Sweden
0
Comment
Question by:Dippen
[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
3 Comments
 
LVL 2

Accepted Solution

by:
gysbert1 earned 100 total points
ID: 1335898
How about using the FillRect method, and filling it with a blank rectangle of size Image.Width by Image.Height? That way the TImage component is never destroyed, and the picture is blank...
0
 

Author Comment

by:Dippen
ID: 1335899
That sounds alright. I already have a white rectangular shape (as background) behind the picture. Wouldn't the easiest thing to do then to just check if the BMP-file exists. If it doesn't I use:

Image1.SendtoBack;

and if the file does exist I use LoadFromFile and BringToFront instead.
0
 
LVL 2

Expert Comment

by:gysbert1
ID: 1335900
If you already have the shape, then that is probably easier.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

721 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