Solved

ListBox and AdvImage

Posted on 1998-11-11
6
269 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
Comment Utility
hi mhieta,

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

meikl
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
Ooops,

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

meikl
0
 
LVL 2

Author Comment

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

mhieta
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 4

Accepted Solution

by:
BoRiS earned 20 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks BoRiS, also thanks to viktor. That BoRiS answer work
very well. Thanks again.

mhieta
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now