I'm struggling with something that, in my opinion, should be easy (ish). I have a window shape and a flowgridlayout panel at the bottom of the form. Inside this form, I dynamically populate it with the X-number of user controls. The controls are of the same type.
The goal is when the user hovers over the user control, it opens another shape and positions it where the mouse is. When the mouse leaves the form, the open form disappears.
It is almost excellent. The problem is that the user control has something like a shortcut or text field inside it. It is believed that he left UC, so the form disappears.
My thought was to use X and Y to determine if it is inside UC, but I cannot figure it out.
May I ask:
1) What is the best approach to this? 2) How can I encode it, since UCs are dynamic, I cannot know exactly where they will be.
thanks
EDIT
I am trying to understand mouse pointers but not getting there. The code below is in the UC SmallTagBox_MouseLeave event:
Point loc = this.Location; Point p = this.PointToScreen(this.Location); Point p2 = this.PointToScreen(this.Parent.Location); Point ms = MousePosition; Rectangle screenBounds = new Rectangle(this.PointToScreen(this.Location), this.Size); if (!screenBounds.Contains(ms)) { thw.Close(); thw = null; }
- loc {X = 275 Y = 3} System.Drawing.Point
- p {X = 808 Y = 908} System.Drawing.Point
- p {X = 808 Y = 908} System.Drawing.Point
- p2 {X = 545 Y = 1542} System.Drawing.Point
- ms {X = 574 Y = 914} System.Drawing.Point
- screenBounds {X = 808 Y = 908 Width = 62 Height = 29} System.Drawing.Rectangle
I do not understand how p2 (its parent) can have a larger Y value relative to the screen.
source share