.NET PowerPacks RectangleShape在窗体调整大小时闪烁 [英] .NET PowerPacks RectangleShape flickers on form resize
问题描述
我可以做一些简单的事情:
I can do something as simple as:
- 创建一个新的.NET表单应用程序
- 将单个RectangleShape放置在表单上
-
在设计器代码中将以下内容添加到InitializeComponent方法中
- Create a new .NET form application
- Put a single RectangleShape onto the form
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屋!