本文介绍了如何在C#windowsforms窗体应用程序停止闪烁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有主面板和自动滚动= true,所有控件都放在主面板上。功能工作正常,但当我点击任何控件或向下或向上滚动,所以每次点击或滚动开始闪烁一次

I have main Panel and Auto Scroll=true, and all controls are placed on main panel. Functionality works fine but when I click on any control or scroll down or up so it start flickering for a second each time I click or Scroll,

我也设置了

 DoubleBuffered = true; 

但不适用于我。

可以任何身体请建议我的解决方案或新的代码,这可以帮助我我alrasy花了2天这个问题。
。提前感谢。

could any body please suggest me solution or new code which can help me I alrasy spent 2 days on this problem.thanks in advance.

推荐答案

您可以尝试将其放入您的表单类:

You can try to put this into your forms class:

private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;

protected override void WndProc (ref Message m)
{
    if ((m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL)
        && (((int)m.WParam & 0xFFFF) == 5))
    {
        // Change SB_THUMBTRACK to SB_THUMBPOSITION
        m.WParam = (IntPtr)(((int)m.WParam & ~0xFFFF) | 4);
    }
    base.WndProc (ref m);
}

您也可以将其添加到您的表单类构造函数:

You could also add this to your forms class constructor:

SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

Im使用windows 8,我不会从面板得到闪烁AutoScroll =但上述方法应该可以解决闪烁。

Im using windows 8, and i dont get flicker from a panel with AutoScroll=true. but the above methods should solve the flicker.

这篇关于如何在C#windowsforms窗体应用程序停止闪烁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 08:01