C# “错误”;参数无效";当我最小化表单时
这些是我按下自定义最小化按钮时收到的错误消息C# “错误”;参数无效";当我最小化表单时,c#,visual-studio,C#,Visual Studio,这些是我按下自定义最小化按钮时收到的错误消息 System.ArgumentException HResult=0x80070057 Message=Parameter is not valid. Source=System.Drawing StackTrace: at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Bitmap.
System.ArgumentException
HResult=0x80070057
Message=Parameter is not valid.
Source=System.Drawing
StackTrace:
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)
at CircularProgressBar.CircularProgressBar.RecreateBackgroundBrush()
at CircularProgressBar.CircularProgressBar.ParentOnResize(Object sender, EventArgs eventArgs)
at System.Windows.Forms.Control.OnResize(EventArgs e)
at System.Windows.Forms.UserControl.OnResize(EventArgs e)
at System.Windows.Forms.Control.OnSizeChanged(EventArgs e)
at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
at System.Windows.Forms.Control.UpdateBounds()
at System.Windows.Forms.Control.WmWindowPosChanged(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
当我开始使用新的自定义控件时,我在尝试使用自定义按钮最小化时遇到了相同的错误。在查看详细的异常消息之前,我无法理解它 System.ArgumentException
HResult=0x80070057
消息=参数无效。
来源=系统图纸
StackTrace:
位于System.Drawing.Bitmap..ctor(Int32宽度、Int32高度、像素格式)
在System.Drawing.Bitmap..ctor(Int32宽度,Int32高度)
位于Bunifu.UI.WinForms.BunifuGradientPanel.Refresh()
位于Bunifu.UI.WinForms.BunifuGradientPanel.OnResize(EventArgs EventArgs) 这是新的BunifuGradientPanel,它以前工作得很好,整天都在最小化,但我离开VS几小时后,当我返回时,它开始出错。奇怪 我不确定,但我怀疑bunifuGradientPanel1没有正确处理自己 要解决它,只需这样做
public bool isMinimized = false;
private void iconButtonMinimize_Click(object sender, EventArgs e)
{
try
{
bunifuGradientPanel1.Dock = DockStyle.None; // Un-dock
this.WindowState = FormWindowState.Minimized;
isMinimized = true;
}
catch (Exception)
{
//...
}
}
private void Form1_Resize(object sender, EventArgs e)
{
if (isMinimized == true)
{
bunifuGradientPanel1.Dock = DockStyle.Top; // Re-dock
bunifuGradientPanel1.Width = panelDesktop.Width; // maintain desired width
isMinimized = false;
}
}
对于遇到相同错误但使用非Banifu控件的用户,只需执行与上面相同的操作,但将Dock替换为Visibility。控件未在最小化上渲染。因此,最小化时设置visible=false。调整大小时设置visible=true
对。。。今天早上我意识到这个错误发生在我的Banifu控件停靠时。如果未锁定,则不会发生错误。但我需要把我的靠岸
官方的BANIFU SUPPORT RESPONSE:Gradient面板正在调整大小,使其无法在最小化屏幕上渲染。我们将在下一个版本中对此most进行修复。很可能在下一版本中
很酷,但我已经修复了它。你在这个窗口上使用了图像吗?@GaurangDave yea,有一个图像。调试器向你展示了什么@BenFwiw,在某种程度上可能是您自己没有创建这个CircularProgressBar类的情况下,您找到了一个很好的理由从您的机器中删除它。