• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

button color change

I use Button class to create a window.
I get the hwnd and I wnat to change the color of the button when I get the message WM_LBUTTIONDOWN.
How can I change the color?
Please in c++
Any comments will be helpful,thanks
  • 2
1 Solution
BabyworshipAuthor Commented:
Edited text of question.
r parkinsonCommented:
You need to process the WM_CTLCOLORBTN message.  This is quite well documented, but basically you just return the handle of the brush that you want to paint the background with. You program has to destroy the brush later though (e.g. when you destroy the window) otherwise you get a memory leek.
BabyworshipAuthor Commented:
So,I need sendmessage()?

HDC hdc=GetDC(hwnd);

I don't know what shuld I do next,how to change the color?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now