How get the current File name of a TImage?

Please discuss general Delphi programming topics here.

How get the current File name of a TImage?

Postby hadipardis » July 18th, 2004, 8:12 am

Hi
I have a TImage which contains a picture.This picture was loaded from a file.Now I want to return the file name or exactly
the path name of it.Can you help me?
Thanks
cheers
hadipardis
Junior Member
Junior Member
 
Posts: 33
Joined: July 17th, 2004, 5:45 am

Postby aspence » July 18th, 2004, 9:23 am

Usually, a picture is assigned to a TImage at design time. When you do this, the 'load image' dialog is used to select an image from some drive location. At this point, the image is loaded and the data is stored directly in the forms dfm. No path to the image is stored anywhere. Once the image has been loaded, you could actually delete the original from the drive. There are two alternatives:

The first is certainly the most extreme. You could subclass TImage and add a property that holds a path (string). Then you could subclass the property editor for loading images (TPictureEditorDlg in PicEdit.pas). You could presumably modify this editor to pass the path info on to your new subclassed TImage. Yikes!

Secondly. You could assign the picture to a TImage programattically by calling TPicture.LoadFromFile and storing that path somewhere for later reference.
- Arnold B. Spence
aspence
Active Member
Active Member
 
Posts: 13
Joined: July 11th, 2004, 8:50 am
Location: Wolfville, N.S. Canada


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron