?
Solved

ListView/Imageview

Posted on 2003-03-31
6
Medium Priority
?
365 Views
Last Modified: 2010-04-06
I am trying to make an app that will display small "thumbnail" images for same size bitmaps in a common directory.  I am trying to use a listview and an imagelist to accomplish this with little success.  One problem is I can't get it to display all the images and when I do try to do it manually, it will diplay the filename for each file, but the bitmap it displays for every file is the first one I click on.  If I close the app and restart it, the first image I click on is the correct one, but all subsequent files display the bitmap image of the first one I clicked on.  Does anyone have any suggestions or sample code I could look at?  I would really appreciate it.
Jason
0
Comment
Question by:jason03
[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
  • 3
6 Comments
 
LVL 4

Expert Comment

by:cjm30305
ID: 8242224
I am posting 3 times.  Once to explain it, then I am going to post the form file, then the unit.  make sure you double click the selected directory twice to make sure it loads the files in the list box.  This is very crude, but does function properly.

Hope this helps.

Cheers.
0
 
LVL 4

Expert Comment

by:cjm30305
ID: 8242227
object Form1: TForm1
  Left = 387
  Top = 227
  Width = 653
  Height = 371
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Image1: TImage
    Left = 280
    Top = 216
    Width = 105
    Height = 105
  end
  object ListView1: TListView
    Left = 216
    Top = 48
    Width = 250
    Height = 150
    Columns = <>
    TabOrder = 0
    ViewStyle = vsList
    OnClick = ListView1Click
  end
  object DirectoryListBox1: TDirectoryListBox
    Left = 8
    Top = 48
    Width = 201
    Height = 153
    ItemHeight = 16
    TabOrder = 1
    OnDblClick = DirectoryListBox1DblClick
  end
  object DriveComboBox1: TDriveComboBox
    Left = 8
    Top = 208
    Width = 201
    Height = 19
    TabOrder = 2
    OnChange = DriveComboBox1Change
  end
  object FileListBox1: TFileListBox
    Left = 472
    Top = 48
    Width = 97
    Height = 17
    ItemHeight = 13
    Mask = '*.bmp'
    TabOrder = 3
    Visible = False
  end
end
0
 
LVL 4

Accepted Solution

by:
cjm30305 earned 200 total points
ID: 8242230
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, FileCtrl, ComCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    ListView1: TListView;
    DirectoryListBox1: TDirectoryListBox;
    DriveComboBox1: TDriveComboBox;
    FileListBox1: TFileListBox;
    Image1: TImage;
    procedure DriveComboBox1Change(Sender: TObject);
    procedure DirectoryListBox1DblClick(Sender: TObject);
    procedure ListView1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.DriveComboBox1Change(Sender: TObject);
begin
  DirectoryListBox1.Drive := DriveComboBox1.Drive;
end;

procedure TForm1.DirectoryListBox1DblClick(Sender: TObject);
var
 i: Integer;
begin
  ListView1.Items.Clear;
 
  FileListBox1.Directory := DirectoryListBox1.Directory;

  for i := 0 to FileListBox1.Items.Count - 1 do
   begin
    ListView1.Items.Add.Caption := FileListBox1.Items.Strings[i];
   end;
end;

procedure TForm1.ListView1Click(Sender: TObject);
var
 Dir: string;
 Filename: string;
begin
  Dir := DirectoryListBox1.Directory;
  Filename := ListView1.Selected.Caption;
  Filename := Dir + '\' + Filename;

  Image1.Picture.LoadFromFile(Filename);
end;

end.
0
 

Expert Comment

by:CleanupPing
ID: 9316523
jason03:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 10

Expert Comment

by:kacor
ID: 10041008
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to accept cjm30305's answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

kacor
EE Cleanup Volunteer
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

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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month10 days, 2 hours left to enroll

762 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