使用 WindowsFormsHost 时 WPF 并不总是重绘

发布于 2024-08-27 22:57:15 字数 690 浏览 6 评论 0原文

我有一个简单的应用程序,它使用 WindowsFormsHost 托管托管 DirectX Control。我已经重写了 Control 中的绘制方法以防止闪烁:

protected override void OnPaint(PaintEventArgs e)
{
    if (this.Visible == true) { base.OnPaint(e); }
}

// Don't paint the background unless the control is not visible
protected override void OnPaintBackground(PaintEventArgs e)
{
    if (this.Visible == false) { base.OnPaintBackground(e); }
}

有一个计时器会定期使 Managed DirectX Control 失效,以便重新绘制它。

我的问题是,当我锁定计算机 (WIN+L),然后解锁它时,WindowsFormsHost 周围的 WPF 内容有时不会完全绘制。直到我将窗口完全拖出视图后,才会绘制它的各个部分。关于为什么 WPF 没有完成自身重绘的任何想法?

抱歉,如果这太模糊而无法解决问题,我无法分享更多源代码。

I have a simple application which is hosting a Managed DirectX Control using WindowsFormsHost. I've overridden the paint methods in the Control to prevent flicker:

protected override void OnPaint(PaintEventArgs e)
{
    if (this.Visible == true) { base.OnPaint(e); }
}

// Don't paint the background unless the control is not visible
protected override void OnPaintBackground(PaintEventArgs e)
{
    if (this.Visible == false) { base.OnPaintBackground(e); }
}

There is a timer which periodically invalidates the Managed DirectX Control so that it will be redrawn.

My problem is that when I lock the computer (WIN+L), and then unlock it, the WPF content around the WindowsFormsHost occasionally does not get fully painted. Various portions of it are not drawn until I drag the window completely out of view. Any ideas on why WPF doesn't finish repainting itself?

Apologies if this is too vague to solve the issue, I'm unable to share more source code.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文