I am trying to solve an issue in my application. I am developing the application in Vista and it works fine there, but when I take it to XP, the form becomes sluggish and unresponsive. When I watch the windows messages using breakpoints, I find that in XP the form is repeatedly painted about once every second (even though it does not really need to); however, the same test on Vista does not show this repetitive painting.
Any ideas as to what might be causing this?
Thanks for everyone's input. The problem has been solved now, with help from Subversion! The sluggishness of the window was a relatively new problem, so I decided to look back in time in my source code using Subversion and discovered that I recently applied the WS_EX_COMPOSITED style flag to the form to reduce flickering in Vista.
protected override CreateParams CreateParams
{
get
{
CreateParams result = base.CreateParams;
result.ExStyle |= 0x02000000; // WS_EX_COMPOSITED
return result;
}
}
When I commented it out, the form was responsive in XP again and the repetitive WM_PAINT messages were gone. So, the solution was to only apply WS_EX_COMPOSITED in Vista or later.
protected override CreateParams CreateParams
{
get
{
CreateParams result = base.CreateParams;
if (Environment.OSVersion.Platform == PlatformID.Win32NT
&& Environment.OSVersion.Version.Major >= 6)
{
result.ExStyle |= 0x02000000; // WS_EX_COMPOSITED
}
return result;
}
}
Now everything works great!