use an offscreen buffer the size of your control.
at first do it the simple way. Draw the entire offscreenbuffer scrolled to the correct position. When ready blit it to the actual screen.
If this is too slow, try to optimize it by not redrawing the entire offscreenbuffer but by making a vertical split: (I'm only talking about a horizontal scroll movement here for now to make the concept easier to grasp. But this method applies to 8 way scrolling as well)
this is somewhat tricky to implement (that's why I suggested the simple approach first), but try to imagine a paper with picture on it, and the left side you wrap around and glue it to the right side (so you get a tube). This way you can scroll the paper indefinitely (by rotating the tube around it's y axis).
similarly you can do the same with the offscreen buffer.Prepare the offscreen buffer by drawing the complete contents on it.
now to scroll to the right you basically split the offscreen buffer in 2 (by way of this vertical split (just like the paper in the example where the glue was)). suppose you scroll 10 pixels to the right, what you do is:
- copy the right hand side of the split (located at pixel 10) to pixel 0 of your control. (so the whole region from (10, 0) - (width - height) to: (0,0)
- then copy the left hand side of the split: pixel 0 to 10 to pixel width-10. so: (0,0)-(10,height) to (width-10, 0)
before you do this ONLY redraw the pixels which have been to be altered (in this case 10 pixels since we scrolled 10 pixels). All other pixels are still identical and don't need redrawing.
You'll have to draw this out on a paper yourself to really understand it. It is a quite common technique with game development on platforms where resources are limited (mobile phones etc).
p.s. scrolling in all directions can be achieved in the exact same way (although it's even harder to get right) ;^)