Hi All, Having a problem has anyone seen this before?
Environment: Windows Forms, .NET 1.1, Win2K client
It is not something easily reproduced.
When this error happens, the
user said that all the controls on the screen get the old red X in them
(as an aside, we inherit from just about every standard Windows Forms
control and use those on the forms)
The exception is:
System.ArgumentException: Invalid parameter used.
at System.Drawing.Graphics.GetHdc()
at System.Windows.Forms.ControlPaint.DrawFrameControl(Graphics
graphics, Int32 x, Int32 y, Int32 width, Int32 height, Int32 kind,
Int32 state)
at System.Windows.Forms.ControlPaint.DrawCheckBox(Graphics graphics,
Int32 x, Int32 y, Int32 width, Int32 height, ButtonState state)
at System.Windows.Forms.ControlPaint.DrawCheckBox(Graphics graphics,
Rectangle rectangle, ButtonState state)
...
There is a lot of custom control painting in this app, but Nothing with the checkbox control other than subclass it and set its
background color. Here's the code
Protected Overrides Sub OnPaint(ByVal pevent As
System.Windows.Forms.PaintEventArgs)
If (Enabled) Then
ForeColor =
ThemeManager.ActiveTheme.InputControlSettings.NormalFillAndBorder.Contro
lForeground
Else
ForeColor =
ThemeManager.ActiveTheme.InputControlSettings.DisabledFillAndBorder.Cont
rolForeground
End If
MyBase.OnPaint(pevent)
End Sub
The code in the event handler may be a red herring, though, as I have seen this problem where the app did not appear to do any custom painting of the checkbox.
Here is the stack trace
> System.ArgumentException: Invalid parameter used.
> at System.Drawing.Graphics.GetHdc()
> at System.Windows.Forms.ControlPaint.DrawFrameControl(Graphics
> graphics, Int32 x, Int32 y, Int32 width, Int32 height, Int32 kind,
Int32
> state)
> at System.Windows.Forms.ControlPaint.DrawCheckBox(Graphics
graphics,
> Int32 x, Int32 y, Int32 width, Int32 height, ButtonState state)
> at System.Windows.Forms.ControlPaint.DrawCheckBox(Graphics
graphics,
> Rectangle rectangle, ButtonState state)
> at System.Windows.Forms.CheckBox.DrawCheckBox(PaintEventArgs e,
> LayoutData layout)
> at System.Windows.Forms.CheckBox.PaintUp(PaintEventArgs e,
CheckState
> state)
> at System.Windows.Forms.ButtonBase.PaintStandard(PaintEventArgs
> pevent)
> at System.Windows.Forms.ButtonBase.PaintControl(PaintEventArgs
> pevent)
> at System.Windows.Forms.ButtonBase.OnPaint(PaintEventArgs pevent)
> at
System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs
> e, Int16 layer, Boolean disposeEventArgs)
> at System.Windows.Forms.Control.WmPaint(Message& m)
> at System.Windows.Forms.Control.WndProc(Message& m)
> at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
> at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
> at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg,
> IntPtr wparam, IntPtr lparam)
Environment: Windows Forms, .NET 1.1, Win2K client
It is not something easily reproduced.
When this error happens, the
user said that all the controls on the screen get the old red X in them
(as an aside, we inherit from just about every standard Windows Forms
control and use those on the forms)
The exception is:
System.ArgumentException: Invalid parameter used.
at System.Drawing.Graphics.GetHdc()
at System.Windows.Forms.ControlPaint.DrawFrameControl(Graphics
graphics, Int32 x, Int32 y, Int32 width, Int32 height, Int32 kind,
Int32 state)
at System.Windows.Forms.ControlPaint.DrawCheckBox(Graphics graphics,
Int32 x, Int32 y, Int32 width, Int32 height, ButtonState state)
at System.Windows.Forms.ControlPaint.DrawCheckBox(Graphics graphics,
Rectangle rectangle, ButtonState state)
...
There is a lot of custom control painting in this app, but Nothing with the checkbox control other than subclass it and set its
background color. Here's the code
Protected Overrides Sub OnPaint(ByVal pevent As
System.Windows.Forms.PaintEventArgs)
If (Enabled) Then
ForeColor =
ThemeManager.ActiveTheme.InputControlSettings.NormalFillAndBorder.Contro
lForeground
Else
ForeColor =
ThemeManager.ActiveTheme.InputControlSettings.DisabledFillAndBorder.Cont
rolForeground
End If
MyBase.OnPaint(pevent)
End Sub
The code in the event handler may be a red herring, though, as I have seen this problem where the app did not appear to do any custom painting of the checkbox.
Here is the stack trace
> System.ArgumentException: Invalid parameter used.
> at System.Drawing.Graphics.GetHdc()
> at System.Windows.Forms.ControlPaint.DrawFrameControl(Graphics
> graphics, Int32 x, Int32 y, Int32 width, Int32 height, Int32 kind,
Int32
> state)
> at System.Windows.Forms.ControlPaint.DrawCheckBox(Graphics
graphics,
> Int32 x, Int32 y, Int32 width, Int32 height, ButtonState state)
> at System.Windows.Forms.ControlPaint.DrawCheckBox(Graphics
graphics,
> Rectangle rectangle, ButtonState state)
> at System.Windows.Forms.CheckBox.DrawCheckBox(PaintEventArgs e,
> LayoutData layout)
> at System.Windows.Forms.CheckBox.PaintUp(PaintEventArgs e,
CheckState
> state)
> at System.Windows.Forms.ButtonBase.PaintStandard(PaintEventArgs
> pevent)
> at System.Windows.Forms.ButtonBase.PaintControl(PaintEventArgs
> pevent)
> at System.Windows.Forms.ButtonBase.OnPaint(PaintEventArgs pevent)
> at
System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs
> e, Int16 layer, Boolean disposeEventArgs)
> at System.Windows.Forms.Control.WmPaint(Message& m)
> at System.Windows.Forms.Control.WndProc(Message& m)
> at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
> at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
> at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg,
> IntPtr wparam, IntPtr lparam)