I developed an application for displaying jpeg images. It can display 4 images, one in each quadrant of the screen. For this, 4 windows are used. Windows do not have a border (frame) and a title. When a new image is uploaded, the window size is adjusted for the new image, and then the image is displayed.
Especially when the window gets larger, it often flickers. Looking at the slots, it seems that the old content moves when you resize it until the new content is displayed.
I consulted with many resources and used all the tricks:
the window has only the CS_DBLCLKS style (no CS_HREDRAW or CS_VREDRAW);
background brush is NULL;
WM_ERASEBKGND returns 1;
WM_NCPAINT returns 0;
WM_NCCALCSIZE indicates to align a side that has not been moved (can you say that it drops the client area?);
WM_WINDOWPOSCHANGING returns 0;
SetWindowPos has flags SWP_NOCOPYBITS | SWP_DEFERERASE | SWP_NOREDRAW | SWP_NOSENDCHANGING.
However, flickering (or moving content) occurs when the window is resized. I want to:
SetWindowPos for the new size and position;
InvalidateRect (hWnd, NULL, FALSE);
UpdateWindow (HWND);
without drawing, erasing the background, or moving content to WM_PAINT. WM_PAINT uses:
hDC= BeginPaint (hWnd, &ps); hMemDC= CreateCompatibleDC (hDC); hOldBitmap = SelectObject (hMemDC, hNewBitmap); BitBlt (hDC,...,hMemDC,0,0,SRCCOPY); SelectObject (hMemDC, hOldBitmap); DeleteDC (hMemDC); EndPaint (hWnd, &ps);
Can someone tell me if / where I am making a mistake that causes the old contents of the window to be moved?
Hardware, etc.: Windows 7 on an HP Elitebook Core7 64 bit with NVIDIA Quadro K1000m 9.18.13.3265 driver (updated to 341.44).
UPDATE (July '17)
I saw the behavior of the program on another computer running Windows (Windows 8/10). This is not like the NVIDIA display driver.
The behavior is most noticeable when you resize the window laid out in the center of the screen (bottom right = w / 2, h / 2) in the upper left or left corner (0, 0).
I may have problems computing for the WM_NCCALCSIZE message to tell Windows to do nothing. Can someone give an example of calculation for my purpose? See Also. How do I make windows NOT redraw anything in my dialog when a user resizes my dialog?