Results 1 to 6 of 6

Thread: Dragging a picture box while seeing its content.

  1. #1

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Post

    Hey all of you out there...

    How do I drag a picture box so when i am dragging, i see the picture box's picture ?


    ------------------
    ------
    God:
    ------
    Oh...those israeli programmers..!

  2. #2
    Junior Member
    Join Date
    May 2001
    Posts
    18

    Dragging while showing Picture Box contents

    The following code will work:

    Dim oldX As integer
    Dim oldY As Integer

    Private Sub PiecePic_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton Then
    oldX = X
    oldY = Y
    End If
    End Sub

    Private Sub PiecePic_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton Then
    PiecePic(Index).Top = PiecePic(Index).Top + (Y - oldY)
    PiecePic(Index).Left = PiecePic(Index).Left + (X - oldX)
    End If
    End Sub

  3. #3
    Zaei
    Guest
    It is probably better to store OldX and OldY as static variables inside of the MouseMove event. Keeps global variables down.

    Z.

  4. #4
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049
    And how would you cope with the oldX and oldY vars then if they are inside the sub since they don't keep their value (or share it) with the other sub.

    Looking at the that code thats the only simple way to do it =)

  5. #5
    Zaei
    Guest
    I dont know of any reason why you would want to use those values outside of that Sub. But, if you really wanted to share them with everyone, you could:
    Code:
    Type POINTAPI
         X as Long
         Y as Long
    End Type
    And store the values in that, so you dont take up a global variable name.

    Z.

  6. #6
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049
    Mmm.. yeah.. ok , effiency to tha max

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