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

烂漫一生 提交于 2021-02-18 15:03:15

问题


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.


回答1:


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.




回答2:


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.




回答3:


For a standard edit control, handle the WM_CTLCOLOREDIT message to set the text and background colours.



来源:https://stackoverflow.com/questions/8994992/how-do-i-change-the-font-of-a-control-in-winapi-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!