473,756 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Overlapping controls

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
4 3238
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.goo glegroups.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
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.goo glegroups.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
Charlie,
Take a look at this:
http://msdn.microsoft.com/msdnmag/is...dvancedBasics/

"Charlie Brown" <cb****@duclaw. comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.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.go oglegroups.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
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.goo glegroups.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.go oglegroups.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4971
by: Hmmm... | last post by:
Is there a way to control which controls appear to be "on top". For example a MaskEdBox shows up "on top" of a ComboBox when the 2 controls overlap, but a MaskedBox shows up "underneath" a DataCombo when 2 controls overlap. How can I force a MaskEdBox to show up "on top" of a DataCombo when whey overlap? Thanks.
11
4678
by: Max M | last post by:
I am writing a "find-free-time" function for a calendar. There are a lot of time spans with start end times, some overlapping, some not. To find the free time spans, I first need to convert the events into a list of non overlapping time spans "meta-spans". This nice ascii graph should show what I mean. 1) --- 2) ---
0
1505
by: Bruce | last post by:
Hello, Back in the Access 97 days, if I had two texboxes on a form or report that overlapped, and I selected both and did a Format, Align, Top from the menu in design view, the controls would align such that the top edge of one control would align with the bottom edge of the other and they would no longer overlap. I liked this behavior. Now, in Access 2003, performing the same actions in a similar situation causes the top edges of the...
0
1087
by: Edwin Knoppert | last post by:
I'm busy with overlapping controls, like the ASP net menu shown underneat the listbox control etc.. Absolute position is what i use in this case, no issue to me now. I found a menu on the following website: http://mguessan.free.fr/html/menu.html The items are being shown OVER a select control (MSIE problem)
0
976
by: UK Bob | last post by:
Hello, I have a selection of button controls that a user can drag and drop around a form. I need to find a way to stop these controls overlapping one another - very similar to how windows desktop works. I know I could use the math to work this out..... does anyone have any code for this or perhaps know a better way?
0
1018
by: Marc | last post by:
Hello, I have a selection of button controls that a user can drag and drop around a form. I need to find a way to stop these controls overlapping one another - very similar to how windows desktop works. I know I could use the math to work this out..... does anyone have any code for this or perhaps know a better way?...
2
1578
by: Tom | last post by:
Hi - I'd like to center two overlapping controls (i.e., have it so that the centers of the two controls are aligned vertically, horizontally or both). The Fomat:Align menu item doesn't support this. Any good solutions, or do I break out my calculator and do it manually? Access 2002 if it makes a difference. Thanks
5
7738
by: zacks | last post by:
I am having a strange issue with an application written in .NET 2.0. Actually it is in VB.NET but I think my problem is not language specific, but a .NET Framework issue. On a form I have a Combo Box populated with two items. There are two Group Boxes on the form with different sets of controls in each. They both are the same size and are located at the same place. Which Group Box is visible depends on the item selected in the combo box....
0
2847
by: richard12345 | last post by:
Hi Guys I have problem with site I am building. The sidebar with menu and other thinks is overlapping footer. The footer move with the content and but it dos it dos not move with the sidebar. Here is the website: holtz-realty And also the html file and css file. Anny help will by mostly appreciated. I did try everything I can think of. HTML:
0
9462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9287
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9886
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9857
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7259
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.