在FlowLayoutPanel的滚动,背景扭曲+闪烁 [英] During FlowLayoutPanel scrolling, background distorts + flickers

查看:1879
本文介绍了在FlowLayoutPanel的滚动,背景扭曲+闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有背景的Windows窗体应用程序。在这,我有一个透明背景FlowLayoutPanel的。当我滚动,会发生以下情况:

I have a windows form application that has a background. Within it, I have a flowlayoutpanel with a transparent background. When I scroll, the following happens:

我也看到一些闪烁。我已经尝试了所有的doublebuffered业务,这是行不通的。

I also see some flickering. I've tried all the doublebuffered business, and it doesn't work.

有什么建议?

推荐答案

是啊,这是行不通的。下面是提高它有点类:

Yeah, that doesn't work. Here's a class that improves it somewhat:

using System;
using System.Windows.Forms;

class MyFlowLayoutPanel : FlowLayoutPanel {
    public MyFlowLayoutPanel() {
        this.DoubleBuffered = true;
    }
    protected override void OnScroll(ScrollEventArgs se) {
        this.Invalidate();
        base.OnScroll(se);
    }
}



编译并从工具箱的顶部上砸你的表单。据拖动时显示窗口内容选项但无法修复的根本问题,。这是一个系统选项,它会为更高版本的Windows打开。当它是上,视窗itselfs卷轴面板的内容,然后要求该应用绘制被揭示的涡旋部件。所述OnScroll方法将覆盖,以确保整个窗口重新绘制以保持背景图像中的位置。最终的结果是不漂亮,你会看到的图像做POGO,上窜下跳,同时滚动。

Compile and drop it from the top of the toolbox onto your form. It however cannot fix the fundamental problem, the "Show window content while dragging" option. That's a system option, it will be turned on for later versions of Windows. When it is on, Windows itselfs scrolls the content of the panel, then asks the app to draw the part that was revealed by the scroll. The OnScroll method overrides that, ensuring that the entire window is repainted to keep the background image in place. The end-result is not pretty, you'll see the image doing the "pogo", jumping up and down while scrolling.

这个唯一的解决方法是打开系统选项关闭。这不是一个实用的修复,用户喜欢的选择,它影响到每一个程序,不只是你的。如果你不能用POGO生活,那么你就必须放弃对透明度。

The only fix for this is turning the system option off. That's not a practical fix, users like the option and it affects every program, not just yours. If you can't live with the pogo then you'll have to give up on the transparency.

这篇关于在FlowLayoutPanel的滚动,背景扭曲+闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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