'=========================================================================== ' Subject: SCROLLABLE VIEWPORT FOR PICTURE Date: 03-13-99 (19:15) ' Author: Joel Paula Code: VBWIN ' Origin: CapeCanaveral/Lab/1961/ Packet: VBWIN.ABC '=========================================================================== Scrollable Viewport for a Picture It's easy to make a scrollable viewport for a picture in both VB3 VB4. In addition to a picture, you can also use other objects that grow. First, create a new form. Place a picture box on the form, name it "picParent," and resize it. This will be the viewport. Place a picture box inside the other picture box (picParent) and name it "picPICTURE." The value of the Left and Top properties must be zero. This one will contain the picture you want to view. Next, place a vertical scrollbar on the right of the picParent Picture. Name it "vsbPict." This scrollbar should have the same Top and Height values as picParent. Do the same with a horizontal scrollbar. Place it on the bottom of "picParent"-the Left and Width values should be equal to picParent. Name it "hsbPic." In both scrollbars, set the LargeChange property to the height and width of picParent, respectively. Then place this code on the declarations section of Form1. You can also copy this code to the Scroll event: Private Sub hsbPIC_Change() picPicture.Left =hsbPIC.Value End Sub Private Sub vsbPIC_Change() picPicture.Top =vsbPIC.Value End Sub Private Sub picPicture_Resize() If picPicture.Height > picParent.Height Then vsbPIC.Max =picParent.Height - picPicture.Height Else vsbPIC.Max = 0 End If If picPicture.Width > picParent.Width Then hsbPIC.Max =picParent.Width - picPicture.Width Else hsbPIC.Max =0 End If vsbPIC.Value = 0 hsbPIC.Value = 0 End Sub Every time you load a new picture, the scrollbars will adjust to its size. Write the code to load the pictures, and write other code to deal with exceptions to the rules. -Joel Paula, Carcavelos, Portugal