From: Cor Ligthert[MVP] on 26 Apr 2010 11:38 You got that already. The main point is that it should result in integers when it are two parameters http://msdn.microsoft.com/en-us/library/system.drawing.size_members.aspx With option strict on, your already used code should go. Be aware that you probably want to size the image itself because with the values you show you need a very big screen as it is about the picturebox, which you do by using streaming the bitmap using a stream and the DrawingClass "zzz" <zzz(a)tin.it> wrote in message news:4bd5a90f$0$1108$4fafbaef(a)reader2.news.tin.it... > > "Armin Zingler" <az.nospam(a)freenet.de> ha scritto nel messaggio > news:uiOVm3U5KHA.6052(a)TK2MSFTNGP02.phx.gbl... >> Am 26.04.2010 16:00, schrieb zzz: >>> Ok, I have turned Option Strict ON. >> >> Hard to believe. :-) Because: > > I mean: now I have turned on Option Strict :D > >> By passing the appropriate values as the srcWidth/srcHeight parameters >> to the graphics.drawimage method called in the Form's paint event. >> The srcX/srcY argument values depend on the current scroll position. > > Can I ask you 3 code rows? ;) > > >
From: zzz on 26 Apr 2010 11:47 "Armin Zingler" <az.nospam(a)freenet.de> ha scritto nel messaggio news:%23QPITZV5KHA.5880(a)TK2MSFTNGP04.phx.gbl... > Am 26.04.2010 16:54, schrieb zzz: >> Can I ask you 3 code rows? ;) > > Yep, go on asking. :) I mean if you can write the 3 code rows about displaying only the visible part of the picturebox avoiding in this way the returned exception Thanks
From: Chris Dunaway on 28 Apr 2010 17:55 On Apr 26, 4:20 am, "zzz" <z...(a)tin.it> wrote: > 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 Try this: http://www.bobpowell.net/zoompicbox.htm Chris
From: Armin Zingler on 29 Apr 2010 10:08 Am 26.04.2010 17:47, schrieb zzz: > "Armin Zingler" <az.nospam(a)freenet.de> ha scritto nel messaggio > news:%23QPITZV5KHA.5880(a)TK2MSFTNGP04.phx.gbl... >> Am 26.04.2010 16:54, schrieb zzz: >>> Can I ask you 3 code rows? ;) >> >> Yep, go on asking. :) > > > I mean if you can write the 3 code rows about displaying only the visible > part of the picturebox avoiding in this way the returned exception > Thanks I didn't answer earlier beause the example I was trying to make takes more than just 3 rows. You have to change the approach by not using a Picturebox. So, I leave only some hints: Draw the image on your own in the control's paint event. You can use a Panel for it; a picturebox is not required. A simple Control would do it also but you can't use the designer for that. Add two scrollbars next to the panel. In the panel's paint event, draw the image using e.graphics.drawimage There are a lot of overloaded methods, so pick out the one letting you specify the source and destination areas of the image resp. the panel. You have to calculate them from the scrollbar's positions and the current zoom factor. Success! -- Armin
From: giggino on 1 May 2010 07:10
Thanks, it helped a lot ;) "Chris Dunaway" <dunawayc(a)gmail.com> ha scritto nel messaggio news:cee2c024-420b-4080-8ca3-904df2ddb3b9(a)e1g2000yqe.googlegroups.com... > On Apr 26, 4:20 am, "zzz" <z...(a)tin.it> wrote: >> 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 > > Try this: > > http://www.bobpowell.net/zoompicbox.htm > > Chris |