如何消除mdi形式C#中的闪烁 [英] How do I eliminate flickering in mdi form C#
问题描述
我正在使用wiforms。我有一个mdi形式。我的问题是,当我将背景图像设置为我的mdi时,它会产生一些问题。弹出消息框时闪烁。当我加载新的儿童表格时(有时候不是每次)它都会闪烁。
i在这里看到很多解决方案,但没有什么对我有用请帮帮我
我尝试了什么:
i尝试过
1)dubblebuffer = true;
2)
const int WM_NCPAINT = 0x85;
const int WM_SIZE = 0x05;
protected override void WndProc(ref message m)
{
if(m.Msg == WM_NCPAINT)
{
if(this.WindowState == FormWindowState.Maximized)
return;
}
if( m.Msg == WM_SIZE)
{
if(this.WindowState == FormWindowState.Maximized)
return;
}
base.WndProc(ref m);
}
3)
//避免闪烁
//保护覆盖CreateParams CreateParams
// {
// get
// {
// CreateParams handleParam = base .CreateParams;
// handleParam.ExStyle | = 0x02000000; // WS_EX_COMPOSITED
//返回handleParam;
//}
//}
4)在mdi load中写下面的代码
this.SetStyle(ControlStyles.UserPaint,true);
您是否尝试过在构造函数中设置窗口样式?
InitializeControl();
SetStyle(ControlStyles.OptimizedDoubleBuffer, true );
< blockquote>我得到了解决方案。我在构造函数中的代码下插入了它并且工作正常
感谢您的支持
foreach (控制ctl this .Controls)
{ // 查找MDI客户端窗口
if (ctl MdiClient)
{
// Hackorama避免闪烁:
var dblBuf = ctl.GetType()。GetProperty( DoubleBuffered,BindingFlags .NonPublic | BindingFlags.Instance);
dblBuf.SetValue(ctl, true , null );
break ;
}
}
im working with wiforms. i have a mdi form. my problem is that when i set a background image to my mdi it makes some problems. it flickering while a messagebox is popup. and also it flicker sometimes when i loading new child form( not every time).
i saw many solution here but nothing works for me please help me
What I have tried:
i tried
1)dubblebuffer=true;
2)
const int WM_NCPAINT = 0x85;
const int WM_SIZE = 0x05;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCPAINT)
{
if (this.WindowState == FormWindowState.Maximized)
return;
}
if (m.Msg == WM_SIZE)
{
if (this.WindowState == FormWindowState.Maximized)
return;
}
base.WndProc(ref m);
}
3)
//for avoid flickering
//protected override CreateParams CreateParams
//{
// get
// {
// CreateParams handleParam = base.CreateParams;
// handleParam.ExStyle |= 0x02000000; // WS_EX_COMPOSITED
// return handleParam;
// }
//}
4)wrote below code in mdi load
this.SetStyle(ControlStyles.UserPaint, true);
Have you tried setting the window style in the constructor?
InitializeControl(); SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
i got solution.i inserted below code in constructor and its worked fine
thanks for your support
foreach (Control ctl in this.Controls) { // Find the MDI client window if (ctl is MdiClient) { // Hackorama to avoid flicker: var dblBuf = ctl.GetType().GetProperty("DoubleBuffered", BindingFlags.NonPublic | BindingFlags.Instance); dblBuf.SetValue(ctl, true, null); break; } }
这篇关于如何消除mdi形式C#中的闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!