I am having trouble changing the font in a CRichEditCtrl (created as a child window). When I tried to use the CRichEditControl's SetDefaultCharFormat() function, no matter what I did to it, the font always remained at an 8 point system font (I *was* setting the mask). Next I tried to use the window's SetFont() function to set the font. Now here comes the weird part:
When I use the SetFont() function before I use SetDefualtCharFormat() (which I am still using for other details, such as color) AND I have the mask's CFM_SIZE flag set, then SetFont correctly changes the font to what I defined. However, there are some weird things that happen in this situation. Mainly, if I use GetDefaultCharFormat() again, the font name is correct in the structure, but the yHeight variable is some huge number (eg. with a 9 point Arial font the yHeight is 105, with 20 point it is 255). I am not sure if there is a relation between the two at all, but I assume since it changes with it, that there is.
On the other hand, if I do not set the CFM_SIZE flag, or I call SetDefaultCharFormat() with the other changes (color, etc.) the font point seems to be extremely offset by something (9 point font is barely legible, 15 point is about the size 9 should be).
This problem has been bugging me for about a week now, and I can find no answers on newsgroups or other message boards. Along with this I would like to ask what the formula is (if there is one) for obtaining the size the edit box should be to allow full space for all the chars (plus a couple pixels above and below). Please help.