transparent controls issue
From: ds (dave_at_petcominc.com)
Date: 04/20/04
- Next message: Colin Young: "Re: Form close ('X' button) not working"
- Previous message: Mark: "Re: Multiple Hyperlinks"
- Next in thread: Bob Powell [MVP]: "Re: transparent controls issue"
- Reply: Bob Powell [MVP]: "Re: transparent controls issue"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 20 Apr 2004 12:36:10 -0500
have 2 layers of related graphics that I want to display. The bottom layer
is relatively expensive to render and stays static. The top layer displays
some user-orchestrated animation, directed via the mouse- similar to a
drag-and-drop operation.
I've tried laying one control over the other. The top control is
transparent. When I call Invalidate() in the TopControl, BottomControl
repaints also. Basically, I'm hoping there is a way to continually update
the top layer without having to redraw the bottom layer.
Any suggestions would be appreciated.
public class TopControl : UserControl
TopControl()
{
SetStyle(ControlStyles.SupportsTranparentBackColor,true);
BackColor = Color.Transparent;
}
protected override void OnPaint(PaintEventArgs e)
{
Console.WriteLine("top paint");
// some drawing code
}
protected override void OnMouseUp(MouseEventArgs e)
{
// collect some rendering data...
Invalidate();
}
}
public class BottomControl : UserControl
{
BottomControl()
{
}
protected override OnPaint(PaintEventArgs e)
{
Console.WriteLine("bottom paint");
// expensive drawing code
}
}
Main()
{
...
Form f = new Form();
f.ResizeRedraw = true;
BottomControl bc = new BottomControl();
bc.Dock = DockStyle.Fill;
bc.Parent = this;
TopControl tc = new TopControl();
tc.Dock = DockStyle.Fill;
tc.Parent = bc;
f.Show();
...
}
- Next message: Colin Young: "Re: Form close ('X' button) not working"
- Previous message: Mark: "Re: Multiple Hyperlinks"
- Next in thread: Bob Powell [MVP]: "Re: transparent controls issue"
- Reply: Bob Powell [MVP]: "Re: transparent controls issue"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|