闪烁免费文本框 [英] Flicker free TextBox

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

问题描述

我有我的窗体上一个简单的WinForms多行文本框。每当我调整或将其内容开始闪烁疯狂的文本框。这看起来很恶心,甚至可能会引起癫痫发作的一些用户; - )

I have a simple Winforms multiline TextBox on my Form. Whenever I resize or move the TextBox its content starts to flicker madly. That looks very disgusting and might even cause epileptic seizure for some users ;-)

有没有一种方法来操纵文本框的重新划分过程中摆脱闪烁?

Is there a way to manipulate the redrawing process of the TextBox to get rid of the flickering?

推荐答案

我已经找到了<一href="https://social.msdn.microsoft.com/Forums/en-US/aaed00ce-4bc9-424e-8c05-c30213171c2c/flickerfree-painting"相对=nofollow>工作液上写的汉斯帕桑特 MSDN论坛。下面code可被添加到形式,将适用于所有子控件,太:

I've found a working solution on the MSDN forums written by Hans Passant. The following code can be added to the form and will work for all child controls, too:

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

这篇关于闪烁免费文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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