通过关闭WS_CLIPCHILDREN减少闪烁 [英] Reduce flickering By Turning off WS_CLIPCHILDREN

查看:120
本文介绍了通过关闭WS_CLIPCHILDREN减少闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个Windows应用程序,该应用程序的界面有多个文本框,所有文本框都放置在一个面板中(该面板具有背景图像).

I have developed a windows application whose interface has a multiple text boxes and all of them are placed in one panel (the panel have a background image).

每次加载面板时,带有这些文本框的窗口都会闪烁.

Whenever the panel is being loaded, the window(with these textboxes) is flickering.

我阅读了很多建议以最大程度地减少这种闪烁, 以下是建议的解决方案之一,

I read a lot of suggestions to minimize this flickering, One of the suggested solutions was the following,

SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); 
SetStyle(ControlStyles.DoubleBuffer, true);

但这对我不起作用

我读到有关使用以下代码关闭WS_CLIPCHILDREN的信息:

I read about turning off the WS_CLIPCHILDREN using this code:

protected override CreateParams CreateParams {
  get {
    var parms = base.CreateParams;
    parms.Style &= ~0x02000000;  // Turn off WS_CLIPCHILDREN
    return parms;
  }
}

此代码可帮助遇到相同问题的某些人.因此,我想使用它,但我真的不知道将其粘贴到哪里,我的意思是,我读到它应该粘贴在 UserControl的代码中,而不是粘贴在表单中.我不知道该怎么做,我使用的所有控件都不是自定义控件.

This code help some people who faced the same problem. So I want to use it but I really don't know where to paste it, I mean, I read that it should be pasted not in the form, but in the the UserControl's code. I don't know how to do that, all the controls that i used is not a custom controls.

在这里&看到第一个答案:

Take a look here & see the 1st answer:

如何解决用户控件中的闪烁

预先感谢

推荐答案

您也可以考虑打开WS_EX_COMPOSITED样式,在某些情况下可能会有所帮助:

You might consider turning on WS_EX_COMPOSITED style also, it may help in some cases:

parms.ExStyle |= 0x02000000; //WS_EX_COMPOSITED

这篇关于通过关闭WS_CLIPCHILDREN减少闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆