I have a C# form, primarily covered by panels. I put a red border around the form. This is the only visible part of the form. The panels visibly cover the rest of the form. Whenever I move my mouse over the form, the red border is the only part it recognizes as the form. If I move my mouse over the panels, which are also on the form, it doesn't recognize that the mouse is still over the form. Is there a way I can manipulate the form object so they will be considered as, "part of the form?"
Here is how I am trying to achieve this:
NOTE: this is a portion of the code I have. If you need more, I am surely willing to add it.
private void rightClickMenu_Paint(object sender, PaintEventArgs e)
{
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle,
Color.Red, 1, ButtonBorderStyle.Solid,
Color.Red, 1, ButtonBorderStyle.Solid,
Color.Red, 1, ButtonBorderStyle.Solid,
Color.Red, 1, ButtonBorderStyle.Solid);
}
private bool MouseInControl(Control ctrl)
{
mouseInControl = ctrl.ClientRectangle.Contains(PointToClient(Control.MousePosition));
if(mouseInControl)
{
rcmTimer.Stop();
rcmTimer.Interval = 500;
}
else
{
CustomForm.rightclickmenuform.Hide();
}
Console.WriteLine(mouseInControl);
return mouseInControl;
}
private void rightClickMenu_MouseEnter(object sender, EventArgs e)
{
MouseInControl(this);
}
private void rightClickMenu_MouseLeave(object sender, EventArgs e)
{
MouseInControl(this);
}
As I state earlier, they red border around the form is the only thing be detected by this event. Once you leave the border, the code considers you to be outside of the form, even if you aren't.
PS: I found this method from this question: https://stackoverflow.com/a/31157183/6804700