Board index » delphi » use timer to delay or control the drawing?

use timer to delay or control the drawing?

I'm benginner.how to use the timer to delay and control the drawing.
 

Re:use timer to delay or control the drawing?


Quote
iris <chunyanm...@163.net> wrote in message 39deafb3_2@dnews...
> I'm benginner.how to use the timer to delay and control the drawing.

To be a beginner you have already advanced ideas :

Here is how you can do :

1) Put on your form a ttimer component
2) Set the initial timer interval property (1000=1 sec)
3) set initially timer enabled property to false
4) Declare 2 integer variables (your image coordinates ) for example xm , ym
in the implementation section of the unit
5) Write your drawing procedure for example :
        procedure tform1.draw(xm,ym:integer);
        begin
        // put here your code to draw
        end;
6)In your image onmousedown event put the lines :
        timer1.enabled:=true;
        timer1.interval:=1;  {fastest as possible (1=1 millisecond)}
7)In your image onmouseup event put the line :
         timer1.enabled:=false;
8)Implement the ontimer event :

procedure tform1.timer1timer(Sender: TObject);
begin
xm:=image1.screentoclient(mouse.CursorPos).x;
ym:=image1.screentoclient(mouse.CursorPos).y;
draw(xm,ym);

end;

am:=round(image1.screentoclient(mouse.CursorPos).x/zoomf);
bm:=round(image1.screentoclient(mouse.CursorPos).y/zoomf);

Other Threads