
Модератор: Модераторы




unit Unit1;
{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
  { TForm1 }
  TForm1 = class(TForm)
    Edit1: TEdit;
    ListBox1: TListBox;
    procedure FormCreate(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  private
    { private declarations }
    procedure NextItem(Count: Integer);
    procedure PrevItem(Count: Integer);
  public
    { public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.NextItem(Count: Integer);
begin
  if (ListBox1.ItemIndex + Count) < ListBox1.Items.Count then ListBox1.ItemIndex := ListBox1.ItemIndex + Count
  else ListBox1.ItemIndex := ListBox1.Items.Count-1;
end;
procedure TForm1.PrevItem(Count: Integer);
begin
  if (ListBox1.ItemIndex - Count) >= 0 then ListBox1.ItemIndex := ListBox1.ItemIndex - Count
  else ListBox1.ItemIndex := 0;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  case Key of
    27: Close;
    38: begin PrevItem(1); Key := 0; end;
    40: begin NextItem(1); key := 0; end;
  end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  ActiveControl := Edit1;
  ListBox1.ItemIndex := 0;
end;
end.
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1