In Visual Basic 6 we use the GetFirstVisible API to check if all the text in a Textbox is visible. We then decrease the font size until all text is visible.
We are looking to accomplish the same thing in Visual Basic 2008, in a Rich Textbox.
Attached is the Procedure we use to check if the font is too big to fit in the text box. If the procedure returns "True" then we make the font smaller and we call the Procedure again.
We would really prefer something like an "AutoFit" feature (like labels have), if this is possible.
Public Function FontTooBig(obj As Object) As Boolean
Dim WindowHandle As Long
WindowHandle = obj.hwnd
obj.Selection.Range.StartPos = Len(obj.Text)
LinesNotVisible = SendMessage(WindowHandle, EM_GETFIRSTVISIBLELINE, 0, 0)
If LinesNotVisible <> 0 Then
FontTooBig = True
FontTooBig = False