Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calling a function continuously

Posted on 1998-05-06
2
Medium Priority
?
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 400 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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