CStatic background color problem
-
I am writing a program that displays static text on a black background. I can change the CStatic object backgound color to black or I can set the space behind the text to the standard light grey color I.E the space directly behind the text not the entire CStatic area (toggle m_staticTextBgd see below). I want to change this light grey to another color. I tried SetSysColors but I dont want to change this at a system level. Thanks
if (nCtlColor == CTLCOLOR_STATIC ) { CWnd *Ctrl = GetDlgItem(pWnd->GetDlgCtrlID()); if (Ctrl) { CRect Rect; Ctrl->GetWindowRect(&Rect); this->ScreenToClient(&Rect); COLORREF Clr = this->GetDC()->GetPixel(Rect.left-1, Rect.top-1); DeleteObject(hbr); hbr = CreateSolidBrush(Clr); if(!m_staticTextBgd) pDC->SetBkColor(Clr); pDC->SetTextColor(RGB(m_fntR,m_fntG,m_fntB)); pDC->SetBkMode(m_staticTextBgd?OPAQUE:TRANSPARENT); } } return hbr;
--- -
I am writing a program that displays static text on a black background. I can change the CStatic object backgound color to black or I can set the space behind the text to the standard light grey color I.E the space directly behind the text not the entire CStatic area (toggle m_staticTextBgd see below). I want to change this light grey to another color. I tried SetSysColors but I dont want to change this at a system level. Thanks
if (nCtlColor == CTLCOLOR_STATIC ) { CWnd *Ctrl = GetDlgItem(pWnd->GetDlgCtrlID()); if (Ctrl) { CRect Rect; Ctrl->GetWindowRect(&Rect); this->ScreenToClient(&Rect); COLORREF Clr = this->GetDC()->GetPixel(Rect.left-1, Rect.top-1); DeleteObject(hbr); hbr = CreateSolidBrush(Clr); if(!m_staticTextBgd) pDC->SetBkColor(Clr); pDC->SetTextColor(RGB(m_fntR,m_fntG,m_fntB)); pDC->SetBkMode(m_staticTextBgd?OPAQUE:TRANSPARENT); } } return hbr;
---Coremn wrote: COLORREF Clr = this->GetDC()->GetPixel(Rect.left-1, Rect.top-1); Coremn wrote: hbr = CreateSolidBrush(Clr); Coremn wrote: return hbr; You retruning the brush with the old screen color rite, then how is the color going to change ?
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
-
Coremn wrote: COLORREF Clr = this->GetDC()->GetPixel(Rect.left-1, Rect.top-1); Coremn wrote: hbr = CreateSolidBrush(Clr); Coremn wrote: return hbr; You retruning the brush with the old screen color rite, then how is the color going to change ?
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
Mr.Prakash wrote: return hbr; You retruning the brush with the old screen color rite, then how is the color going to change ? hbr is the background screen color, in my case black. This colors in the excess space in the CStatic where there is no text, I.E making the unused space blend in with the background, I want the space behind the actual text to be colored, this is done by not using
pDC->SetBkColor(Clr);
in the method OnCtlColor. But I dont know how to change this from light gray. --- -
Mr.Prakash wrote: return hbr; You retruning the brush with the old screen color rite, then how is the color going to change ? hbr is the background screen color, in my case black. This colors in the excess space in the CStatic where there is no text, I.E making the unused space blend in with the background, I want the space behind the actual text to be colored, this is done by not using
pDC->SetBkColor(Clr);
in the method OnCtlColor. But I dont know how to change this from light gray. ---pDC->SetBkMode(TRANSPARENT) will do the trick.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)