R
Ron
I have a simple form that contains a panel. I am overriding the base
OnMouseEnter/Leave events.
I want to fade the panel in when the user mouseovers the panel, and return
back to transparent when they mouse out.
This is my code thusfar, the MouseLeave doesnt appear to be working.
Thanks,
Ron
class TransparentPanel : Panel
{
public TransparentPanel()
{
}
protected enum ViewState
{
Visible, Hidden
}
protected int m_CurrentState = 0;
override protected CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20;
return cp;
}
}
protected override void OnMouseEnter(EventArgs e)
{
Graphics g = this.CreateGraphics();
for (int i = 0; i <= 15; i++)
{
System.Threading.Thread.Sleep(10);
g.FillRectangle(new SolidBrush(Color.FromArgb(17,
SystemColors.Control)), this.ClientRectangle);
Application.DoEvents();
}
}
protected override void OnMouseLeave(EventArgs e)
{
Graphics g = this.CreateGraphics();
for (int i = 15; i >= 0; i--)
{
System.Threading.Thread.Sleep(10);
g.FillRectangle(new SolidBrush(Color.FromArgb(-17,
SystemColors.Control)), this.ClientRectangle);
Application.DoEvents();
}
}
}
OnMouseEnter/Leave events.
I want to fade the panel in when the user mouseovers the panel, and return
back to transparent when they mouse out.
This is my code thusfar, the MouseLeave doesnt appear to be working.
Thanks,
Ron
class TransparentPanel : Panel
{
public TransparentPanel()
{
}
protected enum ViewState
{
Visible, Hidden
}
protected int m_CurrentState = 0;
override protected CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20;
return cp;
}
}
protected override void OnMouseEnter(EventArgs e)
{
Graphics g = this.CreateGraphics();
for (int i = 0; i <= 15; i++)
{
System.Threading.Thread.Sleep(10);
g.FillRectangle(new SolidBrush(Color.FromArgb(17,
SystemColors.Control)), this.ClientRectangle);
Application.DoEvents();
}
}
protected override void OnMouseLeave(EventArgs e)
{
Graphics g = this.CreateGraphics();
for (int i = 15; i >= 0; i--)
{
System.Threading.Thread.Sleep(10);
g.FillRectangle(new SolidBrush(Color.FromArgb(-17,
SystemColors.Control)), this.ClientRectangle);
Application.DoEvents();
}
}
}