0

I had to visually improve an old MFC application which worked fine in the old layout. Now with the new layout artifacts (highlighted in the picture below) can occur if another window is moved in the foreground of this application.
Even if my application gets back the focus it does not repaint properly.

The main windows is a CFrameWnd with style WS_OVERLAPPEDWINDOW and contains other elements like CWnd and CDialogBar.
I had to override the default behavior at some point (OnNcPaint, OnActivate, OnPaint) to achieve the specifications.

If I switch back to the ugly old layout, the drawing is faultless. But there are so many parts changed that I couldn't find the one difference that causes this issue. Hopefully you can name a possible reason.

I'm glad to assist you with more specific information if needed.

Artifacts

Peopleware
  • 1,399
  • 1
  • 25
  • 42
  • Did you recently remove XP support from this app? – Mark Ransom Dec 08 '14 at 18:00
  • It's the same behavior on XP and Windows 7. The software should also be an update for customers using old devices with XP so it is still a requirement. – Peopleware Dec 08 '14 at 18:02
  • I only ask because there's a change in the response to `GetSystemMetrics` if the app isn't marked for XP. I ran into it recently when my own `OnNcPaint` didn't paint properly. – Mark Ransom Dec 08 '14 at 18:06
  • 1
    It's because the background is not getting repainted correctly probably due to an optimisation handling WM_ERASEBKGND to reduce flicker. I suggest disabling any such optimisations until it is repainting correctly, then reimplement them one by one until you find the specific issue. – user1793036 Dec 09 '14 at 01:45
  • 1
    I found out that on Windows 7 the artifacts only occur if the service _Desktop Window Manager Session Manager_ is stopped. – Peopleware Dec 09 '14 at 08:51
  • Downvoted because you don't tell us what you changed and expect us to guess what you changed and what might cause the issue. – Werner Henze Dec 11 '14 at 12:43
  • @Werner Henze, I know this is a complex problem. I could post a hundred lines of code but that didn't seem constructive to me. Up to date resources on MFC are hard to find so I was hoping for some experienced user to give me some hints on the general mechanism. Since the problem is solved for Windows 7, it's not that urgent any more and I can close the discussion. – Peopleware Dec 12 '14 at 09:29

0 Answers0