1、DrawTestDlg.h

    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);

    CPoint m_originPoint;

2、DrawTestDlg.cpp

void CDrawTestDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
    m_originPoint.x = point.x;
    m_originPoint.y = point.y;

    CDialogEx::OnLButtonDown(nFlags, point);
}

void CDrawTestDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
    //首先获得窗口的设备描述表
    HDC hdc;
    hdc = ::GetDC(m_hWnd);
    //移动到线条的起点
    MoveToEx(hdc, m_originPoint.x, m_originPoint.y, NULL);
    //画线
    LineTo(hdc, point.x, point.y);
    //释放设备描述表
    ::ReleaseDC(m_hWnd, hdc);

    CDialogEx::OnLButtonUp(nFlags, point);
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2021-12-28
  • 2022-01-04
  • 2021-12-22
  • 2022-12-23
相关资源
相似解决方案