Hello
I'm trying to scroll a region of graphics, the best way I can see is to use
the ScrollWindowEx API because it is designed for doing this
However it doesn't work correctly, Why?
Here is my code:
Public Class Win32
<DllImport("user32.dll")> _
Public Shared Function ScrollWindowEx(ByVal hWnd As IntPtr, ByVal dx As
Integer, ByVal dy As Integer, <MarshalAs(UnmanagedType.Struct)> ByVal
prcScroll As Rectangle, <MarshalAs(UnmanagedType.Struct)> ByVal prcClip As
Rectangle, ByVal hrgnUpdate As IntPtr,
<System.Runtime.InteropServices.Out(), MarshalAs(UnmanagedType.Struct)>
ByRef prcUpdate As Rectangle, <MarshalAs(UnmanagedType.U4)> ByVal flags As
Integer) As Integer
End Function
End Class
Private Sub barScroll_Scroll(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ScrollEventArgs) Handles barScroll.Scroll
Dim rt As Rectangle = New Rectangle
Dim rtout As Rectangle = New Rectangle(0, 0, 10, 10)
Dim rtin As Rectangle = New Rectangle(20, 20, 100, 100)
Dim rr As Integer = Win32.ScrollWindowEx(Handle, 0, 10, rtin, rt,
IntPtr.Zero, rtout, 0)
End Sub
rr is the return from the ScrollWindowEx function and this returns 0 but
nothing happens on the screen.
err.LastDllError returns 993 which means Invalid access to memory location.
If I change this:
Dim rr As Integer = Win32.ScrollWindowEx(Handle, 0, 10, rtin, rt,
IntPtr.Zero, rtout, 0)
To this:
Dim rr As Integer = Win32.ScrollWindowEx(Handle, 0, 10, rectangle.empty,
rectangle.empty, IntPtr.Zero, rectangle.empty, 0)
the whole screen scrolls as it should do, which kinda says the parameters
are wrong.
Can anyone help?
Scott