get background color
-
Since i am trying to put text (CDC) on a Cstatic (which looks bluish on my screen) I would like to set the background color of CDC for the TextOut to be the same as the label color. I tried doing the following in the label class but of course its incorrect. HOw do I get the color of the label so I can SetBkColor of the CDC?
COLORREF cl = GetBkColor(GetDC());
GetBkColor' : cannot convert parameter 1 from 'class CDC *' to 'struct HDC__ *'
thanks, sb
-
Since i am trying to put text (CDC) on a Cstatic (which looks bluish on my screen) I would like to set the background color of CDC for the TextOut to be the same as the label color. I tried doing the following in the label class but of course its incorrect. HOw do I get the color of the label so I can SetBkColor of the CDC?
COLORREF cl = GetBkColor(GetDC());
GetBkColor' : cannot convert parameter 1 from 'class CDC *' to 'struct HDC__ *'
thanks, sb
-
If this does not help:
COLORREF cl = GetDC()->GetBkColor();
nor
COLORREF cl = m_cMyLabel.GetDC()->GetBkColor();
then you can try this:
COLORREF cl = (COLORREF)GetSysColor(COLOR_3DFACE);
Those calls to
GetDC()
are bad - you need to release every DC you get.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ VB > soccer
-
Those calls to
GetDC()
are bad - you need to release every DC you get.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ VB > soccer
Michael Dunn wrote:
Those calls to GetDC() are bad - you need to release every DC you get.
You are right -- explicit releasing should be preferable. Actually MFC is able to release various handles at idle time. Values returned by
GetDC
and other functions are temporary objects which are stored in a collection. They a released between message processing.