HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if (pWnd->GetDlgCtrlID() == IDC_STATICText) { pDC->SetBkColor(RGB(0,255,0));//文字背景色为绿色 需要返回对应颜色画刷,才能填充没有文字的背景 pDC->SetTextColor(RGB(255, 0, 0));//文字为红色 pDC->SelectObject(&m_font);//文字为15号字体,华文行楷 return m_brush; // 需要返回对应颜色画刷,才能画满完全的背景 } // TODO: Return a different brush if the default is not desired return hbr; }
HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if (pWnd->GetDlgCtrlID() == IDC_STATICText) { pDC->SetBkColor(RGB(0,255,0));//文字背景色为绿色 需要返回对应颜色画刷,才能填充没有文字的背景 pDC->SetTextColor(RGB(255, 0, 0));//文字为红色 pDC->SelectObject(&m_font);//文字为15号字体,华文行楷 return m_brush; // 需要返回对应颜色画刷,才能画满完全的背景 } // TODO: Return a different brush if the default is not desired return hbr; }
Win32 BM_SETCHECK wParam BST_CHECKED,BST_INDETERMINATE,BST_UNCHECKED lParam NULL BOOL CheckRadioButton( __in HWND hDlg, __in int nIDFirstButton, __in int nIDLastButton, __in int nIDCheckButton ); If the function succeeds, the return value is nonzero. Otherwise is zero.
MFC intGetCheckedRadioButton( int nIDFirstButton, int nIDLastButton ); ID of the checked radio button, or0if none is selected.
voidCheckRadioButton( int nIDFirstButton, int nIDLastButton, int nIDCheckButton );
// Of the 4 radio buttons, selects radio button 3. voidCMyDlg::OnMarkRadio() { CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO3); }
Win32 BM_SETCHECK wParam BST_CHECKED,BST_INDETERMINATE,BST_UNCHECKED lParam NULL BOOL CheckRadioButton( __in HWND hDlg, __in int nIDFirstButton, __in int nIDLastButton, __in int nIDCheckButton ); If the function succeeds, the return value is nonzero. Otherwise is zero.
MFC intGetCheckedRadioButton( int nIDFirstButton, int nIDLastButton ); ID of the checked radio button, or0if none is selected.
voidCheckRadioButton( int nIDFirstButton, int nIDLastButton, int nIDCheckButton );
// Of the 4 radio buttons, selects radio button 3. voidCMyDlg::OnMarkRadio() { CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO3); }