Home > Software engineering >  INVALIDATE INVALIDATE (TRUE) (FALSE)
INVALIDATE INVALIDATE (TRUE) (FALSE)

Time:10-03

Void CMFCApplication1Dlg: : OnPaint ()
{
Invalidate (false);

//=====linear
HWND HWND=(HWND) AfxGetMainWnd () - & gt; M_hWnd;

HPEN hpenBlue=CreatePen (PS_SOLID, 1, RGB (0, 0, 255));//
HDC=: : GetDC (hWnd);


MoveToEx (HDC, 550, 300, NULL);
The LineTo (HDC, m_x, m_y);
}

Void CMFCApplication1Dlg: : OnBnClickedOk ()
{
Invalidate (true);
M_x=100;
M_y=100;
}
How to refresh the canvas to draw the line
Or use the invalidate (false);
Can't clear interface lines directly to draw the line

CodePudding user response:

OnPaint drawing completed refresh interface

CodePudding user response:

Shall not be used in the OnPaint Invalidate,
OnPaint use CPaintDC dc (this);//device context for painting
Not GetDC

Void CMFCApplication1Dlg: : OnPaint ()
{
CPaintDC dc (this);
//=====linear
HPEN hpenBlue=CreatePen (PS_SOLID, 1, RGB (0, 0, 255));//

Dc. MoveTo (550, 300);
Dc. LineTo (m_x, m_y);
}

CodePudding user response:

In the OnPaint function you calling the LineTo/MoveTo crossed again,
  • Related