I need to manipulate the contents of a textbox so that the last value can always been seen. How can I do this and do I need scrollbars to achieve this. Thanks.
Printable View
I need to manipulate the contents of a textbox so that the last value can always been seen. How can I do this and do I need scrollbars to achieve this. Thanks.
By "last value" you mean the last section of text , right?
There are a couple of Edit-box messages to do this kind of stuff. Check which suits you.
For ex. if you want to scroll the Caret position into view
' in declarations :
Const EM_SCROLLCARET = &HB7&
Const EM_SCROLL = &HB5&
Const EM_GETLINECOUNT = &HBA&
Const EM_LINESCROLL = &HB6&
private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(byval hwnd as Long, byval wMsg as Long, _
byval wParam as Long, lParam as Any) as Long
'
private Sub Text2_GotFocus()
' to scroll the caret into view:
SendMessage Text2.hwnd, EM_SCROLLCARET, 0, byval &H0&
' to show the last line, irrespective of the Caret position:
' SendMessage Text2.hwnd, EM_LINESCROLL, SendMessage(Text2.hwnd, EM_GETLINECOUNT, 0, 0), 0
End Sub
Be warned: that using it in _GotFocus like in this example would be a little funny to scroll to end each time!, it is not the right place...
If you set the Multiple=True and ScrollBars = 2 (Vertical) would be nice for that example.
RK