Solved

Calling a function continuously

Posted on 1998-05-06
2
151 Views
Last Modified: 2010-04-06
I wrote a function that moves an object across a form and bounces off the edges.. (each time the function is called, the object moves 2 pixels in a specified direction, if that movement causes it to exceed the edge of the form, I change the direction and move away from the edge)

How do I keep calling this function as long as my Form exist.

I want the object to keep moving around until I change a variable (by pressing a button)... I also want to be able to do other operations on this form  (press other buttons...) without stopping the movement of my object?

Any ideas??
0
Comment
Question by:rafy
2 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 100 total points
ID: 1342523
Hi

There are several ways of doing this.  By far the quickest is to add a TTimer to your form (TTimer is on System tab on Delphi's component palette).  Set the TTimer's interval to number of milliseconds (e.g. 500 for half sec) and program the OnTimer event.  This shouldn't interfere with the rest of your program.

Another method is to create a thread to handle the movement of your object.  This would require more work, but if you want to investigate it, look up TThread in Delphi.

Cheers,
JB
0
 

Author Comment

by:rafy
ID: 1342524
The timer works great as long as the other event is discrete like a button press, but it still stops (even the timer) when the event is something like onmousemove where I do something else as long as the mouse is located on my button.  This suspends the timer (and the bounce) until I move my mouse away from the button.

Oh well, Threads it is!
Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now