transparent controls issue

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: ds (dave_at_petcominc.com)
Date: 04/20/04


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();
...
}



Relevant Pages

  • Re: [PATCH 18/41] union-mount: Documentation
    ... +The main analogy for writable overlays is that a writable file system ... +Top layer: The read-write file system. ... +Bottom layer: The read-only file system. ... which supported whiteouts and opaque dirs natively in lower file systems. ...
    (Linux-Kernel)
  • Re: [PATCH 17/39] union-mount: Union mounts documentation
    ... +and contents as the file with the same pathname on the bottom layer. ... +doing the copyup before the file is opened. ... +NFS is currently not supported as either type of layer. ...
    (Linux-Kernel)
  • transparent control issue
    ... is relatively expensive to render and stays static. ... The top layer displays ... the top layer without having to redraw the bottom layer. ... protected override void OnMouseUp ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Question on reinforcement in concrete
    ... Total time to pour the slab was approximately. ... Bottom layer reinforcement is 4 inch above the soffit. ...
    (sci.engr.civil)
  • transparent controls issue
    ... is relatively expensive to render and stays static. ... The top layer displays ... the top layer without having to redraw the bottom layer. ... protected override void OnMouseUp ...
    (microsoft.public.dotnet.framework.drawing)