Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Using image URL in listview & Stringlist.



Permlink Replies: 1 - Last Post: Jan 31, 2015 7:26 AM Last Post By: Eli M
Stev Warby

Posts: 50
Registered: 10/19/14
Using image URL in listview & Stringlist.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 31, 2015 4:12 AM
I am using a MYSQL database that has staff images store as a url. I use the following to populate an image on the onchange event of an editbox linked to the dataset.

function DownloadIMG(const URL : String; var Image : TImage): Boolean;
var HTTP : TIdHttp;
Stream : TStream;
begin
Result := False;
HTTP := TIdHttp.Create(nil);
try
Stream := TMemoryStream.Create;
try
HTTP.Get(URL, Stream);
Stream.Position := 0;
Image.BitMap := TBitMap.Create(0, 0);
Image.BitMap.LoadFromStream(Stream);
Result := True;
finally
Stream.Free
end
finally
HTTP.Free
end;
end;

What I need to do is :

1. Make this image appear in the listView Image control.
2. Add an image component into the string grid so each row has the appropriate image.
3. The way I am working looks inefficient as each time I download the image again. Is there a 'correct' procedure to store the images once download.

thanks...
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Using image URL in listview & Stringlist.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 31, 2015 7:26 AM   in response to: Stev Warby in response to: Stev Warby
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02