Solved

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

Posted on 2009-05-14
5
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 86

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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