Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Moving Buttons on panel, not overlay

Posted on 2007-03-30
5
257 Views
Last Modified: 2013-11-07
Hello

I want to move several buttons on a panel. Thats working correctly.
But while moving I want to check if on the new place, there is alreasy a button.
I am using Mousemove, so it should check at every mousemove event, if the button I want to move will be on the top of another button...

How can I do that?

Thanks

Sven
0
Comment
Question by:Ruttensoft
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:dctuck
ID: 18822455
If you are moving Button1, and want to check if it is over Button2, you could use:

If Button1.ClientRectangle.IntersectsWith(Button2.ClientRectangle) Then
....
End If

This checks the whole of the Button1 rectangle to see if any point in it overlaps Button2's area
0
 

Author Comment

by:Ruttensoft
ID: 18822459
Thanks.
I will have 40 controls, 20 buttons and 20 picturebox. Is it possible to check for all other 39 controls very fast?
0
 
LVL 7

Expert Comment

by:dctuck
ID: 18822461
Sorry - change ClientRectangle to Bounds, so:

If Button1.Bounds.IntersectsWith(Button2.Bounds) Then
....
End If

My mistake...
0
 
LVL 7

Accepted Solution

by:
dctuck earned 500 total points
ID: 18822472
This should work:

        For Each myControl As Control In Me.Controls
            If TypeOf (myControl) Is Button Then
                If Button1.Bounds.IntersectsWith(myControl.Bounds) Then
                    ......
                End If
            End If
        Next
0
 

Author Comment

by:Ruttensoft
ID: 18822476
thanks a lot
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question