我有一个 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/