Solved

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

Posted on 2009-05-14
5
183 Views
Last Modified: 2012-05-07
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
Comment
Question by:Dov_B
  • 4
5 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24390107
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
 
LVL 39

Expert Comment

by:abel
ID: 24390118
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
 
LVL 39

Expert Comment

by:abel
ID: 24390276
glad it helped :)
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24390285
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
 
LVL 39

Expert Comment

by:abel
ID: 24391154
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now