Solved

ListBox and AdvImage

Posted on 1998-11-11
6
271 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

18 Experts available now in Live!

Get 1:1 Help Now