Hi,
This code (w/c programmatically scrolls a textbox) works in VB 6.0:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long)
Private Const EM_LINESCROLL = &HB6
Private Sub Command1_Click()
Dim result As Long
' Textbox should scroll after call below.
result = SendMessage(Text1.hwnd, EM_LINESCROLL, 0, 1)
End Sub
but the same code does not work in VB.NET:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long)
Private Const EM_LINESCROLL As Integer = &HB6
Dim result As Long
result = SendMessage(Textbox1.Handle.ToInt64, EM_LINESCROLL, 0, 1)
result for VB.NET code is always 0. Same happens if hwnd is defined as
IntPtr and Textbox1.Handle is passed to SendMessage. Help please?
Claes Bergefall - 20 Mar 2006 21:08 GMT
Wrong datatypes. Use this:
Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As
IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam
As Integer)
Private Const EM_LINESCROLL As Integer = &HB6
Dim result As Integer
result = SendMessage(Textbox1.Handle, EM_LINESCROLL, 0, 1)
> Hi,
>
[quoted text clipped - 26 lines]
> result for VB.NET code is always 0. Same happens if hwnd is defined as
> IntPtr and Textbox1.Handle is passed to SendMessage. Help please?
jester - 21 Mar 2006 02:08 GMT
Worked like a charm! Thanks, Claes :)
> Wrong datatypes. Use this:
>
[quoted text clipped - 37 lines]
> > result for VB.NET code is always 0. Same happens if hwnd is defined as
> > IntPtr and Textbox1.Handle is passed to SendMessage. Help please?