void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
HDC hdc;
hdc=::GetDC(m_hWnd);
MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,&cmpa);
LineTo(hdc,point.x,point.y);
::ReleaseDC(m_hWnd,hdc);
CString str;
str.Format("%d %d\n%d %d",cmpa.x,cmpa.y,point.x,point.y);
MessageBox(str);
CView::OnLButtonUp(nFlags, point);
}
我在这个类中定义了两个CPoint的变量 m_ptOrigin和cmpa,吧这两个点格式化后输出,但是messagebox总是弹出cmpa的值是0,0,不知道什么问题,point这个正常,高手指点
{
// TODO: Add your message handler code here and/or call default
HDC hdc;
hdc=::GetDC(m_hWnd);
MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,&cmpa);
LineTo(hdc,point.x,point.y);
::ReleaseDC(m_hWnd,hdc);
CString str;
str.Format("%d %d\n%d %d",cmpa.x,cmpa.y,point.x,point.y);
MessageBox(str);
CView::OnLButtonUp(nFlags, point);
}
我在这个类中定义了两个CPoint的变量 m_ptOrigin和cmpa,吧这两个点格式化后输出,但是messagebox总是弹出cmpa的值是0,0,不知道什么问题,point这个正常,高手指点
HDC_hdc, //_handle_to_device_context
int_X, //_x-coordinate_of_new_current_position
int_Y, //_y-coordinate_of_new_current_position
LPPOINT_lpPoint _//_old_current_position
);
函数的功能是将现在的设备基点位置移动到所制定的位置,并且以一个指针返回以前的基点位置。其中最后一个参数是用来接受以前的点位置的,如果这个值为空,就简单的将忽略返回值cmpa初始值为0?
hdc=::GetDC(m_hWnd);
MoveToEx(hdc, 100, 100, NULL);
LineTo(hdc,point.x,point.y);
MoveToEx(hdc, m_ptOrigin.x, m_ptOrigin.y, &cmpa);
LineTo(hdc,point.x,point.y);
::ReleaseDC(m_hWnd,hdc);
CString str;
str.Format("%d %d\n%d %d",cmpa.x,cmpa.y,point.x,point.y);
MessageBox(str);如果你写成这样 就有的保存了