This is a migrated thread and some comments may be shown as answers.

Setting the Opacity of a ShapedForm on MouseEvents?

1 Answer 35 Views
ShapedForm
This is a migrated thread and some comments may be shown as answers.
Robert LeGood
Top achievements
Rank 1
Robert LeGood asked on 22 Jun 2012, 08:48 PM
Hey all,

I have a shaped form that I'm opening from within my main form.   I'd like the form to automatically be opaque, when the mouse leaves the bounds of the form so that the user can look under it.  Here's the simple code so far...

public myShapedForm()
{
    InitializeComponent();
    this.Opacity = .5;
}
 
private void myShapedForm_MouseEnter(object sender, EventArgs e)
{
    this.Opacity = 1;
}
 
private void myShapedForm_MouseLeave(object sender, EventArgs e)
{
    this.Opacity = .5;
}

I'm happy to see that setting the opacity of the form also sets the opaticy of the child controls, but....

The only issue I'm finding is that the MouseEnter only works if I'm hovering directly on the form with no other controls in the way.  (ie. If I have a GroupBox on the form, it doesn't work, nor does it work if I hover over the titlebar.

Is there a different Event that I should be using or, should I be looking for something like the "NotifyParentOnMouseInput" property that I've seen on some Rad Controls, but I haven't seen those for the controls I'm using.  (RadGroupBox, RadTextBox, etc.)

Thanks for your help!!

Rob.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 27 Jun 2012, 04:06 PM
Hello Robert,

RadControls inherit from Control and ShapedForm inherits from Form, so here it is a matter of the possibilities that the Windows Forms part of .NET Framework can provide. Luckily, in this case there is API that can help you achieve your requirement. I am attaching a sample project which demonstrates the approach.

I hope this helps.

All the best,
Nikolay
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
ShapedForm
Asked by
Robert LeGood
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or