Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ListBox and AdvImage

Posted on 1998-11-11
6
Medium Priority
?
282 Views
Last Modified: 2010-04-04
Is there any way to display image from ListBox, i have added
filenames to listbox and i want to display image file in the AdvImage or JPEGImage what i listed in the ListBox.

mhieta
0
Comment
Question by:mhieta
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346517
hi mhieta,

why you don't use TListView? Here can be simple added Pictures.

meikl
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1346518
Ooops,

i think i have not really read the question. Sorry.

meikl
0
 
LVL 2

Author Comment

by:mhieta
ID: 1346519
meikl>> i wanna use listbox because, i used listbox to display results searching files
from hard disk, so the listbox display files.

mhieta
0
Technology Partners: 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!

 
LVL 4

Accepted Solution

by:
BoRiS earned 80 total points
ID: 1346520
mhieta

If you are doing what I think you are doing, then you are loading image names into a list view and then you want display the image when the use clicks on the listbox item...

fist the listbox items must contain the path as well as the filename

eg..
c:\windows\players.jpg

If this is what you are doing then pass this code...

procedure TForm1.ListBox1Click(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to (ListBox1.Items.Count - 1) do begin
    if ListBox1.Selected[i] then begin
      if not FileExists(ListBox1.Items.Strings[i]) then begin
        MessageDlg('File: ' + ListBox1.Items.Strings[i] +
                   ' not found', mtError, [mbOk], 0);
        Continue;
      end;
       Image1.Picture.LoadFromFile(ListBox1.Items.Strings[i]);
      end;
end;
end;

This will result in the listbox item clicked been loaded in the image1.  Remember that you must add Jpeg to your uses clause

uses
 Windows, Forms,...,Jpeg

Later
BoRiS
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1346521
Here is how this can be done...

YOu need to add JPEG to your uses clause, and also have a TImage component on your form as well as your listbox...

OnListBoxClick();
var
  JPG : TJpegImage;
  FileName : String;
begin
  if ListBoxName.ItemIndex <> -1 then begin
    FileName := ListBoxName.Items.Strings[ListBoxName.ItemIndex];
    if not FileExists(FileName) then exit;
    JPG := TJpegImage.Create;
    JPG.LoadFromFile(FileName);
    ImageName.Picture.Assign(JPG); //If only JPG doesn't work, try JPG.Picture...
    JPG.Free;
  end;
end;

That's all y'all

C'Ya

Cheers,
Viktor
0
 
LVL 2

Author Comment

by:mhieta
ID: 1346522
Thanks BoRiS, also thanks to viktor. That BoRiS answer work
very well. Thanks again.

mhieta
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

824 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