Here my code
if(bSelected)
{
clrTextSave=pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
clrBkSave=pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
pDC->FillRect(rcAllLabels,&CBrush(::GetSysColor(COLOR_HIGHLIGHT)));
}
else
pDC->FillRect(rcAllLabels,&CBrush(m_clrTextBk));
When I complie on Visual studio 2008 it give me : warning C4238: nonstandard extension used : class rvalue used as lvalue I don't know how to fix this warning? Plz somebody help? Thank you !
You are getting the warning (which should be an error because you should always compile your code using the highest warning level) because you are creating a temporary and using it's address. To prevent this warning, you need to create a local variable instead:
if(bSelected)
{
clrTextSave = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
clrBkSave = pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
CBrush brush(::GetSysColor(COLOR_HIGHLIGHT)); // create a local variable
pDC->FillRect(rcAllLabels, &brush); // use its address
}
else
{
CBrush brush(m_clrTextBk); // same thing here
pDC->FillRect(rcAllLabels, &brush);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With