Results 1 to 4 of 4

Thread: Testing for image over image

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    New Romney, Kent, UK
    Posts
    232

    Cool Testing for image over image

    Hiya peeps,
    I wonder if you can help,
    I have a number of images placed on a form by drag and dropping them. They are repositioned by snaping to a certain area , and as long as you move them within this designated area, everything is fine.

    However when rushing I can click on the image and it will snap to the designated area, but may go over or under an existing image.
    As the images are selectively counted, it can cause problems by counting extra items placed on top of others.

    Is there a way of detecting an image on top of another?


  2. #2

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    New Romney, Kent, UK
    Posts
    232

    Re: Testing for image over image

    I thought of checking the .top of every imageholder, but am not sure if this is the way to go? it seems like a lot of looping

  3. #3
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Testing for image over image

    vb Code:
    1. Private Function Overlapped(pObj1 As Object, pObj2 As Object) As Boolean
    2.     If ((pObj1.Top + pObj1.Height >= pObj2.Top And _
    3.               pObj1.Top <= (pObj2.Top + pObj2.Height)) And _
    4.              (pObj1.Left <= pObj2.Left + pObj2.Width And _
    5.               pObj1.Left + pObj1.Width >= pObj2.Left)) Then
    6.         Overlapped = True
    7.     End If
    8. End Function
    Then you can use it like this
    vb Code:
    1. If Overlapped(Image1, Image2) Then
    2.       'Overlap, do Something here
    3. End If

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    New Romney, Kent, UK
    Posts
    232

    Re: Testing for image over image

    Great thanks, but it's still a case of taking each image in turn and testing it against all the others, every time I move one, isn't it?

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