Reaction Time Program: Keep Listen to MouseDown while in a p

Please discuss general Delphi programming topics here.

Reaction Time Program: Keep Listen to MouseDown while in a p

Postby nathan3073 » July 19th, 2008, 1:24 pm

Dear all,
I'm new in Delphi and need assistance for my problem. The description of my program and the problem I'm facing is as follow:

My Program
My program shows 25 circles arranged in a 5x5 square. There is also one button, labeled START. It is a reaction time program and what I wanna do is light one circle (YELLOW) every 1000ms and ask the user to CLICK ON the lighted circle as fast as he/she can. After the user click on the right circle, it will change into white. No matter how fast the user click the lighted circle, my program stays on a fixed interval of 1000ms between two lighting command. The lighting sequences start as the user pressed the START button. The lighting command (changing the circle's color) is put inside the startClick.

My Problem
The problem I'm facing is the program isn't responding to the circleMouseDown. FYI, I've made all the 25 circles their MouseDown procedure and tested them to change the circle color and they work fine. However, when I put them in real situation it's like they haven't even been called. I suspect this is because the program is still busy executing the statements placed in startClick.

Is there any way to capture the circleMouseDown even the program still runs startClick procedure? Nonetheless, after it responds to the circleMouseDown for the appropriate circle, I need it to come back to its last position in startClick.

That's all, any suggestions will be very helpful for me.

Nathanael Gratias

My Sampe Code for startClick and circleMouseDown:

Code: Select all
procedure TForm4.btnStartClick(Sender: TObject);
var j : integer;
 btnStart.Visible := false;

 for j:=2 to 7 do
   changeColor(pattern1[j-1], clWhite);
   changeColor(pattern1[j], clYellow);

procedure TForm4.circle1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
 if (circle1.Brush.Color = clYellow) then circle1.Brush.color := clWhite;
Posts: 1
Joined: July 19th, 2008, 1:19 pm

Postby Kambiz » July 19th, 2008, 8:59 pm

You should change the code for btnStartClick. Use a timer to wait for the interval.
User avatar
Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests