I have a problem. I need to change color to the rectangle when I click a button on the toolbar.
Here is the code for OnDraw:
Code:
void CObligatorisk_oppgaveView::OnDraw(CDC* pDC){

	CObligatorisk_oppgaveDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// Tegner ut rektangel A og rektangel B og resultatet C
	pDC->FrameRect(rectA, &blackBrush);
	pDC->FrameRect(rectB, &blackBrush);

	if(fargered=true)
	{
		pDC->FrameRect(rectC, &redBrush);
	}
	else 
	{
		CBrush blackHatchBrush;
		blackHatchBrush.CreateHatchBrush(HS_FDIAGONAL, RGB(0,0,0));
		CBrush* pOldBrush = pDC->SelectObject(&blackHatchBrush);

		CPen blackPen;
		blackPen.CreatePen(PS_SOLID, 3, RGB(0, 0, 0));
		CPen* pOldPen = pDC->SelectObject(&blackPen);

		pDC->Rectangle(rectC);

		pDC->SelectObject(pOldPen);
		pDC->SelectObject(pOldBrush);

	}
Here is the code for the button:
Code:
void CObligatorisk_oppgaveView::OnFargerR()
{
	fargered = true;
	Invalidate();

}
Can some one help me?