Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I want to the change the textcolor of CMFCBUTTON in disabled state. Iam successfully able to change textcolor when button is in enable state. I tried below code which is mentioned in 'what have you tried section'

What I have tried:

bool var;
CMFCBUTTON * m_btn;
m_btn->EnableWindow(var)
if(var)
{
m_btn->SetFaceColor(RGB(0,255,0),true);
m_btn->SetTextColor(RGB(255,255,255));
}

else
{
m_btn->SetFaceColor(RGB(255,0,0),true);
m_btn->SetTextColor(RGB(33,33,33));
}

Here face color got changed in both enable and disable condition but text color got reflected only in enable condition.
Posted
Comments
Richard MacCutchan 5-Jun-20 10:38am    
Yes because you have not given your boolean variable var a value. So it will contain (probably) some random garbage, which could be zero or not.
Rick York 5-Jun-20 10:51am    
You might want to consider the FooButton class at this site by Ravi Bhavnani. It is an owner-drawn button class for use with MFC. I use it extensively and it is pretty good. https://www.codeproject.com/Articles/7622/FooButton

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900