From: zzz on
Hi to all,
inside a subroutine i have this code:

Me.PictureBox1.Size = New Size(Me.dimensioni.Width * Me.zoom_factor,
Me.dimensioni.Height * Me.zoom_factor)

When the program goes out of sub I get the error:

System.ComponentModel.Win32Exception non � stata gestita
Message="Operazione completata"
Source="System.Drawing"
ErrorCode=-2147467259
NativeErrorCode=0
StackTrace:
in System.Drawing.BufferedGraphicsContext.CreateCompatibleDIB(IntPtr
hdc, IntPtr hpal, Int32 ulWidth, Int32 ulHeight, IntPtr& ppvBits)
in System.Drawing.BufferedGraphicsContext.CreateBuffer(IntPtr src,
Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)
in System.Drawing.BufferedGraphicsContext.AllocBuffer(Graphics
targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
in
System.Drawing.BufferedGraphicsContext.AllocBufferInTempManager(Graphics
targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
in System.Drawing.BufferedGraphicsContext.Allocate(IntPtr targetDC,
Rectangle targetRectangle)
in System.Windows.Forms.Control.WmPaint(Message& m)
in System.Windows.Forms.Control.WndProc(Message& m)
in
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
in System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
in System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
msg)
in
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
in
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
in
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
in System.Windows.Forms.Application.Run(ApplicationContext context)
in
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
in
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
in
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine)
in EGF.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:riga 81
in System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args)
in System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
in System.Threading.ThreadHelper.ThreadStart_Context(Object state)
in System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
in System.Threading.ThreadHelper.ThreadStart()
InnerException:

I tried to insert the code inside a try catch but without success.
Can anyone help me?
Thanks


From: Armin Zingler on
Am 26.04.2010 11:20, schrieb zzz:
> Hi to all,
> inside a subroutine i have this code:
>
> Me.PictureBox1.Size = New Size(Me.dimensioni.Width * Me.zoom_factor,
> Me.dimensioni.Height * Me.zoom_factor)

Which event handler calles this sub routine?

What does

debug.print(Me.PictureBox1.Size.tostring)

output directly after the assignment?



--
Armin
From: Cor Ligthert[MVP] on
Why do you think that this quit standard code which is probably billion
times used has a bug.

Or do you mean in your program, that is possible, but then you can simply
try it by placing some fixed values instead of the calculation.

I assume you have option strict on in top of your program to be sure the
correct types are used.


"zzz" <zzz(a)tin.it> wrote in message
news:4bd55b2d$0$1117$4fafbaef(a)reader2.news.tin.it...
> Hi to all,
> inside a subroutine i have this code:
>
> Me.PictureBox1.Size = New Size(Me.dimensioni.Width * Me.zoom_factor,
> Me.dimensioni.Height * Me.zoom_factor)
>
> When the program goes out of sub I get the error:
>
> System.ComponentModel.Win32Exception non � stata gestita
> Message="Operazione completata"
> Source="System.Drawing"
> ErrorCode=-2147467259
> NativeErrorCode=0
> StackTrace:
> in System.Drawing.BufferedGraphicsContext.CreateCompatibleDIB(IntPtr
> hdc, IntPtr hpal, Int32 ulWidth, Int32 ulHeight, IntPtr& ppvBits)
> in System.Drawing.BufferedGraphicsContext.CreateBuffer(IntPtr src,
> Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)
> in System.Drawing.BufferedGraphicsContext.AllocBuffer(Graphics
> targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
> in
> System.Drawing.BufferedGraphicsContext.AllocBufferInTempManager(Graphics
> targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
> in System.Drawing.BufferedGraphicsContext.Allocate(IntPtr targetDC,
> Rectangle targetRectangle)
> in System.Windows.Forms.Control.WmPaint(Message& m)
> in System.Windows.Forms.Control.WndProc(Message& m)
> in
> System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
> in System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
> m)
> in System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
> Int32 msg, IntPtr wparam, IntPtr lparam)
> in System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
> msg)
> in
> System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
> dwComponentID, Int32 reason, Int32 pvLoopData)
> in
> System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
> reason, ApplicationContext context)
> in
> System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
> reason,
> ApplicationContext context)
> in System.Windows.Forms.Application.Run(ApplicationContext context)
> in
> Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
> in
> Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
> in
> Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
> commandLine)
> in EGF.My.MyApplication.Main(String[] Args) in
> 17d14f5c-a337-4978-8281-53493378c1071.vb:riga 81
> in System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
> args)
> in System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
> assemblySecurity, String[] args)
> in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
> in System.Threading.ThreadHelper.ThreadStart_Context(Object state)
> in System.Threading.ExecutionContext.Run(ExecutionContext
> executionContext, ContextCallback callback, Object state)
> in System.Threading.ThreadHelper.ThreadStart()
> InnerException:
>
> I tried to insert the code inside a try catch but without success.
> Can anyone help me?
> Thanks
>
>
>
From: zzz on


"Armin Zingler" <az.nospam(a)freenet.de> ha scritto nel messaggio
news:%23Tes8nS5KHA.1932(a)TK2MSFTNGP05.phx.gbl...
> Am 26.04.2010 11:20, schrieb zzz:
>> Hi to all,
>> inside a subroutine i have this code:
>>
>> Me.PictureBox1.Size = New Size(Me.dimensioni.Width * Me.zoom_factor,
>> Me.dimensioni.Height * Me.zoom_factor)
>
> Which event handler calles this sub routine?
>
> What does
>
> debug.print(Me.PictureBox1.Size.tostring)
>
> output directly after the assignment?
>
>
>
> --
> Armin

My code is inside
..MouseWheel event( is about zooming an image displayed in a form).

Private Sub pict_MouseMove(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseWheel

try

If e.Delta < 0 Then

Me.zoom_factor *= 2

Else

Me.zoom_factor /= 2

End If

Me.PictureBox1.Size = New Size(Me.dimensioni.Width * Me.zoom_factor,
Me.dimensioni.Height * Me.zoom_factor)

Debug.Print(Me.zoom_factor.ToString)

Catch ex As Exception

MsgBox(ex.Message)

End Try



when zoom_factor reaches a 2048 value, I get the error, but the exception is
not raised.....so I really don't known where the dll exception is raised.

Maybe too large dimension of image makes it up....






From: Patrice on
Hello,

> when zoom_factor reaches a 2048 value, I get the error, but the exception
> is not raised.....so I really don't known where the dll exception is
> raised.

Looking at the call stack, it seems to happens when the control is painted,
not at the time of the change.

> Maybe too large dimension of image makes it up....

I would really set a max value for the zoom. 2048 likely means you just see
a single pixel on your screen anyway ;-)

--
Patrice