When it comes to what's been drawn in an app's client area and whether it needs to be painted again when part or all of the client area is obscured changed starting with Vista. Desktop composition, run by the Windows Desktop Manager (DWM)
https://learn.microsoft.com/en-us/windows/win32/dwm/dwm-overview
Note carefully: Win apps no longer write/draw directly to the screen or primary display device as done with pre-Vista apps, with the DWM any output is written/drawn to offscreen surfaces that are used to create the visible desktop image.
IOWs, what is written to an app's DC is maintained by the DWM and if the device context (DC) needs to be redrawn it is composited from the stored offscreen data.
Most WinAPI examples/samples/ documentation were created before Windows Vista, so presume data is written directly to an app's DC.
The DWM from Vista to Win 7 could be programmatically turned on and off by an app. Since Win 8 DWM is always on. That means DWM is always enabled with Win 10.
Now when an app needs to change what is drawn to the screen needs to invalidate the DC to force a repaint.
That includes any windowed controls in the client area, a WinAPI button is a control.
Ever hover your pointer over the taskbar and any apps that are displayed there? You will see a live preview of the app even when it is minimized or obscured by other window(s). That is one feature of the DWM.
https://learn.microsoft.com/en-us/windows/win32/dwm/thumbnail-ovw
With all that said without seeing your code it is nigh um-possible to definitively diagnose what the problem might be. A Short, Self Contained, Correct (Compilable), Example would be most helpful.
http://www.sscce.org/
Sharing your code online as a git repository would let us run the code through our compiler and see what the problem(s) might be, and then provide possible solutions. GitHub is one service, and it can be used for free.
https://github.com/
I have several public GitHub repos you can look at, C/C++/WinAPI (shameless self-promotion):
https://github.com/GeorgePimpleton