Hello i've been looking for a couple of days now how to avoid controls themselves from flickering in a CDialog.
I am using CMemDC and erasing the background to draw some basic shapes with GDI+
void CCustomDialog::OnPaint()
{
CPaintDC pDC(this);
CMemDC dc(&pDC);
Gdiplus::Graphics graphics(dc.GetSafeHdc());
CRect clip;
dc.GetClipBox(&clip);
dc.FillSolidRect(clip, GetSysColor(COLOR_WINDOW));
DefWindowProc(WM_PAINT, (WPARAM)dc->m_hDC, (LPARAM)0);
Gdiplus::Pen pen(Gdiplus::Color(150, 125, 255, 100), 5.0);
graphics.DrawEllipse(&pen, 200, 50+m_interator, 100, 100);
}
This class inherits from CDialog and will then itself be a base class to other dialogs to control the "theme".
however when i invalidate and then update the window on a mouse move event
void CCustomDialog::OnMouseMove(UINT nFlags, CPoint point)
{
m_interator++;
Invalidate();
UpdateWindow();
CDialog::OnMouseMove(nFlags, point);
}
The Ellipse doesn't flicker at all but all the other buttons, labels and edit controls do.
I haven't found anything to avoid this and i myself do not know enough about MFC to avoid it.
Any ideas?
I was thinking maybe I can set the DC of the controls to be the same CMemDC, but i'm not sure how to do that yet, will post here if I figure it out.