Показать сообщение отдельно
  #6  
Старый 25.12.2009, 09:25
Аватар для Страдалецъ
Страдалецъ Страдалецъ вне форума
Гуру
 
Регистрация: 09.03.2009
Адрес: На курорте, из окна вижу теплое Баренцево море. Бррр.
Сообщения: 4,723
Репутация: 52347
По умолчанию

Так попробуйте:
Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, JPEG;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Button2: TButton;
    Image1: TImage;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
   Files: Array of string;
   Index: Integer;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
var
 fs: TSearchRec;
 x: string;
begin
 x:= Edit1.Text+'*.*' ;
 SetLength(Files, 0);
 Index := -1;
 if FindFirst(x, faAnyFile, fs) = 0
 then repeat
      if (ExtractFileExt(fs.Name) = '.bmp') or (ExtractFileExt(fs.Name) = '.jpg')
      then begin
           SetLength(Files, Length(Files)+1);
           Files[High(Files)] := Edit1.Text + fs.Name;
           end;
      until FindNext(fs)<>0;
 FindClose(fs);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 Inc(Index);
 if Index > High(Files) then Index := 0;
 Image1.Picture.LoadFromFile(Files[Index]);
end;

end.
и dfm
Код:
object Form1: TForm1
  Left = 192
  Top = 114
  Width = 870
  Height = 640
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Image1: TImage
    Left = 8
    Top = 88
    Width = 105
    Height = 105
    Proportional = True
    Stretch = True
  end
  object Button1: TButton
    Left = 16
    Top = 56
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Edit1: TEdit
    Left = 16
    Top = 24
    Width = 289
    Height = 21
    TabOrder = 1
    Text = 'Edit1'
  end
  object Button2: TButton
    Left = 312
    Top = 24
    Width = 65
    Height = 25
    Caption = 'Button2'
    TabOrder = 2
    OnClick = Button2Click
  end
end
__________________
Жизнь такова какова она есть и больше никакова.
Помогаю за спасибо.
Ответить с цитированием