Home All Groups Group Topic Archive Search About
Author
6 Oct 2006 3:41 PM
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?

Author
6 Oct 2006 7:08 PM
Steve Long
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

Show quoteHide quote
"Charlie Brown" <cbr***@duclaw.com> wrote in message
news:1160149269.696373.105170@k70g2000cwa.googlegroups.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?
>
Author
6 Oct 2006 10:15 PM
Charlie Brown
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:
Show quoteHide quote
> 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" <cbr***@duclaw.com> wrote in message
> news:1160149269.696373.105170@k70g2000cwa.googlegroups.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?
> >
Author
6 Oct 2006 10:31 PM
Steve Long
Charlie,
Take a look at this:
http://msdn.microsoft.com/msdnmag/issues/04/01/AdvancedBasics/

Show quoteHide quote
"Charlie Brown" <cbr***@duclaw.com> wrote in message
news:1160172912.346014.180070@h48g2000cwc.googlegroups.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" <cbr***@duclaw.com> wrote in message
>> news:1160149269.696373.105170@k70g2000cwa.googlegroups.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?
>> >
>
Author
8 Oct 2006 4:48 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Charlie Brown" <cbr***@duclaw.com> schreef in bericht
news:1160172912.346014.180070@h48g2000cwc.googlegroups.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" <cbr***@duclaw.com> wrote in message
>> news:1160149269.696373.105170@k70g2000cwa.googlegroups.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?
>> >
>