问题如下:
在一个对话框中放一个CStatic控件,相关变量为m_static,然后加一个CButton,为这个CButton添加相应事件,代码如下: m_static.GetDC()->SetTextColor(0X0000FF);
m_static.SetWindowText("测试");但是这个文本框里面的字就是黑色,请教名位,这是什么原因?
在一个对话框中放一个CStatic控件,相关变量为m_static,然后加一个CButton,为这个CButton添加相应事件,代码如下: m_static.GetDC()->SetTextColor(0X0000FF);
m_static.SetWindowText("测试");但是这个文本框里面的字就是黑色,请教名位,这是什么原因?
{
// Call the base class implementation first! Otherwise, it may
// undo what we're trying to accomplish here.
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // Are we painting the IDC_MYSTATIC control? We can use
// CWnd::GetDlgCtrlID() to perform the most efficient test.
if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)
{
// Set the text color to red
pDC->SetTextColor(RGB(255, 0, 0)); // Set the background mode for text to transparent
// so background will show thru.
pDC->SetBkMode(TRANSPARENT); // Return handle to our CBrush object
hbr = m_brush;
} return hbr;
}其实也可以通过OnCtlColor实现,你可以在类中放一个表示颜色的参数,然后BUTTON事件中赋值,在OnCtlColor中设为这个颜色。BUTTON后只要设法重新调用OnCtlColor即可。还可以,派生出自己的CYouStatic类来管理控件,这样更方便。把分给mahongxi(烤鸡翅膀)(色摸) 和 lzd(雨中绝音)