Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

delphi - Can I retrieve Filename for TPicture directly?

I have a Delphi application which displays an image using a TImage.

The location of the image is stored in a database and retrieved on load and set directly using code similar to below:

Image1.Picture.LoadFromFile(Query1.FieldByName('image').AsString);

I want to be able to display and edit the Filename being loaded during the above, am I right that there is no way to access that directly from the TImage component and that I will need to store the filename separately?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

No, there isn't. You can store it yourself, though.

var
  ImageFileName: string;


begin
  ImageFileName := Query1.FieldByName('image').AsString;
  Image1.Picture.LoadFromFile(ImageFileName);
end;

Declare the ImageFileName variable at a place where it will be visible everywhere you need access to the file name.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...