• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

how can I horizontaly scroll a very wide bitmap gif or whatever across the form

I have a bitmap that is to wide to display completely in the picture box how can I progromaticly scroll the picture within the picture box without the use of scroll bars
0
Dov_B
Asked:
Dov_B
  • 4
1 Solution
 
abelCommented:
This needed a bit experimenting to get it right. Esp. the redraw bit for once the image goes inside the rectangle of the Picture control. But here you go. This scrolls to the left in steps of 5 pixels. Make -5 into 5 to do the reverse: scrolling to right.

Dim bmpTemp As New Bitmap(picSourceLarge.Image)
Dim graph As Graphics = Graphics.FromImage(bmpTemp)
Dim aPen As New Pen(New SolidBrush(Color.White), picSourceLarge.Width)
 
' erase background with white
Dim rect As New Rectangle(0, 0, picSourceLarge.Width, picSourceLarge.Height)
graph.DrawRectangle(aPen, rect)
 
' draw scrolled to the left image in a -5 pixel step
graph.DrawImageUnscaled(picSourceLarge.Image, New Point(-5, 0))
picSourceLarge.Image = bmpTemp

Open in new window

0
 
abelCommented:
picSourceLarge in the code above is supposed to be your picture control on your form, having a picture that is too large, and without scrollbars.
0
 
abelCommented:
glad it helped :)
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Or you could just put the UNSCALED PictureBox inside a Panel (without AutoScroll) and then simply change the Location() Property of the PictureBox to move it around in there...
0
 
abelCommented:
haha, lol, funny. While I thought about it, all I thought of was the scrollbars, so I didn't even try. Of course you can remove them. Getting to late here. Was a nice exercise regardless and thanks for waking me up ;-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now