Direct2D window is black if out of focus
I have a Direct2D window that displays nicely in focus; however, when the focus is moved to another window (the same application or a different one), the entire window turns black. I have attached the issue prior to use ID2D1HwndRenderTarget::Clear
. This feature is vital to my application, as without it the picture becomes rather ... weird.
Is there a way that an unfocused Direct2D window can draw as normal (note: WM_PAINT
called as usual, like and Clear
, BeginPaint
etc. all without error)
Thanks in advance.
source to share
In my experience with DirectX, if the screen turns back because the DX lost the device, he was "drawing". This happens very often - for example, when switching between a full screen DirectX window to another application and vice versa.
So, you need to reinitialize the DX device so that it can resume drawing operations.
This might help a little more (not my site, but a quick google search included it)
http://www.programmersheaven.com/2/FAQ-DIRECTX-Avoid-task-switching
source to share
From MSDN,
Handling Device Loss
While your program is running, the graphics device you are using may become unavailable. For example, the device may be lost if the display changes its resolution, or if the user removes the display adapter. If a device is lost, the render target also becomes invalid, as well as the device-specific resources that were associated with the device. Direct2D signals a lost device by returning the D2DERR_RECREATE_TARGET error code with the EndDraw method. If you receive this error code, you must re-create the render target and all device dependent resources.
Please check the link for more information. http://msdn.microsoft.com/en-us/library/ff684174(VS.85).aspx
source to share