I used 3 timer component and I m using one checkbox. And I have three procedures for timer1, timer2 and timer3 and I writed below these in my unit code explorer. Note that band1,band2 and band3 are images that will be animated ordinarily.

procedure TForm1.Timer1Timer(Sender: TObject);
begin
timer1.Enabled:=true;
timer1.Interval:=2000;
band1.Visible:=true;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin

if band1.Visible=true then
begin
timer2.Enabled:=true; //set timer2
timer2.Interval:=4000;//work timer2 40 million miliseconds
band2.Visible:=true; //fire the command
end;
end;

procedure TForm1.Timer3Timer(Sender: TObject);
begin
if band2.Visible=true then
begin
timer3.Enabled:=true;
timer3.Interval:=6000;
band3.Visible:=true;
end;
But I want to use these three events in my checkbox6 component's click event procedure. can you help me about that object. how will I write the code inside my click event procedure for using my timer components according to checking position of my checkbox whose caption is "animate" .
procedure TAnaform.CheckBox6Click(Sender: TObject);
begin
if checkbox6.Checked then
begin
?????????????????????*here how will I write code using sender reserved word
???????????????????????
???????????????????????????
end;
end;
Lastly, I want to use these codes in a indefinite loop to work these images like an animation permanently since my checkbox is not checkbox.

Sorry I m not professional to write the forum. Ok I will be more careful after you told me secondly thus the code scopes will not be a nightmare for you. :)

Recommended Answers

All 4 Replies

You don't have to be a professional. You only need to pay attention. So far you have not.

When writing a post that contains code, place all your code in code blocks:

[[I][/I]code=Pascal[I][/I]]
program fooey;
begin
writeln( 'fooey' )
end.
[[I][/I]/code[I][/I]]

becomes:

program fooey;
begin
writeln( 'fooey' )
end.

Next, don't start a new thread for every post you make. If you are still working on a problem from a previous thread then reply to that thread.

Now, I've asked you several times to explain yourself better. You've not done that either. However, at this point I think I understand:

You have three image components (band1, band2, band3) which you wish to animate together by making one visible, then another, and then another, in succession, where only one is visible at any given time.

You only need one timer component. (Again, the documentation would have given you a very good example of what follows):

TForm1.Timer1Timer( Sender: TObject );
  begin
  if band1.visible then 
    begin
    band1.visible := false;
    band2.visible := true;
    //wait 4 sec before displaying band3
    timer1.interval := 4000
    end
  else if band2.visible then
    begin
    band2.visible := false;
    band3.visible := true;
    //wait 6 sec before displaying band1
    timer1.interval := 6000
    end
  else // band3 is visible
    begin
    band3.visible := false;
    band1.visible := true;
    //wait 2 sec before displaying band2
    timer1.interval := 2000
    end
  end;

Initially band1, band2, and band3 are all not visible, and Timer1.enabled = false. To start your animation:

procedure TAnaform.CheckBox6Click( Sender: TObject );
  begin
  // display the first band
  timer1timer( sender );
  // enable auto-display of each successive band
  timer1.enabled := true
  end;

Timers are resource-heavy, and there are only a limited number, so don't use any more than you need. For a single animation you only need one.

Hope this helps. If I have mis-understood what you are trying to do then please explain what it is you are trying to do.

Thank you my teacher duoas... your code is really improving me. I will try to be very careful as you wish. And sorry for a bad mis-understood... :(...

I will never forget your help and teaching duoas really thank you very much...

Hey, no problem. Glad to be of help.

The whole trick to programming is nitpicking to the nth degree. You have to think about things very exactly, and it takes a little while to be able to do that regularly. You'll do fine.

:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.