Background color looping

  • Thread starter Thread starter mortb
  • Start date Start date
M

mortb

Hi
I want to loop the background color on my "about" form.
This is the code I've tried to use. It doesn't work.
The about form newer shows up. I thought Application.DoEvents(); would allow
the form to show

help appreciated!
/mortb

private void frmAbout_Load(object sender, System.EventArgs e)
{
do
{
int color = 0;
for(; color < 255; color ++)
{
this.BackColor = Color.FromArgb(color, color, color);
Application.DoEvents();
}
for(; color > 0; color --)
{
this.BackColor = Color.FromArgb(color, color, color);
Application.DoEvents();
}
}
while(true);
}
 
I want to loop the background color on my "about" form.
This is the code I've tried to use. It doesn't work.
The about form newer shows up. I thought Application.DoEvents(); would allow
the form to show

the problem with your code is that the Load event never ends.

put then a timer on your form and move the code from the Load event into the
timer's tick event handler. in the Load event just start the timer.

this should work.

regards,
Wiktor Zychla
 
* "Wiktor Zychla said:
the problem with your code is that the Load event never ends.

Another problem is that the form is not yet visible when the 'Load'
event handler is executed.
 
I solved it by putting a timer on the form -- the "infinte loop" approach
consumed to much CPU.

Thanks
 
Back
Top