#include "pch.h" #include "MyButton.h" BEGIN_MESSAGE_MAP(MyButton, CButton) ON_WM_CTLCOLOR_REFLECT() END_MESSAGE_MAP() MyButton::MyButton() { m_color = RGB(0, 0, 255); // ĬÈÏÀ¶É« } void MyButton::SetButtonColor(COLORREF color) { m_color = color; RedrawWindow(); } HBRUSH MyButton::CtlColor(CDC* pDC, UINT /*nCtlColor*/) { // TODO: Ôڴ˸ü¸Ä DC µÄÈκÎÌØÐÔ if (this->IsWindowEnabled()) { pDC->SetBkColor(m_color); } // TODO: Èç¹û²»Ó¦µ÷Óø¸¼¶µÄ´¦Àí³ÌÐò£¬Ôò·µ»Ø·Ç null »­±Ê return NULL; }