Click here to Skip to main content
11,417,240 members (53,569 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Windows API
How do i change the text color of a PUSHBUTTON...??? Using Windows API.
Posted 31-Jan-12 8:37am
Edited 31-Jan-12 10:57am
v3
Comments
SAKryukov at 31-Jan-12 13:56pm
   
What language, API and UI library do you use? Tag it.
--SA
ryanb31 at 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 at 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...???
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
iamrohitsingh at 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 at 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...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You need to subclass controls. Please read Create your own controls - the art of subclassing[^]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,295
1 OriginalGriff 7,592
2 Maciej Los 3,718
3 Abhinav S 3,456
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web01 | 2.8.150427.4 | Last Updated 31 Jan 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100