Principales respuestas
Error , Si está utilizando el objeto Graphics() después del método GetHdc, llame al método ReleaseHdc

Pregunta
-
al utilizar los picturebox con gif animados de repente me sale con el error Si está utilizando el objeto Graphics() después del método GetHdc, llame al método ReleaseHdc.
tengo un mismo picturebox para cuatro imagen solo me cambio la imagen cuando recibo el valor que le indique que debe ser la imagen algo muy simple solo que revienta con ese error.
If value7 = 1 And value8 = 1 Then PictureBox1.Image =My.Resources.plantas___Riego End If '/////////////////////////////////////// If value7 = 1 And value8 = 0 Then PictureBox1.Image = My.Resources.giro End If '/////////////////////////////////////// If value8 = 1 And value7 = 0 Then PictureBox1.Image = My.Resources.SoloRiego End If '/////////////////////////////////////// If value8 = 0 And value7 = 0 Then PictureBox1.Image = My.Resources.P1Izquierda1 End If
- Cambiado Enrique M. Montejo viernes, 25 de marzo de 2016 10:46 Pregunta relacionada con controles de Windows Forms.
Respuestas
-
Ok gracias igual sigue sin funcionar:, con esas líneas que indicaste. Ya probé colocancando dentro el try chath y tampoco. Sigue el mismo error. Gracias por responder seguiré en la búsqueda Saludos.
este el error que arroja
No se controló System.InvalidOperationException
HResult=-2146233079
Message=El objeto ya está en uso.
Source=System.Drawing
StackTrace:
en System.Drawing.Image.get_RawFormat()
en System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
en System.Drawing.Graphics.DrawImage(Image image, Rectangle rect)
en System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
en System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
en System.Windows.Forms.Control.WmPaint(Message& m)
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
en System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
en System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
en System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
en System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
en System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
en System.Windows.Forms.Application.Run(ApplicationContext context)
en Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
en Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
en Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
en Sistema_de_control_del_Riego_Aeroponico.My.MyApplication.Main(String[] Args) en 17d14f5c-a337-4978-8281-53493378c1071.vb:línea 81
en System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
en System.Threading.ThreadHelper.ThreadStart_Context(Object state)
en System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
en System.Threading.ThreadHelper.ThreadStart()
InnerException:
Todas las respuestas
-
¿Dónde te da el error?
Fíjate que puedes poner los bloques If ... Then bastante mejor ordenados:
If value7 = 1 Then If value8 = 1 Then PictureBox1.Image =My.Resources.plantas___Riego ElseIf value8 = 0 Then PictureBox1.Image = My.Resources.giro End If ElseIf value7 = 0 Then If value8 = 1 Then PictureBox1.Image = My.Resources.SoloRiego ElseIf value8 = 0 Then PictureBox1.Image = My.Resources.P1Izquierda1 End If End If
Saludos, Javier J
-
-
-
-
-
Ok gracias igual sigue sin funcionar:, con esas líneas que indicaste. Ya probé colocancando dentro el try chath y tampoco. Sigue el mismo error. Gracias por responder seguiré en la búsqueda Saludos.
este el error que arroja
No se controló System.InvalidOperationException
HResult=-2146233079
Message=El objeto ya está en uso.
Source=System.Drawing
StackTrace:
en System.Drawing.Image.get_RawFormat()
en System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
en System.Drawing.Graphics.DrawImage(Image image, Rectangle rect)
en System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
en System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
en System.Windows.Forms.Control.WmPaint(Message& m)
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
en System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
en System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
en System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
en System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
en System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
en System.Windows.Forms.Application.Run(ApplicationContext context)
en Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
en Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
en Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
en Sistema_de_control_del_Riego_Aeroponico.My.MyApplication.Main(String[] Args) en 17d14f5c-a337-4978-8281-53493378c1071.vb:línea 81
en System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
en System.Threading.ThreadHelper.ThreadStart_Context(Object state)
en System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
en System.Threading.ThreadHelper.ThreadStart()
InnerException: -