?
Solved

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

Posted on 2009-05-14
5
Medium Priority
?
189 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

801 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