Exemplo n.º 1
0
void CSquaresView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CView::OnLButtonDown(nFlags, point);

	//
	// Convert click coordinates to MM_LOENGLISH units.
	//
	CClientDC dc (this);
	dc.SetMapMode (MM_LOENGLISH);
	CPoint pos = point;
	dc.DPtoLP (&pos);

	//
	// If a square was clicked, set its color to the current color.
	//
	if (pos.x >= 35 && pos.x <= 315 && pos.y <= -35 && pos.y >= -315) {
		int i = (-pos.y - 35) / 70;
		int j = (pos.x - 35) / 70;
		CSquaresDoc* pDoc = GetDocument ();
		COLORREF clrCurrentColor = pDoc->GetCurrentColor ();
		pDoc->SetSquare (i, j, clrCurrentColor);
	}
}