Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the font of a control in WinApi C++?

Tags:

c++

winapi

How do I change the font of an edit control in win32 API. I would like to be able to edit the style as well as the color of a font on a edit control.

like image 549
Potent Venom Avatar asked Dec 22 '22 03:12

Potent Venom


2 Answers

First you should clarify that you're talking about a standard Edit control versus a Rich Edit control - the two are totally different.

You can change the font by sending a WM_SETFONT message to the edit control. Setting the color is a totally different process.

You can set the text color by responding to the WM_CTLCOLOREDIT message in the owner of the edit control.

like image 178
Mark Ransom Avatar answered Dec 24 '22 01:12

Mark Ransom


You can send it a WM_SETFONT message. Be warned, though, as the link explains, you may have to re-size the control after changing the font.

like image 34
Goz Avatar answered Dec 24 '22 03:12

Goz