I am new to programming, writing a program with a non-standard interface. The window frame in Windows 10 moves as it should, but in Windows 7 a trace remains when you move the left frame to the right.

incorrect frame movement

It’s impossible to bring all the code because of its size, but here are a few lines that are responsible for drawing the window:

SetWindowPos ( HwndGlavOkna, HWND_TOP, KoorGlavOknaX, KoorGlavOknaY, WirinaGlavOkna, VysotaGlavOkna, SWP_NOREDRAW ) InvalidateRect ( HwndGlavOkna, NULL, TRUE ) RedrawWindow ( HwndGlavOkna, NULL, NULL, RDW_INTERNALPAINT ) 

Tell me, please, what could be the error.

Here is the region drawing code:

 case WM_PAINT: hRgn = CreateRoundRectRgn ( 0, 0, WirinaGlavOkna, VysotaGlavOkna, 20, 20 ); if ( hRgn == NULL ) oNeizvOw; if ( SetWindowRgn ( IdGlavOkna, hRgn, TRUE ) == 0 ) oNeizvOw; 
  • And the code of drawing of this region (in WM_PAINT) can show? - mega
  • one
    Generally, if such code is required to redraw a window, it means something is crooked. Why is the usual InvalidateRect or InvalidateRgn not enough? - mega
  • one
    Perhaps the RDW_ERASE flag or its combination with RDW_FRAME (if you draw in the non-client area, in response to WM_NCPAINT ). - mega
  • @mega added region rendering code. - 0Zerro
  • @mega did not understand your question in the second comment. Do you mean remove RedrawWindow ? - 0Zerro

1 answer 1

I managed to fix the error by replacing the SWP_NOREDRAW flag with SWP_SHOWWINDOW :

 if ( SetWindowPos ( HwndGlavOkna, HWND_TOP, KoorGlavOknaX, KoorGlavOknaY, WirinaGlavOkna, VysotaGlavOkna, SWP_SHOWWINDOW ) == 0 ) oNeizvOw;