开发者

C++ Windows font size question

First i'm using the windows api.

So I have an edit control, that needs to be able to fit 22 characters max. Currently only 12 fit with the font I'd like to use.

Is there any way to resiz开发者_开发技巧e the font well the user is typing to allow for more text to fit without creating a bunch of fonts?


Well, you could. Implement a message handler for EN_CHANGE so you know the text was changed. Use GetWindowDC and DrawTextEx with the DT_CALCRECT and DT_EDITCONTROL flags to measure the size of the text. Send WM_SETFONT to change the font for the control if it doesn't fit and repeat.

The user being pleased with the end result is however very unlikely.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜