Jump to content
  • Advertisement
Sign in to follow this  

[.net] Moving on the Screen buffer

This topic is 5198 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:

public class RECT
public Int32 left;
public Int32 top;
public Int32 right;
public Int32 bottom;

private static extern int ScrollWindowEx(
System.IntPtr hWnd,
int dx,
int dy,
RECT prcScroll,
RECT prcClip,
System.IntPtr hrgnUpdate,
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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!