The
SetScrollPos
just does that. Wont update the window.
You can use the
SendMessage()
function to get/set scroll position. Here's the interop
Private Declare Auto Function RtfScroll _
Lib "user32.dll" Alias "SendMessage" ( _
ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As IntPtr, _
ByRef lParam As System.Drawing.Point) As Integer
Private Const WM_USER = &H400
Private Const EM_GETSCROLLPOS = WM_USER + 221
Private Const EM_SETSCROLLPOS = WM_USER + 222
Eg to set scroll position to x=0, y =100
RtfScroll(RichTextCtl.Handle, EM_SETSCROLLPOS, 0, New System.Drawing.Point(0, 100))
To get scroll position
Dim pt As New System.Drawing.Point()
RtfScroll(rt.Handle, EM_GETSCROLLPOS, 0, pt)
==============================
There's another simpler way to achieve this without using interop.
To do it,
1. Place the cursor at the appropriate position by setting the
SelectionStart
property's value and setting the SelectionLength to zero.
2. call the
ScrollToCaret()
function to scroll to the caret