重寫 DrawItem:
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rect = lpDrawItemStruct->rcItem;
UINT state = lpDrawItemStruct->itemState;
// 根據狀態選擇顏色
COLORREF bgColor;
if (state & ODS_SELECTED) bgColor = RGB(0, 120, 215); // 按下:藍
else if (state & ODS_DISABLED) bgColor = RGB(200,200,200); // 禁用:灰
else bgColor = RGB(0, 100, 180); // 正常:深藍
CBrush brush(bgColor);
pDC->FillRect(&rect, &brush);
// 繪製文字
CString text;
GetWindowText(text);
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(255,255,255));
pDC->DrawText(text, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
// 焦點框
if (state & ODS_FOCUS) pDC->DrawFocusRect(&rect);
}