Solved

ListBox and AdvImage

Posted on 1998-11-11
6
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 106
When I am typing into a TEdit last word repeats 7 162
Controlled Assessment GCSE - desperate help needed 4 112
Delphi: ForceDirectory plain function 7 50
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 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