• Image on an Image (VB6 SP5)

    Author
    Topic
    #370988

    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

    Viewing 1 reply thread
    Author
    Replies
    • #588526

      Is this in a userform or in a document?

    • #588570

      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

    Viewing 1 reply thread
    Reply To: Image on an Image (VB6 SP5)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: