RichTextBox - Scroll vs. page issue
Hello all.
I made this great property that (seems) to work as expected:
Code:
<Browsable(False), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public Property ScrollPosition() As Point
Get
SendMessage(Me.Handle, EM_GETSCROLLPOS, 0, ScrollPosition)
End Get
Set(ByVal value As Point)
SendMessage(Me.Handle, EM_SETSCROLLPOS, 0, value)
End Set
End Property
But when I need to scroll the vertical bar to a value higher than 65536 it starts to behave the wrong way. For example, this causes the control to jump up:
Code:
ScrollPosition = ScrollPosition
EDIT
http://www.vbmonster.com/Uwe/Forum.a...ling-incorrect
But how to convert it to work with my code...
Code:
Private Function CorrectScrollPosY(ByVal Index As Long, ByVal lngNewScrollPos As Long) As Long
If (lngPixelCntY(Index) > 65535) Then
CorrectScrollPosY = CLng(CDbl(lngNewScrollPos) * lngLineHeightPixels * rtbDiff(Index).LineCount / 65535.0#)
Else
CorrectScrollPosY = lngNewScrollPos
End If
End Function
Plus I can't scroll to a line; it must scroll by pixel. (to prevent a strange shaking when typing)
EDIT
Ok discovered the point structure contains two UShort values, not two integers at all! :o
I'll see if a custom structure works out. < Does not work out; same issue; system uses two UShorts :/
Thought of using the SCROLLINFO structure, but that API doesn't update the control...
OK I'm out of luck here. Any help greatly appreciated.