Solved

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

Posted on 2009-05-14
5
184 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

16 Experts available now in Live!

Get 1:1 Help Now