Einzelnen Beitrag anzeigen

Luki206
(Gast)

n/a Beiträge
 
#17

AW: Objekt an Trackbar Position ausrichten

  Alt 1. Apr 2014, 15:04
Ich werde es glaub ich nie lernen.. hier:
Delphi-Quellcode:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Imaging.pngimage, Vcl.ExtCtrls,
  Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    ImgEck1: TImage;
    ImgSlideGro: TImage;
    ImgEck2: TImage;
    ImgSlide: TImage;
    Timer1: TTimer;
    LblTest: TLabel;
    Ed1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Timer2: TTimer;
    Label1: TLabel;
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
  private
    { Private-Deklarationen }
    max : Integer;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
if not (Ed1.Text = '') then begin
  max := StrToInt(Ed1.Text) * 10;
  Timer1.Enabled := true;
  Timer2.Enabled := true;
end else begin
  Application.MessageBox('Bitte eine Maximal-Zahl eingeben!', 'MAX ZAHL', MB_ICONWARNING or MB_OK);
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled := false;
Timer2.Enabled := false;
Label1.Caption := '0';
ImgSlide.Left := ImgEck1.Left;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var maxwi: Integer;
begin
if (ImgSlide.Left = ImgEck2.Left) or (ImgSlide.Left > ImgEck2.Left+5) then begin
  ImgSlide.Left := ImgEck1.Left;
end else begin
  ImgSlide.Left := ImgSlide.Left+(((ImgEck1.Left+ImgEck2.Left+32)+ max div 60)div max);
end;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
Label1.Caption := IntToStr(StrToInt(Label1.Caption)+1);
end;

end.
  Mit Zitat antworten Zitat