Hi. I have a winform (with fade-in and fade-out effect) and I run it on VS 2003 and works great. But when I use VS 2005, the winform appears like with flicks, it's like it had a rendering problem. The example works great with VS 2003, but I have to run in in VS 2005.
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
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
So the easiest way to get rid if this flickering is by overriding
OnControlCreated method and adding the following two lines:
how can i change this property through coding coz it is not visible there suppose if the name of the form is form1 then form1.TopMost is not available so how can i change it ??
looking forward for help
I have a datagrid in windows applicaiton ..I have a data table in database whicha have around 5 columns..& now i want to show 3 columns only from that table to this datagrid..
I have been working in wwebapplicaiton. Its easy in webs application to do this. but i m confused how to do this in windows datagrid form..
In otherwords i must say that is there any way to handle the datagrid as we do in webapplication..
One way would be to populate the DataTable with only the 3 columns you want from the database and then set the datasource property to it. i.e. Use a SQL query to retreive from the database only the information you want to fill the datatable with.
Last Visit: 31-Dec-99 19:00 Last Update: 29-Feb-24 15:25