Sendcommand

G

Gary Brizard

OK. Why wont' the folowing code cause a richtextbox to scroll down?

Declare Auto Function SendMessage Lib "User32.dll" (ByVal hwnd As Long,
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Point) As Long
Const WM_USER = 1024

Const EM_SETSCROLLPOS = WM_USER + 222

Private Function DoesNotWork()

Dim pt As New Point

Dim hWnd As Long = Me.RichTextBox1.Handle.ToInt32

pt.X = 0

pt.Y = 12

Dim l As Long = Win32.SendMessage(Me.RichTextBox1.Handle.ToInt32,
EM_SETSCROLLPOS, 0, pt)

End Function
 
A

Armin Zingler

Gary Brizard said:
OK. Why wont' the folowing code cause a richtextbox to scroll
down?

Declare Auto Function SendMessage Lib "User32.dll" (ByVal hwnd As
Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As
Point) As Long
Const WM_USER = 1024

Const EM_SETSCROLLPOS = WM_USER + 222

Private Function DoesNotWork()

Dim pt As New Point

Dim hWnd As Long = Me.RichTextBox1.Handle.ToInt32

pt.X = 0

pt.Y = 12

Dim l As Long =
Win32.SendMessage(Me.RichTextBox1.Handle.ToInt32,
EM_SETSCROLLPOS, 0, pt)

End Function

1. Enable Option Strict
2. Declaration of SendMessage is wrong. Replace hWnd by Intptr, other Longs
by Integer.
 
H

Herfried K. Wagner [MVP]

Hello,

Gary Brizard said:
OK. Why wont' the folowing code cause a richtextbox to
scroll down?

Declare Auto Function SendMessage Lib "User32.dll" (ByVal hwnd As Long,
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Point) As Long

Untested:

\\\
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr,
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByRef lParam As POINTAPI _
) As Int32

Public Structure POINTAPI
Public x As Int32
Public y As Int32
End Structure
///
Const WM_USER = 1024

Const EM_SETSCROLLPOS = WM_USER + 222

Declare all of the constants above "As Int32".

HTH,
Herfried K. Wagner
 
H

Herfried K. Wagner [MVP]

Hello,

Gary Brizard said:
Thanks,

Is there an api viewer equivelent like in vb6?

VS.NET doesn't come with an API viewer. Nevertheless, you may find some API
viewers on the web. Notice that most of them will produce wrong
declarations for .NET.

Regards,
Herfried K. Wagner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top