I just started to learn MFC. I need to draw a circle. If I use OnPaint() it works. What should i do that it will draw on background ? Is this the proper function or should I change it?
void Cvaja5Dlg::OnRButtonDown(UINT nFlags, CPoint point)
{
CPaintDC dc(this);
dc.Ellipse(0,0,500,500);
CDialogEx::OnRButtonDown(nFlags, point);
}
No, Windows painting works different way. It’s quite asynchronous.
CPaintDCshall be used only insideWM_PAINThandler as it performsBeginPaint()/EndPaint()calls.CWnd::OnPaint()/CView::OnDraw()method.isRightButtonDownand callInvalidate()to initiate asynchronous repainting of window. To enforce synch repainting you could useUpdateWindow()orRedrawWindow()right after invalidating.