示例#1
0
void CSketcherView::MoveElement(CClientDC & aDC, const CPoint & point)
{
	CSize distance = point - m_CursorPos; // Get move distance
	m_CursorPos = point; // Set current point as 1st for next time
	
	// If there is an element selected, move it
	if(m_pSelected)
	{
		if (typeid(*m_pSelected) == typeid(CText))
		{
			CRect oldRect=m_pSelected->GetBoundRect(); // Get old bound rect
			aDC.LPtoDP(oldRect); // Convert to client coords
			m_pSelected->Move(distance); // Move the element
			InvalidateRect(&oldRect); // Invalidate combined area
			UpdateWindow(); // Redraw immediately
			m_pSelected->Draw(&aDC,m_pSelected); // Draw highlighted
			return;
		}
		// ...otherwise, use this method
				
		aDC.SetROP2(R2_NOTXORPEN);
		m_pSelected-> Draw(&aDC, m_pSelected); // Draw the element to erase it
		m_pSelected-> Move(distance); // Now move the element
		m_pSelected-> Draw(&aDC, m_pSelected); // Draw the moved element
	}
}
示例#2
0
void CSketcherView::MoveElement(CClientDC & aDC, const CPoint & point)
{
	CSize distance = point - m_CursorPos; // Get move distance
	m_CursorPos = point; // Set current point as 1st for
	// next time
	// If there is an element selected, move it
	if(m_pSelected)
	{
		aDC.SetROP2(R2_NOTXORPEN);
		m_pSelected-> Draw(&aDC, m_pSelected); // Draw the element to erase it
		m_pSelected-> Move(distance); // Now move the element
		m_pSelected-> Draw(&aDC, m_pSelected); // Draw the moved element
	}
}