|Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread|
|Messages 1 to 4 of 4 total|
|EWB 2 - Trying to change the background color temporarily|
|Sun, May 17 2015 4:51 PM||Permanent Link|
I would like to change the background color of a panel for 2 seconds before reverting back to the original color. The code I have used does not work and I have traced it to behavior demonstrated in the following code:
Timer(2); // Pause for 2 seconds--this works and is not the problem
ShowMessage('The color of the panel should have changed to orange by now, but it has not changed yet.');
The color of the panel changes to orange after the ShowMessage dialog is closed. How can I get the color to change before the Timer function is called?
Thanks for any help.
|Sun, May 17 2015 7:11 PM||Permanent Link|
On 5/17/2015 4:51 PM, David Martin wrote:
> Timer(2); // Pause for 2 seconds--this works and is not the problem
What does this do actually ?!
Are you blocking the execution by looping or such? If so then likely no
repaint takes place.
> The color of the panel changes to orange after the ShowMessage dialog is closed. How can I get the color to change before the Timer function is called?
i would suggest you use an actual timer for this.
prevColor := BasicPanel1.Background.Fill.Color;
BasicPanel1.Background.Fill.Color := clOrange;
Timer1.Interval := 2000;
Timer1.Enabled := true;
procedure TForm1.Timer1Timer(Sender: TObject);
Timer1.Enabled := false;
BasicPanel1.Background.Fill.Color := prevColor;
|Sun, May 17 2015 8:38 PM||Permanent Link|
>> Timer(2); // Pause for 2 seconds--this works and is not the problem
>What does this do actually ?!
As you surmised, this executes a dummy while loop for 2 seconds. I was not aware of the non-visual TTimer component that is on the System tab in the IDE. I followed your lead and was able to get the behavior I was looking for. Thank you!
|Mon, May 18 2015 4:00 AM||Permanent Link|
David Martin wrote:
> and was able to get the behavior I was looking for
If you want to get fancy, check out the animation capabilities. I have
a TPanel behind one button which I fade in and out to gentle bring
attention to it.