Question How does zoom function work?

irreversible1983

New member
Joined
Aug 15, 2010
Messages
2
Programming Experience
Beginner
Hi,
I have an image with a button for zoom on it. I want to zoom-in and zoom-out the image with mouse scrolling up and down, right and left. Can anyone help me with some example to understand how this can be done?
Thanks.
 
There is no zoom functionality built in. What I would suggest is that you add a Panel to your form and then add a PictureBox to the Panel. You would start with the two the same Size and set the AutoScroll property of the Panel to True. You'll also want to set the SizeMode of the PictureBox appropriately; probably to Zoom. Now, if you change the Size of the PictureBox, the user will still only be able to see the area defined by the Panel, so their viewing area will remain the same, but the Image in the PictureBox will get bigger or smaller. The Panel will also create scroll bars automatically to facilitate panning.

Just note that, when you change the Size of the PictureBox, it will grow or shrink with the top, left corner as the origin. As such, you'll probably want to change the Location too, to make the centre of the Panel act as the origin. To do that, you should actually set both at the same time, which means setting the Bounds property or calling the SetBounds method.
 
How does zoom function work in VB.Net?

Thanks for replying. Do you have a sample code with you for this functionality? I am a beginner in VB and would need to see some example for the same. Great Thanks !
 
Did you make an attempt? How do you know that you can't do it if you haven't tried? You may not be able to get the whole thing done on your own, but I'm sure that you can add a couple of controls and set a few properties. The only difficult part is the actual resizing, but even that part you could at least try. If you aren't able to do any particular part for yourself then by all means let us know what you've done and what exactly you're stuck on and we can help. If you aren't able to do anything at all for yourself then this project is clearly to difficult for you and you should put it on the shelf until you've learned a bit more. I'm not trying to discourage you. Quite the opposite. Having someone else write your code for you is no way to learn. I want to you to learn how to program and the only way to do that is to program. If you want examples then search the web because there are tons of examples out there already. If you want the code for this particular problem then start thinking. I'm more than happy to help you with specific issues.
 
Back
Top