gpt4 book ai didi

c++ - 未聚焦时 Direct2D 窗口变黑

转载 作者:可可西里 更新时间:2023-11-01 10:09:50 26 4
gpt4 key购买 nike

我有一个 Direct2D 窗口,它在聚焦时画得很好;然而,当焦点移动到另一个窗口(同一个应用程序或另一个)时,整个窗口变黑。我将问题归结为 ID2D1HwndRenderTarget::Clear 的使用。此功能对我的应用程序至关重要,因为没有它,绘画会变得相当……奇怪。

有没有一种方法可以让未聚焦的 Direct2D 窗口正常绘制(注意:WM_PAINT 会像往常一样被调用,Clear 也是如此,BeginPaint等都没有错误)

提前致谢。

最佳答案

来自 MSDN,

Handling Device Loss

While your program is running, the graphics device that you are using might become unavailable. For example, the device can be lost if the display resolution changes, or if the user removes the display adapter. If the device is lost, the render target also becomes invalid, along with any device-dependent resources that were associated with the device. Direct2D signals a lost device by returning the error code D2DERR_RECREATE_TARGET from the EndDraw method. If you receive this error code, you must re-create the render target and all device-dependent resources.

请检查链接以获取更多信息。 http://msdn.microsoft.com/en-us/library/ff684174(VS.85).aspx

关于c++ - 未聚焦时 Direct2D 窗口变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2608283/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com