Sign in to follow this  

[.net] Moving on the Screen buffer

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Have you ever noticed that if you move a control or window, it doesn't redraw, but instead moves the stuff over? I was wonder how i can do the same thing via code... i want to move part of the screen on one of my controls, and only redraw the new part (for scrolling) Any ideas?

Share this post


Link to post
Share on other sites
Use P/Invoke to call ScrollWindowEx, like so:

[StructLayout(LayoutKind.Sequential)]
public class RECT
{
public Int32 left;
public Int32 top;
public Int32 right;
public Int32 bottom;
}

[DllImport("user32.dll")]
private static extern int ScrollWindowEx(
System.IntPtr hWnd,
int dx,
int dy,
[MarshalAs(UnmanagedType.LPStruct)]
RECT prcScroll,
[MarshalAs(UnmanagedType.LPStruct)]
RECT prcClip,
System.IntPtr hrgnUpdate,
[MarshalAs(UnmanagedType.LPStruct)]
RECT prcUpdate,
System.UInt32 flags
);

static uint SW_ERASE = 4;
static uint SW_INVALIDATE = 2;
static uint SW_SCROLLCHILDREN = 1;
static uint SW_SMOOTHSCROLL = 16;

public void Scroll ()
{
RECT src = new RECT();
src.left = 10;
src.top = 10;
src.right = 110;
src.bottom = 110;
ScrollWindowEx(this.Handle, -5, 0, src, null, IntPtr.Zero, null, 0 /*SW_ERASE + SW_INVALIDATE + SW_SCROLLCHILDREN*/);
}


Share this post


Link to post
Share on other sites

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this