Hello, HashCode, how to make it so that while the cursor is on the form, then the parameter
this.Opacity = 100; As soon as the cursor leaves the form, the parameter changes to
this.Opacity = 30; Hello, HashCode, how to make it so that while the cursor is on the form, then the parameter
this.Opacity = 100; As soon as the cursor leaves the form, the parameter changes to
this.Opacity = 30; For C # WinForms, MouseEnter and MouseLeave events:
private void Form1_MouseEnter(object sender, EventArgs e) { this.Opacity = 1; } private void Form1_MouseLeave(object sender, EventArgs e) { this.Opacity = 0.3; } What was offered to you with MouseEnter / MouseLeave is a bad decision. If you have controls on the form, then in the case of this decision, this situation may arise:
+---------------------------------+ | [Inner Control] | +---------------------------------+ Parent.OnMouseEnter (1.0) Parent.OnMouseLeave (0.3) Inner.OnMouseEnter (1.0) Inner.OnMouseLeave (0.3) Parent.OnMouseEnter (1.0) Parent.OnMouseLeave (0.3) A good solution involves inserting a dummy panel (and checking for MouseEnter / MouseLeave its boundaries) or MouseEnter / MouseLeave with message filtering.
Source: https://ru.stackoverflow.com/questions/100674/
All Articles