Thanks for all the suggestions but what I am looking for are the number of
lines
that will be visible when the text is greater then the textbox can display.
In other words,
The textbox is a rectangle of a certain size and can only hold so many lines
of text
according to the font that is being used. How can I determine this?
The following code worked fine in visual basic 5 but with my limited
knowledge of
..net I am not sure how to change the API calls.
'
' Determines the number of lines actually visible in the
' text control.
'
'
Private Function GetVisibleLines%()
Dim rc As Rect
Dim hdc%
Dim lfont%, oldfont%
Dim tm As TEXTMETRIC
Dim di%
' Get the formatting rectangle - this describes the
' rectangle in the control in which text is placed.
lc% = SendMessage(Text1.hWnd, EM_GETRECT, 0, rc)
' Get a handle to the logical font used by the control.
' The VB font properties are accurately reflected by
' this logical font.
lfont% = SendMessageBynum(Text1.hWnd, WM_GETFONT, 0, 0&)
' Get a device context to the text control.
hdc% = GetDC(Text1.hWnd)
' Select in the logical font to obtain the exact font
' metrics.
If lfont% <> 0 Then oldfont% = SelectObject(hdc%, lfont%)
di% = GetTextMetrics(hdc%, tm)
' Select out the logical font
If lfont% <> 0 Then lfont% = SelectObject(hdc%, oldfont%)
' The lines depends on the formatting rectangle and font height
GetVisibleLines% = (rc.bottom - rc.Top) / tm.tmHeight
' Release the device context when done.
di% = ReleaseDC(Text1.hWnd, hdc%)
End Function