Setting the Opacity of a ShapedForm on MouseEvents?

2 posts, 0 answers
  1. Robert LeGood
    Robert LeGood avatar
    28 posts
    Member since:
    Dec 2007

    Posted 22 Jun 2012 Link to this post

    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()
        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!!

  2. Nikolay
    Nikolay avatar
    1805 posts

    Posted 27 Jun 2012 Link to this post

    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,
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top