Click here to Skip to main content
13,446,366 members (36,670 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How do i change the text color of a PUSHBUTTON...??? Using Windows API.
Posted 31-Jan-12 7:37am
Updated 31-Jan-12 9:57am
SAKryukov 31-Jan-12 13:56pm
What language, API and UI library do you use? Tag it.
ryanb31 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 do i do that...???
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Read Microsoft documentation:[^]

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.
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...
Rate this: bad
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[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01-2016 | 2.8.180314.2 | Last Updated 31 Jan 2012
Copyright © CodeProject, 1999-2018
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