مشاهدة النسخة كاملة : كيفية ايقاف الوقت
manoubi77
06-05-2010, 03:20 PM
السلام عليكم ورحمة الله وبركاتة
كيفية ايقاف الوقت؟
شرح للسؤال
قمت بوضع "timer1" و ارغب في ان يتوقف بعد 10 ثواني
و شكرا.
kachwahed
06-05-2010, 03:37 PM
وعليكم السلام ورحمة الله وبركاته
var
I: Integer = 0;
//On Timer1Time
begin
if I = 10 then
Timer1.Enabled := False
else Inc(I);
end;
manoubi77
06-05-2010, 06:00 PM
السلام عليكم ورحمة الله وبركاتة
لقد قمت بوضع الكود كما قلت و لكن لا يعمل و السبب:
[Error] Unit1.pas(28): Cannot initialize local variables
http://shup.com/Shup/332374/Sans-titre.png
kachwahed
06-05-2010, 07:45 PM
كتبت لك:
//On Timer1Time
أي أن ما سيأتي من الكود تكتبه في OnTimerTime1
السطر:
I: Integer = 0;
اكتبه فوق :)
AL-MOB4RM3G
06-05-2010, 09:00 PM
اكتبه فوق :)
الأخ كاش واحد يقصد بهذه الطريقة تقريبا,
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i : integer = 0;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if i = 10 then
begin
timer1.Enabled := false;
Showmessage('Timer now is False');
end
else
inc(i);
end;
end.
بالتوفيق,
الكاسر الآخر
17-05-2010, 10:40 AM
هناك طريقة أخرى ...هي أن تضع خاصية Interval في التايمر 10 ثواني أي 10000
وتكتب الكود في Timer1Ontimer
Timer1.Enabled := False;
فقط
vBulletin® , Copyright ©2008-2012