Sunday, April 13, 2008

Why does ShowWindow cause a flicker?

When you call
ShowWindow(hwnd, SW_SHOW);
the WM_ERASEBKGND message is sent to the window procedure. If you are using your own custom paint routine, you probably don't need this. It will fill in your window with gray and then your paint routine will paint over it, but the gray fill appears briefly as a flicker. To prevent this, just override the WM_ERASEBKGND message handler.
case WM_ERASEBKGND:
return FALSE;

No comments: