I'm trying to add verticall scrollbar to my CEdit-inherited control which should appear only if it's needed. The obvious startegy I'm using is to determine whether text height is larger than control's height. I've found few examples of such a task here and in SO post Any way to retrieve text height, in pixels, of text within a CEditBox?. In both examples the height of text is determined as linesCount * lineHeight. However I has a text that doesn't contain line breaks, for example:
CString text = L"Hello Hello Hello /*few more times*/ Hello Hello Hello";
In that case CEdit::GetLinesCount method always returns 1 despite it has an ES_MULTILINE style option (and horizontal scrollbar is off). So, how can I find whether I need vertical scrollbar or not?
With the hint of IInspectable I ended up using the
DrawTextmethod, however at least my variant is not precise - it gives bigger height than actually needed: