未聚焦时 Direct2D 窗口呈黑色
我有一个 Direct2D 窗口,在聚焦时可以很好地绘制;但是,当焦点移动到另一个窗口(同一应用程序或另一个)时,整个窗口会变黑。我将问题归结为 ID2D1HwndRenderTarget::Clear 的使用。这个功能对我的应用程序至关重要,因为如果没有它,绘画就会变得相当......奇怪。
有没有一种方法可以让未聚焦的 Direct2D 窗口正常绘制(注意:像往常一样调用 WM_PAINT
,Clear
、BeginPaint
也如此)等都没有错误)
提前致谢。
I have a Direct2D window which paints fine when in focus; however, when focus moves to another window (same application or another), the entire window goes black. I pinned the issue down to the use of ID2D1HwndRenderTarget::Clear
. This function is vital to my application as without it, painting becomes rather... weird.
Is there a way an un-focused Direct2D window can paint as normal (note: WM_PAINT
is being called as usual, as is Clear
, BeginPaint
, etc. all without error)
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 MSDN,
请检查链接以获取更多信息。 http://msdn.microsoft.com/en-us /library/ff684174(VS.85).aspx
From MSDN,
Please check the link for more info. http://msdn.microsoft.com/en-us/library/ff684174(VS.85).aspx
根据我使用 DirectX 的经验,如果屏幕返回原样,是因为 DX 丢失了它正在“绘画”的设备。这种情况经常发生 - 例如 - 当在全屏 DirectX 窗口和另一个应用程序之间切换时,反之亦然。
因此,您需要做的是重新初始化 DX 设备,以便它可以恢复绘画操作。
这可能会有所帮助(不是我的网站,但快速谷歌搜索找到了它)
http://www.programmersheaven.com/2/FAQ-DIRECTX-Avoid-task-switching
With my experience with DirectX, if the screen turns back its because DX lost the device it was 'painting' to. This happens a lot - for instance - when switching between a full-screen DirectX window to another application, and vice-versa.
So what you need to do is re-intialize the DX device so it can resume painting operations.
This might help some more (not my website, but a quick Google search turned it up)
http://www.programmersheaven.com/2/FAQ-DIRECTX-Avoid-task-switching