My Purpose is to reduce Opacity onDeactivate event because the form has the setting "Stay on Top".
I tried to do this :
protected override void OnDeactivate(EventArgs e)
{
base.OnDeactivate(e);
Opacity = 0.7;
}
All works perfectly (I click on another window and my form's opacity reduces) till I close the form. If I close the form, I get this error :
System.ComponentModel.Win32Exception (0x80004005): Parametro non corretto in System.Windows.Forms.Form.UpdateLayered() in System.Windows.Forms.Form.set_Opacity(Double value) in Hazar.Form1.OnDeactivate(EventArgs e) in C:\Users\lrena\source\repos\Hazar\Hazar\Form1.cs:riga 44 in System.Windows.Forms.Form.set_Active(Boolean value) in System.Windows.Forms.Form.WmActivate(Message& m) in System.Windows.Forms.Form.WndProc(Message& m) in Hazar.Form1.WndProc(Message& m) in C:\Users\lrena\source\repos\Hazar\Hazar\Form1.cs:riga 81 in System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) in System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) in System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)