Need ScrollWindowEx Calling Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Scott Gunn

    #1

    Need ScrollWindowEx Calling Help

    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("use r32.dll")> _
    Public Shared Function ScrollWindowEx( ByVal hWnd As IntPtr, ByVal dx As
    Integer, ByVal dy As Integer, <MarshalAs(Unma nagedType.Struc t)> ByVal
    prcScroll As Rectangle, <MarshalAs(Unma nagedType.Struc t)> ByVal prcClip As
    Rectangle, ByVal hrgnUpdate As IntPtr,
    <System.Runtime .InteropService s.Out(), MarshalAs(Unman agedType.Struct )>
    ByRef prcUpdate As Rectangle, <MarshalAs(Unma nagedType.U4)> ByVal flags As
    Integer) As Integer
    End Function
    End Class

    Private Sub barScroll_Scrol l(ByVal sender As System.Object, ByVal e As
    System.Windows. Forms.ScrollEve ntArgs) Handles barScroll.Scrol l
    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.ScrollWin dowEx(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.LastDllErro r returns 993 which means Invalid access to memory location.

    If I change this:
    Dim rr As Integer = Win32.ScrollWin dowEx(Handle, 0, 10, rtin, rt,
    IntPtr.Zero, rtout, 0)

    To this:
    Dim rr As Integer = Win32.ScrollWin dowEx(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


Working...