
Signature
--
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.
So how do I disable the OnPaintBackground? I tried overriding
OnPaintBackground but it never gets called. I tried setting window styles to
UserPaint and AllPaintingInWMPaint, but that didn't make either OnPaint or
OnPaintBackground get called.
Could this be related to layered windows? I read something about the .NET
transition to a layered window has an error that causes flicker. The
workaround was to set a transparent key color, which forces .NET to layer the
window. This solved the flicker problem, BUT it made the window insanely
slow to transition, esepcially when maximized.

Signature
Brian R.
> For almost any reasonably intellient paint scheme one should disable the
> OnPaintBackground.
[quoted text clipped - 35 lines]
> > Any thougths would be helpful. I am sure I am missing some vital step
> > here.
Linda Liu [MSFT] - 08 Jun 2007 07:58 GMT
Hi Brian,
It would be better for me to look into this issue if you could send me a
simple project that could just reproduce the problem.
To get my actual email address, remove 'online' from my displayed email
address.
Thank you for your understanding and cooperation!
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Bob Powell [MVP] - 08 Jun 2007 09:26 GMT
Are you directly using the LayeredWindow API?

Signature
--
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.
> So how do I disable the OnPaintBackground? I tried overriding
> OnPaintBackground but it never gets called. I tried setting window styles
[quoted text clipped - 55 lines]
>> > Any thougths would be helpful. I am sure I am missing some vital step
>> > here.
Brian R. - 08 Jun 2007 14:41 GMT
No. All I did was set the .NET Windows Form property: TransparencyKey. That
got rid of the flicker but made the window fade SO Much slower. The article
I read stated that this property, when set, forces System.Windows.Forms to
layer the window.
See the last section from this code project article that addresses opacity
and layered windows.
http://www.codeproject.com/csharp/notanotherformfader.asp

Signature
Brian R.
> Are you directly using the LayeredWindow API?
>
[quoted text clipped - 57 lines]
> >> > Any thougths would be helpful. I am sure I am missing some vital step
> >> > here.
Linda Liu [MSFT] - 13 Jun 2007 05:00 GMT
Hi Brian,
Thank you for your sample project.
I run it on my machine and see the TransitionForm flashes when it is
closed. I have a try setting the TransparencyKey property of the
TransitionForm to Lime, and see that the flicker is eliminated.
But I don't see the transition becomes slower after I set the
TransitionForm's TransparencyKey property.
I think a simple workaround to this slow transition problem is to decrease
the transition range of the Opacity, e.g. from 0.5 to 1 and then from 1 to
0.5. To do this, you can set the TransitionForm's Opacity property to 0.5
in the designer and modify one line of code in the FadeInTimerElapsed
method as follows:
// modify the original line of code
if (Opacity <= 0.0)
// to the code below
if (Opacity <=0.5)
Hope this helps.
If you have any concern, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support