Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How do i change the text color of a PUSHBUTTON...??? Using Windows API.
Posted
Updated 31-Jan-12 9:57am
v3
Comments
Sergey Alexandrovich Kryukov 31-Jan-12 13:56pm    
What language, API and UI library do you use? Tag it.
--SA
ZurdoDev 31-Jan-12 16:12pm    
Need way more specific details. Is this for a different application, one that you do not have control over?
iamrohitsingh 31-Jan-12 16:25pm    
I am just developing a Calculator using WINDOWS API(NO MFC) ...And i want the color of calculators buttons to be different....how do i do that...???

Read Microsoft documentation:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb761849(v=vs.85).aspx[^]

By the way, this kind of thing is somehow hard to do with the API (and just a bit better with MFC) as message are sent to the parent windows instead of the control itself. This make it harder to make reusable controls.

WinForms (and WPF) are hundredth of time better for that. The color can be set directly in the designer or a single line of code is required to set the color in code.
 
Share this answer
 
Comments
iamrohitsingh 1-Feb-12 7:37am    
I have only programmed in WINDOWS API. I don't no MFC. If you can suggest me a good book to learn MFC or WPF
Christopher P Taylor 21-Jul-14 9:07am    
Too bad the documentation you link to is totally incomprehensible. You're supposed to return a brush for drawing text? Does this control the background color or the text color? How does this relate to the fact that the button is supposed to be BS_OWNERDRAW anyway? It's enough to make a coder despair...
You need to subclass controls. Please read Create your own controls - the art of subclassing[^]
 
Share this answer
 

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