By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,304 Members | 2,052 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,304 IT Pros & Developers. It's quick & easy.

Overlapping controls

P: n/a
I have a form with 2 custom controls that can be dragged around by a
user. How can I check if they overlap each other without performing
some kind of Collision detection on them? Is there anything in GDI to
check for overlapping controls?

Oct 6 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Yes, it's called math.
If one of the controls' left property is < another controls' left property +
it's width property, guess what, the former is overlapping the latter (in
checking for the x location only). Do the math for the rest.

HTH
Steve

"Charlie Brown" <cb****@duclaw.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
>I have a form with 2 custom controls that can be dragged around by a
user. How can I check if they overlap each other without performing
some kind of Collision detection on them? Is there anything in GDI to
check for overlapping controls?

Oct 6 '06 #2

P: n/a
Thank you for your sarcastic reply Steve. Some of my controls are not
rectangles, so checking for overlaps using math becomes a bit more
complex than simple addition. I was looking to see if there was
something built into the framework that already did the check, for
example, checking z order on overlapping controls or something similar.
I have done collision detection classes before, but looking for an
existing solution before beginning is usually the more productive way
to code software.

In the future when you reply to someone, curb the sarcasm, and put some
thought into your answer. Although I didn't mention whether I was
testing for rectangles or not, you could have asked.
Steve Long wrote:
Yes, it's called math.
If one of the controls' left property is < another controls' left property +
it's width property, guess what, the former is overlapping the latter (in
checking for the x location only). Do the math for the rest.

HTH
Steve

"Charlie Brown" <cb****@duclaw.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
I have a form with 2 custom controls that can be dragged around by a
user. How can I check if they overlap each other without performing
some kind of Collision detection on them? Is there anything in GDI to
check for overlapping controls?
Oct 6 '06 #3

P: n/a
Charlie,
Take a look at this:
http://msdn.microsoft.com/msdnmag/is...dvancedBasics/

"Charlie Brown" <cb****@duclaw.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Thank you for your sarcastic reply Steve. Some of my controls are not
rectangles, so checking for overlaps using math becomes a bit more
complex than simple addition. I was looking to see if there was
something built into the framework that already did the check, for
example, checking z order on overlapping controls or something similar.
I have done collision detection classes before, but looking for an
existing solution before beginning is usually the more productive way
to code software.

In the future when you reply to someone, curb the sarcasm, and put some
thought into your answer. Although I didn't mention whether I was
testing for rectangles or not, you could have asked.
Steve Long wrote:
>Yes, it's called math.
If one of the controls' left property is < another controls' left
property +
it's width property, guess what, the former is overlapping the latter (in
checking for the x location only). Do the math for the rest.

HTH
Steve

"Charlie Brown" <cb****@duclaw.comwrote in message
news:11**********************@k70g2000cwa.googleg roups.com...
>I have a form with 2 custom controls that can be dragged around by a
user. How can I check if they overlap each other without performing
some kind of Collision detection on them? Is there anything in GDI to
check for overlapping controls?

Oct 6 '06 #4

P: n/a
Charlie,

Overlapping controls is allowed, so it would be strange if there was a check
for that.

It is often used to hide controls or even more by using the splitter.

Cor

"Charlie Brown" <cb****@duclaw.comschreef in bericht
news:11**********************@h48g2000cwc.googlegr oups.com...
Thank you for your sarcastic reply Steve. Some of my controls are not
rectangles, so checking for overlaps using math becomes a bit more
complex than simple addition. I was looking to see if there was
something built into the framework that already did the check, for
example, checking z order on overlapping controls or something similar.
I have done collision detection classes before, but looking for an
existing solution before beginning is usually the more productive way
to code software.

In the future when you reply to someone, curb the sarcasm, and put some
thought into your answer. Although I didn't mention whether I was
testing for rectangles or not, you could have asked.
Steve Long wrote:
>Yes, it's called math.
If one of the controls' left property is < another controls' left
property +
it's width property, guess what, the former is overlapping the latter (in
checking for the x location only). Do the math for the rest.

HTH
Steve

"Charlie Brown" <cb****@duclaw.comwrote in message
news:11**********************@k70g2000cwa.googleg roups.com...
>I have a form with 2 custom controls that can be dragged around by a
user. How can I check if they overlap each other without performing
some kind of Collision detection on them? Is there anything in GDI to
check for overlapping controls?

Oct 8 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.