.NET PowerPacks RectangleShape在窗体调整大小时闪烁 [英] .NET PowerPacks RectangleShape flickers on form resize

查看:254
本文介绍了.NET PowerPacks RectangleShape在窗体调整大小时闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以做一些简单的事情:

I can do something as simple as:

  1. 创建一个新的.NET表单应用程序
  2. 将单个RectangleShape放置在表单上
  3. 在设计器代码中将以下内容添加到InitializeComponent方法中

  1. Create a new .NET form application
  2. Put a single RectangleShape onto the form
  3. add the following into the InitializeComponent method in the designer code

Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or _
    ControlStyles.UserPaint Or _
    ControlStyles.DoubleBuffer, True)
Me.UpdateStyles()

  • 运行程序
  • 调整表单大小
  • 愤怒地看着矩形闪烁
  • 是否有可能摆脱这种情况?还是ShapeContainer内部有缺陷,我需要找到其他解决方案吗?

    Is it possible to get rid of this? Or is the ShapeContainer internally flawed and I need to find a different solution?

    推荐答案

    它确实有缺陷.它使用自己的窗口,该窗口在WS_EX_TRANSPARENT样式已打开的情况下覆盖在窗体上.这种样式使其不可见,但也会阻止任何类型的双缓冲正常工作.双重缓冲表单无效,错误的窗口.

    It's fairly flawed. It uses its own window that's overlaid onto the form with the WS_EX_TRANSPARENT style turned on. That style makes it invisible, but also prevents any kind of double-buffering from working properly. Double-buffering the form has no effect, wrong window.

    否则,这是绘制图形的一种相当昂贵的方法.廉价且无闪烁的方法是在窗体的OnPaint()重写或Paint事件处理程序中使用e.Graphics.FillRectangle().

    It is otherwise a rather expensive way to draw shapes. The cheap and flicker-free way is using e.Graphics.FillRectangle() in the form's OnPaint() override or Paint event handler.

    这篇关于.NET PowerPacks RectangleShape在窗体调整大小时闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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