Solved

ListBox and AdvImage

Posted on 1998-11-11
6
272 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 4

Accepted Solution

by:
BoRiS earned 20 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

786 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