Overlapping controls

  • Thread starter Thread starter Charlie Brown
  • Start date Start date
C

Charlie Brown

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?
 
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
 
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.
 
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
 
Back
Top