. 打开资源视图。
2. 双击打开STATIC所在的对话框。
3. 修改STATIC的ID属性,这里假设为IDC_STATIC1。
4.为对话框添加类,假设为CProp1.
5. 选择对话框,在属性面板上点击消息,并选择WM_CTLCOLOR。
添加如下代码:
HBRUSH CProp1::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if (pWnd->GetDlgCtrlID() == IDC_STATIC1)
{
pDC->SetTextColor(RGB(255, 0, 0));
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
就OK!了