Custom windows form border, TransparencyKey Flicker

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I've got a question regarding a small amount of flicker I am seeing when
a form is first drawn that has a transparent background.

I have a custom panel that I'm drawing myself which takes up all of the
client area of a form (rounded corners, gradients etc).

I have set the background color and the transparencykey of the container
form to the same values.

Everything draws and looks great however right before the form is displayed
I see a black flicker or flash right before the form is rendered. It's a
really really quick flash.

Is there anyway to get around this? I've tried just a blank form and
setting the transparency key and the backcolor to the same values with the
same result.

thanks,
bp
 
The transparency key of the form will have no bearing on the problem.

Are you trying to double-buffer the control? This might be a bad idea. See
Windows Forms Tips and Tricks for transparent control info.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Thanks for getting back with me Bob,
Said control is double buffered. However, the problem is not with the
control it's with the form. Test case:
Create a default windows form,
Change the size of the form to something really large (800x600)
Set backcolor and transparency key of the form to the same color (gainesburo).
Add a panel with a label and some text (change the backcolor of the panel to
yellow or something) and make it take up 50% of the form
Set formborder style to none
Show the form.

I get a flash right before it's rendered.

thanks,
-bp

Show the form.

This will cause a small flash to occur right before the form is rendered.
Any ideas?

-bp
 
I'm not surprised. The form is trying to be transparent when the control has
no notion of how to draw itself transparently clears the screen area with
it's OnPaintBackground implementation.

I think that the only way you'll get any sense out of what I think you want
to do is to implement the layered window API on your main window and custom
paint the content.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Thanks Bob,
At least you pointed me in the right direction. I was able to minimize the
flicker by doing the following:

I manually implemented the layered window API as you suggested within the
load event of the chromeless form. I wrapped the win32 layered API calls
within a FreezePainting (Google) API call as well. This appears to really
minimize the flash I was seeing. It's there to the trained eye but I'm sure
most people will not even notice.


thanks again,
-brett
 
Back
Top