0

I am using Visual Studio 2017 and I have created an MFC SDI Application with Direct2D for drawing. So I am listening to

ON_REGISTERED_MESSAGE(AFX_WM_DRAW2D, &CIGUIDEView::OnDraw2d)

messages for painting into the client area of the application. It all works fine, until I hit STRG-ALT-ENTF and return from the windows lock screen. Then the client area gets 'frozen', i.e. it is not refreshing. The application itself however is still responsive. When I set a breakpoint in

OnDraw2d(WPARAM wParam, LPARAM lParam){..}

Visual Studio breaks, so it is evident that all the drawing actually should happen. However, the application looks like this:

No graphics update in client area of MFC SDI application using Direct2D

Funny enough, this does ONLY happen when the mouse pointer is inside the client area while I hit STRG-ALT-ENTF. If it is outside, there is no problem.

Is this a bug or am I missing something?

Regards, Michael

  • You are *probably* failing to [handle device loss](https://learn.microsoft.com/en-us/windows/win32/learnwin32/drawing-with-direct2d#handling-device-loss). Without a [mcve], you can't expect anything more substantial than a guess. Please read [ask]. – IInspectable Feb 28 '20 at 08:44
  • I read that MFC Direct2D wrapper classes take care of device loss. Anyhow, I will try to deliver a minimal reproducible example. – user3045799 Feb 28 '20 at 08:54
  • Failing to deliver a minimal reproducible example, I found out the cause: In the aforementioned drawing operation, I used a CD2DPathGeometry object that got invalid. So it was after all due to device loss as you had mentioned. The solution is to catch the event of D2DERR_RECREATE_TARGET as an HRESULT of m_renderTarget.EndDraw(); and recreate the objects that have become invalid manually. – user3045799 Mar 02 '20 at 10:52

0 Answers0