【发布时间】:2020-09-30 05:55:48
【问题描述】:
我的目的是减少 Opacity onDeactivate 事件,因为表单具有“留在顶部”设置。
我试过这样做:
protected override void OnDeactivate(EventArgs e)
{
base.OnDeactivate(e);
Opacity = 0.7;
}
一切正常(我单击另一个窗口,我的表单的不透明度降低),直到我关闭表单。如果我关闭表单,我会收到此错误:
System.ComponentModel.Win32Exception (0x80004005):参数不正确 在 System.Windows.Forms.Form.UpdateLayered() 在 System.Windows.Forms.Form.set_Opacity(双值) 在 C:\Users\lrena\source\repos\Hazar\Hazar\Form1.cs:riga 中的 Hazar.Form1.OnDeactivate(EventArgs e) 中 在 System.Windows.Forms.Form.set_Active(布尔值) 在 System.Windows.Forms.Form.WmActivate(Message&m) 在 System.Windows.Forms.Form.WndProc(Message&m) 在 C:\Users\lrena\source\repos\Hazar\Hazar\Form1.cs:riga 81 中的 Hazar.Form1.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&m) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
【问题讨论】:
标签: c# event-handling