2

My Form has a problem with that GroupBbox MouseEvents.

I'm trying to make some GUI gadgetries (docking, opacity..).

Here is an example:

Picute

I've linked all (GUI)-Objects to these two functions.

private void MyMouseMove(object sender, MouseEventArgs e)
{
    this.Opacity = 1;
}

private void MyMouseLeave(object sender, EventArgs e)
{
    this.Opacity = 0.5;
}

..expect the group panels, because they don't have MouseMove and MouseLeave events. Can they be added? A standard Panel has them as well.

I really like the layout of that GroupPanels (with that border and text), that's why I would love to be able to solve that problem with GroupBox.

That gadgets I create will only be triggered, if the cursor is in- or outside the form. (doesn't matter if inactive or active). Maybe there is another way to trigger it, than MouseMove and MouseLeave.

Community
  • 1
  • 1
MrMAG
  • 1,194
  • 1
  • 11
  • 34
  • So you want to change opacity when a user enters/leaves a group box? – Cameron Tinker May 31 '13 at 15:15
  • 1
    GroupPanels, aka GroupBoxes, do have those mouse events. The problem is it will fire the MouseLeave event when the mouse enters one of the GroupBox's child controls. Using a timer is probably the best solution, see [Winform - determine if mouse has left user control](http://stackoverflow.com/a/425361/719186). – LarsTech May 31 '13 at 15:40

1 Answers1

0

Using a Timer is probably the simplest solution!
Thank you LarsTech for linking to this 'Winform - determine if mouse has left user control' question.

I'm able to continue my Project with this sample below.

public partial class Form1 : Form
{
    private Timer timer1;
    public Form1()
    {
        InitializeComponent();
        this.Opacity = 0.5D;
        timer1 = new Timer();
        timer1.Interval = 200;
        timer1.Tick += timer1_Tick;
        timer1.Enabled = true;
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        if (this.DesktopBounds.Contains(Cursor.Position))
            this.Opacity = 1D;
        else
            this.Opacity = 0.5D;
    }
}

credits goes to: Hans Passant

Community
  • 1
  • 1
MrMAG
  • 1,194
  • 1
  • 11
  • 34