|
-
May 7th, 2005, 04:58 PM
#1
Click a button and change color on rectangle?
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?
-
May 7th, 2005, 07:24 PM
#2
Re: Click a button and change color on rectangle?
-
May 8th, 2005, 02:45 AM
#3
Re: Click a button and change color on rectangle?
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:
So what is the problem? Should we guess?
You should not use any of the two forms, but:
and if you want to test it agains false then
PS: doesn't you compiler give you a warning here
It should.
-
May 8th, 2005, 05:47 AM
#4
Re: Click a button and change color on rectangle?
No warning from the compiler, strange since you said that.
I'll check...
-
May 8th, 2005, 06:00 AM
#5
Re: Click a button and change color on rectangle?
The compiler generates a warning on an assignment within conditional expression on Warning Level 4, looks like you didn't change the default level 3.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|