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.
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