|
-
April 8th, 1999, 04:56 PM
#1
Static Text Color
How do I change the background color of a Static Text item on a dialog?
-
April 8th, 1999, 07:57 PM
#2
Re: Static Text Color
Have a look in the static controls section of this site.
There is an article called 'Extended use of CStatic Class'
or something like that. It can do lots of things to static text !
-
April 8th, 1999, 08:26 PM
#3
Re: Static Text Color
The control background is painted with the brush returned from OnCtlColor.
You can accomplish what you are looking for like this:
HBRUSH CComputeDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// handle only STATIC controls
if( nCtlColor == CTLCOLOR_STATIC )
{
short ID = pWnd->GetDlgCtrlID(); // get STATIC's control ID
if( ID == IDC_STATIC11 ) // if the right control, change color
{
pDC->SetTextColor(RGB(255,255,255));
pDC->SetBkMode(TRANSPARENT);
hbr = (HBRUSH)::GetStockObject(BLACK_BRUSH);
}
}
return hbr;
}
-
April 9th, 1999, 12:09 PM
#4
Re: Static Text Color
That method would work for one control and would be somewhat
cumbersome to use for more than one. The class I mentioned
can control the foreground and background color and the font
type and style also. I believe that this is easier to use then the
method you posted although it does require one to download the
class. To use the CLabel class one declares a variable of type
CLabel and then calls its control methods such as :
m_static1.SetBkColor(crBkgnd); // sets background colour
m_static1.SetTextColor(crText); // sets foreground colour
Of course, these are my opinions. Your mileage may vary.
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
|