如何为通过远程桌面运行的应用程序获得流畅、无闪烁的 GUI?

发布于 2024-08-24 21:14:17 字数 1133 浏览 8 评论 0原文

我意识到互联网上存在大量关于减少 Windows 窗体应用程序中的闪烁的问题。经过大量实验,我发现针对我的特定情况的解决方案非常简单:将出现闪烁的控件的 Control.DoubleBuffered 属性设置为 true。我通过简单地从必要的控件类(在我的例子中,从 ListViewDoubleBufferedListView 以及从 DataGridViewDoubleBufferedDataGridView< /代码>)。

我正在开发的应用程序中的罪魁祸首是 DataGridView,它在 Windows.Forms.TimerTick 事件上更新其许多单元格> 对象。在启用双缓冲之前,网格在大多数更新中都会轻微闪烁(不是太糟糕,但足以引人注目)。 启用双缓冲后,闪烁消失了。

不过,我在这里谈论的是我的开发机器。不幸的是,这个应用程序实际上是由最终用户通过远程桌面连接运行的,这是我从 Raymond Chen 的这篇博文意味着我不应该使用双缓冲。

那么我的问题是:我应该使用什么? Chen 建议在本地计算机上的双缓冲方法和远程桌面连接上的传统非双缓冲方法之间进行切换;但在这种情况下,该应用程序的最终用户仍然会遇到闪烁。这是不可避免的吗?

郑重声明:这不是调用 BeginUpdate/EndUpdate 这么简单(已经在 ListBox 上这样做了,并且ListView 控件)或 SuspendLayout/ResumeLayout (已经对 DataGridView 控件执行此操作,尽管我不这样做我不认为这特别重要,因为正如我所说,我只是更新某些单元格中的值)。

也许无闪烁的远程桌面应用程序根本不可能?

I realize there are a ton of questions floating around the internet about reducing flicker in Windows Forms applications. After copious experimentation, I found that the solution in my particular case was quite straightforward: setting the Control.DoubleBuffered property to true for the controls that were exhibiting flicker. I accomplished this by simply deriving from the necessary control classes (in my case, from ListView to DoubleBufferedListView and from DataGridView to DoubleBufferedDataGridView).

The primary culprit in the app I am working on is a DataGridView which updates many of its cells on the Tick event of a Windows.Forms.Timer object. Before enabling double buffering, the grid would flicker slightly (not too bad, but enough to be noticeable) on most updates. After enabling double buffering, the flicker went away.

However, I'm talking about my development machine here. Unfortunately, this app is actually run by end users via a Remote Desktop connection, which I learned from this blog post by Raymond Chen means I should not use double buffering.

My question, then, is: what should I use? Chen suggests switching between a double buffered approach on local machines and the traditional non-double buffered approach on remote desktop connections; but in that case the end users of this app will still experience the flicker. Is this simply unavoidable?

For the record: this is not a simple matter of calling BeginUpdate/EndUpdate (already doing that on ListBox and ListView controls) or SuspendLayout/ResumeLayout (already doing that for the DataGridView control as well, although I don't think that's even particularly important since, as I said, I'm just updating the values in certain cells).

Maybe a flicker-free remote desktop app is simply impossible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

林空鹿饮溪 2024-08-31 21:14:17

在“值得一试”类别中:在控件上设置标志 AllPaintingInWmPaint,或按照此处的建议重写 OnPaintBackground:http://alt.pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html

这将有助于使背景绘画更接近是时候进行前景绘制了。这将提高它们从客户端同时发送到服务器的机会。

In the category "worth a try": Set the flag AllPaintingInWmPaint on the control, or override OnPaintBackground as suggested here: http://alt.pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html

This would help to get the background paint closer in time to foreground paint. This will improve that chance that they will be sent simultaneously from client to server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文