第一种方式:使用HDC
- HDC hdc;
- hdc = ::GetDC(m_hWnd);
- MoveToEx(hdc, m_ptOld.x, m_ptOld.y, NULL);
- LineTo(hdc, m_ptNew.x, m_ptNew.y);
- ::ReleaseDC(m_hWnd,hdc);
- CPen pen(PS_SOLID, 1, RGB(255, 0, 0));
- CDC* pDC = GetDC();
- CPen* pOldPen = pDC->SelectObject(&pen);
- pDC->MoveTo(m_ptOld);
- pDC->LineTo(m_ptNew);
- pDC->SelectObject(pOldPen)
- ReleaseDC(pDC);
第三种方式:使用cclient- CClientDC dc(this);
- dc.MoveTo(m_ptOld);
- dc.LineTo(m_ptNew);
第四种方式:使用CWindowDC- CWindowDC dc(this);
- dc.MoveTo(m_ptOld);
- dc.LineTo(m_ptNew);
联系客服