Hi,
I'm creating some controls that basically draw shapes with/without text
inside/outside etc, pretty customizeable shapes including square,
circle, star...
I'm having a problem when their anchors are set so they resize with the
parent control, they're flickering like mad and I cant seem to get them
to double buffer and resize nicely...
To get transperency to work correctly I've had to use:
protected override CreateParams CreateParams
{
[SecurityPermission(SecurityAction.Assert, UnmanagedCode = true)]
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT
return cp;
}
}
Inside my constructor:
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.UserPaint, true);
I've overridden OnPaintBackground so that it doesn't call
base.OnPaintBackground
I'm also using a backbuffer image so it only blits at the end of the
painting method, but it's still flickering like mad on resize, and the
painting isn't that complex, especially for the circle and square
shapes, FillRect, DrawRect, DrawString, thats about it
Anyone have any tips?
Most of my transperency code has come from
http://www.bobpowell.net/transcontrols.htm and a few other sites with
similar content, it's been a royal pain in the behind trying to get
such a simple thing as circles and stars to be drawn nicely on top of
forms with background images and such
thanks,
Kris Wragg
|