Click here to Skip to main content
15,887,881 members
Home / Discussions / C#
   

C#

 
AnswerRe: Framework 2.0 rendering problem Pin
Rei Miyasaka16-May-06 11:44
Rei Miyasaka16-May-06 11:44 
GeneralRe: Framework 2.0 rendering problem Pin
Phoen2518-May-06 11:22
Phoen2518-May-06 11:22 
GeneralRe: Framework 2.0 rendering problem Pin
Rei Miyasaka18-May-06 11:32
Rei Miyasaka18-May-06 11:32 
GeneralRe: Framework 2.0 rendering problem Pin
Phoen2518-May-06 11:53
Phoen2518-May-06 11:53 
GeneralRe: Framework 2.0 rendering problem Pin
Rei Miyasaka18-May-06 11:58
Rei Miyasaka18-May-06 11:58 
GeneralRe: Framework 2.0 rendering problem Pin
Phoen2518-May-06 12:37
Phoen2518-May-06 12:37 
GeneralRe: Framework 2.0 rendering problem Pin
Rei Miyasaka18-May-06 15:06
Rei Miyasaka18-May-06 15:06 
GeneralRe: Framework 2.0 rendering problem Pin
Phoen255-Jul-06 9:45
Phoen255-Jul-06 9:45 
I found the problem ...

See this link:

http://www.dotnet247.com/247reference/msgs/42/214827.aspx

Yes, that is what I found. I hadn't seen the flickering before because my
form was too small.

However, this is true. The flickering occures when the underlaying window is
switched to "layered mode". Actually it flickers even if you set alpha to
255 (fully opaque).

Switching to layered mode involves three steps.
1. Checking the os version - it has to be NT 5 or latter
2. Set WS_EX_LAYERED window style
3. SetWindowLayeredAttributes this method is not defined in user32.dll for
versions before Win2k that's why first step is necessary.

When a Windows Forms control is created it is not a layered window. And it
switches to this mode when set the opacity to some value less then 1.

So my solution is to switch to layered mode in some early stage of the form
life. As soon as the form is created before to become visible. Otherwise
we'll see the flickering.

Javier is completely correct that the layered window has to be fully
redrawn. But it goes only when the window (form) resizes. You can still
invalidate some portions of the form and it will works how ot supposed to
work.
Layered window could even show better performance in some situations.
How internaly layered windows work is all painting is redirected to
off-screen buffer and when the painting's done alpha blending is applied to
the resulting picture and the result is drawn on the screen. This of course
is done internaly in windows and it uses the video card hardware support for
alpha blending if it has any.

Becuse all winodw is double buffered Windows doesn't send WM_PAINT when the
form is moved for example or when some part of the form is uncovered. In
such cases Windows uses double buffered image.
When children control is moved on the form it updates as much as it is
necessary. So the performance hit is not so big.

Anyway, my first solution that I was planning to post involved P\Invoke and
calling all API functions necessary to switch to "layered mode", but then I
found that if one set Opacity to value less then 1 and then return it back
to 1 the form class doesn't switch to the "normal mode" and leave the window
layered.

So the easiest way to get rid if this flickering is by overriding
OnControlCreated method and adding the following two lines:

this.Opacity = 0.9;
this.Opacity = 1;

No more flickering .

Thanks a lot people !!!
GeneralRe: Framework 2.0 rendering problem Pin
Rei Miyasaka5-Jul-06 9:53
Rei Miyasaka5-Jul-06 9:53 
AnswerRe: Framework 2.0 rendering problem Pin
Nader Elshehabi16-May-06 11:52
Nader Elshehabi16-May-06 11:52 
QuestionListview 2.0 - SelectedIndexChanged Event Pin
Doncp16-May-06 10:40
Doncp16-May-06 10:40 
AnswerRe: Listview 2.0 - SelectedIndexChanged Event Pin
Rei Miyasaka16-May-06 11:38
Rei Miyasaka16-May-06 11:38 
Questionbringing the form on top Pin
Rizwan Rathore16-May-06 10:37
Rizwan Rathore16-May-06 10:37 
AnswerRe: bringing the form on top Pin
Rei Miyasaka16-May-06 11:03
Rei Miyasaka16-May-06 11:03 
GeneralRe: bringing the form on top Pin
Rizwan Rathore16-May-06 11:27
Rizwan Rathore16-May-06 11:27 
GeneralRe: bringing the form on top Pin
Rei Miyasaka16-May-06 11:32
Rei Miyasaka16-May-06 11:32 
GeneralRe: bringing the form on top Pin
Rizwan Rathore16-May-06 11:35
Rizwan Rathore16-May-06 11:35 
GeneralRe: bringing the form on top Pin
Rei Miyasaka16-May-06 11:41
Rei Miyasaka16-May-06 11:41 
GeneralRe: bringing the form on top Pin
Rizwan Rathore16-May-06 11:53
Rizwan Rathore16-May-06 11:53 
QuestionDATA GRID in C# window application Pin
Faisal Khatri16-May-06 10:27
Faisal Khatri16-May-06 10:27 
AnswerRe: DATA GRID in C# window application Pin
Josh Smith16-May-06 10:59
Josh Smith16-May-06 10:59 
AnswerRe: DATA GRID in C# window application Pin
coolvinx16-May-06 11:11
coolvinx16-May-06 11:11 
Questionpdb file Pin
mehrdadc4816-May-06 10:03
mehrdadc4816-May-06 10:03 
AnswerRe: pdb file Pin
Michael P Butler16-May-06 10:17
Michael P Butler16-May-06 10:17 
Questionmulticast problem Pin
snouto16-May-06 9:38
snouto16-May-06 9:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.