1

I have a winforms application in which I have used many Custom Controls like buttons, panels and tabs. And the panels will be used almost for every layout in the Application. Now i have added the following DoubleBuffer in the constructor of the panel.

public partial class MainPanel : Panel
{
    public MainPanel()
    {
        //ControlStyle is enum of system.windows.forms
        SetStyle(ControlStyles.UserPaint, true);
        SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        SetStyle(ControlStyles.DoubleBuffer, true);
        SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
    }
}

Also after creating the application I had lots of flickering issues, ie when ever I tried to run the application, due to 'n' number of panels my application flickered a lot. So googled a lot and found few solution among which the following one worked out for me

protected override CreateParams CreateParams
{
    get
    {
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x02000000;  // Turn on WS_EX_COMPOSITED
        return cp;
    }
}

using the above code reduced my flickering issues, however it takes a fraction of second to show the form(as the logic of the code is to wait untill all the controls are painted) Im completely ok with the delay(which is hardly few microseconds).

My application works on Windows 7(all versions), Windows 8, Windows 8.1 but when it comes to Windows XP(SP 2 but didnt try other versions) the application runs, but frequently hangs. However there is no crash of the application. But the application freezes a lot in XP. The framework version I'm using is .Net 3.5 and I'm installing .Net 3.5 framework on the machine when the application installs(using NSIS).

The application I have compiled for x86 so that it can run on any bit machine. As far as I know I have covered every possible thing. But still I'm facing this issue. Is there something obvious that I'm missing?

Is there any issue with my Application regarding XP??

PS: Eventhough Microsoft has terminated support for Windows XP I still have to launch the application for XP users.

Thanks in Advance

Vikneshwar
  • 1,029
  • 4
  • 20
  • 38
  • Have you tried debugging on WinXP? Have you tried looking at process dumps taken when hung? – Richard May 07 '14 at 10:14
  • Profile your application under XP and see what is the problem. – Sriram Sakthivel May 07 '14 at 10:14
  • I know about issue with `WS_EX_COMPOSITED` on XP from own experience. I don't remember if there was freezes or just buggy UI (artifacts), but you should definitely check os version and disable that flag for XP. – Sinatr May 07 '14 at 10:20
  • @Richard the Windows XP machine is an altogether different machine. So far I havent looked for process dumps. There are times when my application runs, but then again im not able to click on any button. – Vikneshwar May 07 '14 at 10:31
  • @SriramSakthivel Im not sure what you are suggesting by 'Profiling application under XP' can you please elaborate? Any referral links would be useful. – Vikneshwar May 07 '14 at 10:35
  • I mean to use a "performance profiler" There are paid tools. Visual studio has one. Check [this](msdn.microsoft.com/en-us/magazine/cc337887.aspx) and [this](http://msdn.microsoft.com/en-us/library/ms182398.aspx). And SO [discussion here](http://stackoverflow.com/questions/10644/any-decent-c-sharp-profilers-out-there) – Sriram Sakthivel May 07 '14 at 10:40
  • @SriramSakthivel thanks for the link ill have a look into it maybe it will be useful. But still I'm not sure that after profiling what I would have to do. Anyway as of now first let me have a look into profiling. – Vikneshwar May 07 '14 at 11:02
  • 1
    Pretty unlikely that it is caused by WS_EX_COMPOSITED. Far more likely that it is caused by inappropriately firehosing the UI thread with Control.Begin/Invoke calls. That easily freezes the UI on a slow machine, the kind that has XP installed. – Hans Passant May 07 '14 at 11:24

0 Answers0