static text
-
how to change colour of static text at runtime.
-
how to change colour of static text at runtime.
Try using SetTextColor function of CDC by trapping the ON_WM_CTLCOLOR() message. In the message-handler OnCtlColor, use code like this:
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);//Here m\_stText represents a CStatic control if(m\_stText.m\_hWnd == pWnd->m\_hWnd) { pDC->SetTextColor(RGB(0,0,155)); } return hbr;
}
Regards, Ashok Dhamija _____________________________ Padam Technologies
-
Try using SetTextColor function of CDC by trapping the ON_WM_CTLCOLOR() message. In the message-handler OnCtlColor, use code like this:
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);//Here m\_stText represents a CStatic control if(m\_stText.m\_hWnd == pWnd->m\_hWnd) { pDC->SetTextColor(RGB(0,0,155)); } return hbr;
}
Regards, Ashok Dhamija _____________________________ Padam Technologies
hi, thanks man it worked ,and for clearing the concept with that informative code I added the following code to get the CWnd* handle to the static control from the IDC_ CWnd *m_stText=GetDlgItem(IDC_STATIC);and i guess it doesnt work with the button. thanks Farpointer
-
how to change colour of static text at runtime.
The WM_CTLCOLORSTATIC message is sent to the parent during drawing of the control. The HDC and HWND are provided to change the foreground colors. The return value is a brush to set the background.
-
hi, thanks man it worked ,and for clearing the concept with that informative code I added the following code to get the CWnd* handle to the static control from the IDC_ CWnd *m_stText=GetDlgItem(IDC_STATIC);and i guess it doesnt work with the button. thanks Farpointer
farpointer wrote: guess it doesnt work with the button. thanks For Coloring the Button you either have to subclass it or make it owner drawn...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV