Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Indiana
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Image on an Image (VB6 SP5)

    I would like to place a small image on top of an image by coordinates. I know I can trap an images coordinates where it is clicked. What I would then like to do is place an image where the click occured. Does anyone know how I can accomplish this.

    Thanks in advance

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Image on an Image (VB6 SP5)

    Is this in a userform or in a document?

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Image on an Image (VB6 SP5)

    Perhaps you can adapt the following:

    The picture clicked on is Picture1. The picture to be placed on top is Picture2. Originally, it is hidden (Visible = False).

    Code:

    Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ' Center Picture 2 over position of MouseUp
    Picture2.Left = Picture1.Left + X - Picture2.Width / 2
    Picture2.Top = Picture1.Top + Y - Picture2.Height / 2
    ' Make sure that Picture2 is on top
    Picture2.ZOrder
    ' Make Picture2 visible
    Picture2.Visible = True
    End Sub

    You'll have to add code to handle clicking again. As it stands, Picture2 will be moved. If you don't want this, you can use a module level boolean variable to check whether Picture2 has been placed yet.

    If you want the top left corner of Picture2 placed at the MouseUp position, remove
    - Picture2.Width / 2
    and
    - Picture2.Height / 2

Posting Permissions

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