I am trying to find the scroll Position in a Rechtextbox control. but I am always getting 0,0 as the coordinate. The function SendMessage is always returning 0 which mean something is wrong. This function should return 1 which means successful execution. But somehow I am not getting the answer right. Can somebody help me what am I doing wrong here.


'Declaration in Form Module

Private Sub Command1_Click()
Dim udtScrollPos As tagPOINT
Dim lngWin32apiResultCode As Long

With RichTextBox1
lngWin32apiResultCode = _
SendMessage(.hwnd, _
EM_GETSCROLLPOS, _
0, _
udtScrollPos)
End With

With udtScrollPos
Label3.Caption = "(" & .x & "-" & .y & ")"
End With
End Sub


'Declaration in General Module

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 Const WM_USER As Long = &H400
Public Const EM_GETSCROLLPOS = WM_USER + 221

Type tagPOINT
x As Long
y As Long
End Type