Josh
Josh

Reputation: 6282

Owner draw the text of a button with the Windows API

I want to owner/custom draw the text of a button, but only the text (or the content). So I can render the button with multiple colored fonts.

If I handle WM_DRAWITEM I have to paint the entire button. I want to only paint the text.

Is there some API I can call to have windows paint the button without the text, and then I can paint the text myself?

Upvotes: 0

Views: 655

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 597500

You have to draw the entire button yourself. However, you can use the DrawFrameControl() function, or the DrawThemeParentBackground/Ex() and DrawThemeBackground/Ex() functions if CommCtrl v6 is enabled on XP+, to let Windows draw the button's background and borders for you. You can then draw your desired text on top of that.

Upvotes: 1

Related Questions