Results 1 to 7 of 7

Thread: Alternative to scrolling in a picturebox...

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2003
    Posts
    62

    Alternative to scrolling in a picturebox...

    I came up with this to examine "up close" HiRes images from my Maps database. You can move the image around to see every part of it without going "out of bounds"
    Attached Files Attached Files
    Last edited by Promocom; Jun 1st, 2006 at 07:21 PM. Reason: Better title description

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Large images in small picturebox...

    you might want consider placing the second picture box within the first & then doing something like:
    VB Code:
    1. Private sX As Single, sY As Single
    2.  
    3. Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    4.     If Button = vbLeftButton Then
    5.         sX = X
    6.         sY = Y
    7.         Screen.MousePointer = vbSizePointer
    8.     End If
    9. End Sub
    10.  
    11. Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    12.     Dim lLeft As Long, lTop As Long
    13.     If Button = vbLeftButton Then
    14.         ' Restrict Left
    15.         lLeft = Picture2.Left + (X - sX)
    16.         If lLeft > 0 Then lLeft = 0
    17.         If lLeft < Picture1.ScaleWidth - Picture2.Width Then lLeft = Picture1.ScaleWidth - Picture2.Width
    18.         Picture2.Left = lLeft
    19.         ' Restrict Top
    20.         lTop = Picture2.Top + (Y - sY)
    21.         If lTop > 0 Then lTop = 0
    22.         If lTop < Picture1.ScaleHeight - Picture2.Height Then lTop = Picture1.ScaleHeight - Picture2.Height
    23.         Picture2.Top = lTop
    24.     End If
    25. End Sub
    26.  
    27. Private Sub Picture2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    28.     Screen.MousePointer = vbNormal
    29. End Sub
    30.  
    31. Private Sub Form_Load()
    32.     With Picture2
    33.         .Appearance = 0
    34.         .BorderStyle = 0
    35.         .AutoRedraw = True
    36.         .AutoSize = True
    37.         .Picture = LoadPicture(App.Path & "\map.jpg")
    38.         .Move (Picture1.ScaleWidth - .Width) \ 2, (Picture1.ScaleHeight - .Height) \ 2
    39.     End With
    40. End Sub
    It avoids the need for constant PaintPicturing.

    You'll probably want to get a mod to move this to the CodeBank.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2003
    Posts
    62

    Re: Large images in small picturebox...

    I tried your code bushmobile and I'm getting some weird "multiple image" effects while moving the image. Are there any property changes I should make to the controls?

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Large images in small picturebox...

    I made a PictureView control two years ago. I got bored of people asking for picture scrolling so I made this control

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Large images in small picturebox...

    I've attached an example.

    (i didn't bother including the picture in the attachment)

    Attached Files Attached Files

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Large images in small picturebox...

    I'll move this to the codebank, but could you pick a better title of the thread?


    Has someone helped you? Then you can Rate their helpful post.

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2003
    Posts
    62

    Re: Alternative to scrolling in a picturebox...

    Yes it works quite nicely bushmobile...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width