question

ARC-0178 avatar image
0 Votes"
ARC-0178 asked XingyuZhao-MSFT commented

Slide 2 scrollbars at same time with different values

I use this simple code to move 2 scrollbars of different Richtextboxes at same time, the trouble comes when one of them has more longer text, any suggestion? how I can get and implement the percentage to reach the second position start/middle/ending equivalent position at same time??



  1. Const EM_GETSCROLLPOS As Integer = WM_USER + 221

  2. Const EM_SETSCROLLPOS As Integer = WM_USER + 222

  3. Declare Function SendMessage Lib "user32.dll" Alias "SendMessageW" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As Point) As Integer

  4. Private Sub RichTextBox1_VScroll(sender As Object, e As EventArgs) Handles RichTextBox1.VScroll

  5. Dim pt As Point

  6. SendMessage(RichTextBox1.Handle, EM_GETSCROLLPOS, 0, pt)

  7. SendMessage(RichTextBox2.Handle, EM_SETSCROLLPOS, 0, pt)

  8. End Sub

  9. Private Sub RichTextBox2_VScroll(sender As Object, e As EventArgs) Handles RichTextBox2.VScroll

  10. Dim pt As Point

  11. SendMessage(RichTextBox2.Handle, EM_GETSCROLLPOS, 0, pt)

  12. SendMessage(RichTextBox1.Handle, EM_SETSCROLLPOS, 0, pt)



dotnet-visual-basic
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers