none
TableLayout painting slowly when used ExStyle |= UnsafeNativeMethods.WS_EX_COMPOSITED RRS feed

  • Question

  • Hi,

     We are using Ribbon Control(WPF) integrated with element host over TableLayoutPanel.But the paint is slow when hovering over ribbon controls. if we remove ExStyle |= UnsafeNativeMethods.WS_EX_COMPOSITED in TableLayoucontrol hovering is working fine without any performance lag.but by removing it we are getting flickering issue on resizing or button clicks.

       Please respond as early as possible.

    • Moved by Stanly Fan Thursday, May 18, 2017 3:17 AM from windows form designer
    • Moved by Bob Ding Thursday, June 8, 2017 5:17 AM
    Wednesday, May 17, 2017 12:34 PM

All replies

  • Hi vamshi_1402,

    According to your description, your issue is more related about WPF. I will move this thread to WPF forum. You will get a more professional support from there, thank you for your understanding.

    Best Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 18, 2017 3:14 AM
  • Hi,

    As far as I know,  ExStyle |= UnsafeNativeMethods.WS_EX_COMPOSITED is way to get rid of flickering for WinForm control. WS_EX_COMPOSITED  works by forcing child windows to draw back to front and by double buffering them;

    You can try to use the methods in below thread to get rid of flickering .

    If there are a lot of controls in TableLayoutPanel, try to add controls between spendLayout method and ResumeLayout method. And I recommend not placing too many controls on the TableLayoutPanel.

    SuspendLayout();
    
    ResumeLayout();

    You can also try to custom the TableLayoutPanel, and set DoubleBuffer in Constructor as below.

     this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.CacheText, true);

    Below method actually is same ExStyle |= safeNativeMethods.WS_EX_COMPOSITED .

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

    http://stackoverflow.com/questions/6677533/how-to-avoid-flickering-in-tablelayoutpanel-in-c-net

    And I think host WinForm control in WPF is not the good choice. WPF Grid maybe is a good alternative.

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    • Edited by Bob Ding Thursday, May 18, 2017 7:20 AM
    Thursday, May 18, 2017 7:17 AM
  • Hi Stanly,

      As is mentioned in my previous post problem seems to be with TableLayoutPanel.If i use FlowLayoutPanel(winform) instead of TableLayoutPanel(Winform) ribbon control is working fine without any delay on mousehoverig .It is only when i use TableLayoutPanel with 

    WS_EX_COMPOSITED style i'm getting this issue. 

     public class EWTableLayoutPanel : TableLayoutPanel
        {

            protected override void OnCreateControl()
            {
                base.OnCreateControl();
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.CacheText, true);          
            }

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

    }

    Is there any other style i can use which solves both flickering and mouse over issues.

    Thanks in advance.

    Regards,

    Vamsi

    Thursday, May 18, 2017 9:08 AM
  • Hi,

    >> Is there any other style i can use which solves both flickering and mouse over issues.

    The flickering can not be fixed quickly, If you have a WPF application, I am not recommend you host winform control, especially the layout controls. Too many controls painting on the layout control always encounter flickering trouble.

    I don't know why you host TableLayout in WPF, WPF have many Layout controls you can make a choice.

    Best regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 23, 2017 9:09 AM