Changing button color

Changing button color

Post by Phillip Tus » Fri, 18 Jul 2003 07:11:39



Greetings to all ...

Can someone post a solution to dynamically change a button's color?

Thanks in advance.

Phil Tusa

 
 
 

Changing button color

Post by Seve » Fri, 18 Jul 2003 08:36:22



Quote:> Greetings to all ...

> Can someone post a solution to dynamically change a button's color?

> Thanks in advance.

> Phil Tusa

You must intercept the WM_CTLCOLOR message and change the color using a
different brush from the default one.

HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    if (nCtlColor == CTLCOLOR_BTN)
    {
        pDC->SetTextColor (m_colorText);
        pDC->SetBkColor (m_colorBack);
        return m_hbrBack;            // a brush previously created 'ad hoc'
    }

    // TODO: Return a different brush if the default is not desired
    return hbr;

Quote:}.

Hope this helps

Severino Delaurenti
MultiMedia Soft ( http://www.multimediasoft.com )

 
 
 

1. how to change button color not MFC application

Hi there
this should be easy...I have a winCE application not using MFC. I've a
button and I simply want to change its color.
What should I do ?
I tryed catching the WM_CTLCOLORBTN message and by using lparam and wparam
and SetBkcolor().. but it doesn't work...
Any suggestion ??

what's the meaing of SetSysColor() ??

Thank in advance
Chevassunse

2. Questions: NDS - DX2/66

3. changing button colors

4. Championship Manager 4

5. Changing text and colour of start button?

6. Hard drive portibility

7. Any way of changing the Start Button Colour?

8. no sound since i put XP on WHY??

9. How do u change the color of the ugly green button?

10. How to change color start button

11. Easy way to change start button color?

12. How do i change start button color?

13. CHANGING THE START BUTTON COLOR