OnCtlColor里这么做HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { // 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() == IDB_MYBUTTON) { // Set the back color pDC->SetBkColor(RGB(255, 0, 0)); hbr = m_brush; } return hbr; }
{
// 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() == IDB_MYBUTTON)
{
// Set the back color
pDC->SetBkColor(RGB(255, 0, 0));
hbr = m_brush;
} return hbr;
}
CButton着色很麻烦,不过我见过现成的类,可以着色。
自己生成一个CButton的子类
并改写DrawItem()
在DrawItem()中自己画,
呵呵。。
你见过类到底是什么类,详细一点,好不好。
http://www.csdn.net/develop/read_article.asp?id=9603
if (pWnd->GetDlgCtrlID() == IDB_MYBUTTON)
{ ....
}
IDB_MYBUTTON 在哪定义的?在MSDN查不到的!请赐教!
IDB_MYBUTTON是自己用CBUTTON派生类CREATE时指定的,或绑定通过资源编辑器加上的按馏;
我觉得在CBUTTON类中改写ONCTLCTRL()函数可以达到要求.
类里改写ONCTLCTRL()消息函数.