
set the text color and the background color of a Control Cbutton
Use an owner-draw button. There is an example of a bitmap-based
owner-draw button on my MVP Tips site, and you can work
theme-and-variation on this to draw anything you want.
joe
On Tue, 25 Apr 2000 14:14:40 +0200, "Arnaud MASION"
Quote:
>Hello,
>I would like to set the text color and the background color of a Control
>Cbutton.
>I tried the following code in 'OnCtlColor' but it only works for a CStatic
>Control.
>HBRUSH CFontesView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
>{
> HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
> COLORREF crRed = RGB(255,0,0);
> COLORREF crBlue = RGB(128,184,223);
> if (nCtlColor != CTLCOLOR_EDIT && nCtlColor != CTLCOLOR_LISTBOX
> && nCtlColor != CTLCOLOR_BTN)
> {
> pDC->SetBkMode(TRANSPARENT);
> hbr = CreateSolidBrush(crBlue);
> }
> if (pWnd->GetDlgCtrlID() == IDC_BUTTONTEST1) // Doesn't work ! ! ! !
>{
> pDC->SetBkMode(TRANSPARENT);
> pDC->SetTextColor(crRed);
> pDC->SetBkColor(WHITE);
> hbr = CreateSolidBrush(WHITE);
> return (HBRUSH) hbr;
> }
> if (pWnd->GetDlgCtrlID() == IDC_STATIC2) // ok !!!
> {
> pDC->SetBkMode(TRANSPARENT);
> pDC->SetTextColor(crRed);
> file://pDC->SetBkColor(WHITE);
> }
> return hbr;
>}
>Thanks,
>Arnaud from France
Joseph M. Newcomer [MVP]
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm