gradyc
April 8th, 1999, 04:56 PM
How do I change the background color of a Static Text item on a dialog?
|
Click to See Complete Forum and Search --> : Static Text Color gradyc April 8th, 1999, 04:56 PM How do I change the background color of a Static Text item on a dialog? Gomez Addams April 8th, 1999, 07:57 PM 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 ! Dallex April 8th, 1999, 08:26 PM 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; } Gomez Addams April 9th, 1999, 12:09 PM 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. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |