bool m_bIsLButtonDawn =false; void CDrawDlg::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CWnd *pwnd=GetDlgItem(IDC_EDIT1); CDC *pdc=pwnd->GetDC(); CRect rect; this->ClientToScreen(&point); pwnd->ScreenToClient(&point); pwnd->GetClientRect(&rect); // HCURSOR hcur=::LoadCursorFromFile("pen.cur"); // SetClassLong(GetSafeHwnd(),GCL_HCURSOR,(LONG)hcur); // CPen pen(PS_INSIDEFRAME,-1,RGB(255,255,255)); // CPen* olePen=pdc->SelectObject(&pen); if(rect.PtInRect(point) && m_bIsLButtonDawn ) { pdc->DPtoLP(&m_fp); pdc->MoveTo(m_fp); pdc->DPtoLP(&point); pdc->LineTo(point); } m_fp=point; // pdc->SelectObject(olePen); ReleaseDC(pdc); CDialog::OnMouseMove(nFlags, point); } void CDrawDlg::OnLButtonUp(UINT nFlags, CPoint point) { m_bIsLButtonDawn =false; // TODO: Add your message handler code here and/or call default ///* CWnd *pwnd=GetDlgItem(IDC_EDIT1); CDC *pdc=pwnd->GetDC(); CRect rect; this->ClientToScreen(&point); pwnd->ScreenToClient(&point); pwnd->GetClientRect(&rect); if(rect.PtInRect(point)) { pdc->DPtoLP(&m_fp); pdc->MoveTo(m_fp); pdc->DPtoLP(&point); pdc->LineTo(point); } ReleaseDC(pdc);*/ CDialog::OnLButtonUp(nFlags, point); } void CDrawDlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CWnd *pwnd=GetDlgItem(IDC_EDIT1); CDC *pDC=pwnd->GetDC(); CRect rect; this->ClientToScreen(&point); pwnd->ScreenToClient(&point); pwnd->GetClientRect(&rect); if(rect.PtInRect(point)) { m_fp.x=point.x; m_fp.y=point.y; } ReleaseDC(pDC); m_bIsLButtonDawn =true; CDialog::OnLButtonDown(nFlags, point); }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/225884.html原文链接:https://javaforall.net
