non-rectangular controls on a form - how to detect mouse events
Posted on 2002-06-06
I am building an application for viewing entities and relationships, and something that I expected to be trivial has instead been a very interesting problem.
Practically, the application GUI consists of a master form that contains other forms (representing entities) and a custom control that draws a line connecting two forms (representing associations).
The Delphi TControl methods that detect a mouse event are built on the assumption that all controls are rectangular. On a screen showing a master entity and 50 owned entities with their relationships, I have 50 lines at varous angles extending from the master entity to the owned entities.
The math to detect whether a mouse click is on the line or not is trivial. What I haven't figured out is how to get the mouse click event past the topmost control in a stack of overlapping rectangles - ie the control asks "Are you inside of me? No -- let the next guy handle it" without creating an entirely new heirarchy from the TControl level down.
I can clone Borland's code and make the necessary changes (call it TFancyControl in the FancyControls unit if you like), but that seems like a kludge.
I am sure that this has been solved a hundred times, but my strength is in the business process rahter than in the GUI end of things.
Any assistance will be appreciated.
Thanks in advance.