Jump to content
  • Advertisement
Sign in to follow this  

[.net] Moving on the Screen buffer

This topic is 5019 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
Advertisement
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
I love you!!

Thanks alot! It helps alot and works perfectly... though if you put the smoothsctoll flag, it scrolls backwards... wierd..., but it's stoll great =)

Thanks bunches

*rates very helpful*

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!