I am not a real fan of MFC but I can tell you what windows API is doing. Dialog backgrounds paint by WM_CTLCOLORDLG, WM_CTLCOLORSTATIC it used to be WM_CTLCOLOR and I suspect MFC still uses WM_CTLCOLOR because it has a couple of bugs. Usually what you want to do is return a NULL_BRUSH with GetStockObject(NULL_BRUSH); So this one if you paint the entire dialog then return a NULL_BRUSH WM_CTLCOLORDLG message - Windows applications | Microsoft Docs[^] MFC may use this one and again return a NULL_BRUSH WM_CTLCOLOR message - Windows applications | Microsoft Docs[^] That means it doesn't paint the background before it sends you an WM_PAINT :-) If you want/need to transparent overlay the bitmap you have to use a transparent colour to stop flashing
void CDemoDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
// transfer the bitmap into paint DC using a transparent color
dc.TransparentBlt(
10, 10, bmp.bmWidth, bmp.bmHeight, // destination coordinates and sizes
&pDCTmp, // source DC .. your DC with bitmap
0, 0, bmp.bmWidth, bmp.bmHeight, // source coordinates and sizes
RGB(255, 0, 0)); // transparent color
}
In vino veritas