Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Expertise: Intermediate
Aug 1, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Better Scrolling Images

I enjoyed Joel Paula's "Scrollable Viewport for a Picture" tip ["101 Tech Tips for VB Developers," Supplement to the February 1997 issue of VBPJ, page 12], and I'd like to make some improvements to it. First, make the scrollbar's Scroll event update the picture position so it moves while you drag the scroll box. Second, declare these form level variables:
Dim StartX As Long, StartY As Long
Dim 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 = True
End Sub

Private 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 If
End Sub

Private Sub PicPicture_MouseUp_
        (Button As Integer, Shift As _
        Integer, x As Single, y As Single)
                Moving = False
End Sub
Now you can scroll the image with your mouse. Don't forget to test for the borders of the image.
Pedro Prospero
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date