I enjoyed Joel Paula’s “Scrollable Viewport for a Picture” tip [“101 Tech Tips for VB Developers,” Supplementto the February 1997 issue of VBPJ, page 12], and I’d like to make some improvements to it. First, make thescrollbar’s Scroll event update the picture position so it moves while you drag the scroll box. Second, declarethese form level variables:
Dim StartX As Long, StartY As LongDim Moving As Boolean
Finally, declare these three events for PicPicture:
Private Sub PicPicture_MouseDown_ (Button As Integer, Shift As _ Integer, x As Single, y As Single) StartX = x StartY = y Moving = TrueEnd SubPrivate Sub PicPicture_MouseMove_ (Button As Integer, Shift As _ Integer, x As Single, y As Single) If Moving Then PicPicture.Move _ PicPicture.Left + x - _ StartX, PicPicture.Top + _ y - StartY End IfEnd SubPrivate Sub PicPicture_MouseUp_ (Button As Integer, Shift As _ Integer, x As Single, y As Single) Moving = FalseEnd Sub
Now you can scroll the image with your mouse. Don’t forget to test for the borders of the image.
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.
Related Posts
- Quickly Test a Block of Code in .NET
- Report: Average Application Has 24 Vulnerabilities Due to Flawed Components
- Embarcadero Brings Millions of C++ and Delphi Developers to Windows 10 with its Latest RAD Product Release
- Asus Zenbook 14 OLED: Vibrant Display Meets Powerful Performance
- Senate considers bills impacting software patents
























