Corrections *or* a workaround would be appreciated.
Public Class Form1
Dim gpTest As New System.Drawing.Drawing2D.GraphicsPath
Dim intAlpha As Integer
Dim sglPenWidth As Integer
Dim clrSchmutz As Color
Dim penSchmutz As Pen
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
gpTest.AddLine(e.X, e.Y, e.X, e.Y)
Me.Invalidate()
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
gpTest.StartFigure()
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.DrawPath(penSchmutz, gpTest) 'error occurs here
at the start of the 2nd mouse drag
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
intAlpha = 100
sglPenWidth = 2
clrSchmutz = System.Drawing.Color.Black
penSchmutz = New Pen(Color.FromArgb(intAlpha, clrSchmutz),
sglPenWidth)
End Sub
End Class
System.OutOfMemoryException was unhandled
Message="Out of memory."
Source="System.Drawing"
StackTrace:
at System.Drawing.Graphics.CheckErrorStatus(Int32 status) at
System.Drawing.Graphics.DrawPath(Pen pen, GraphicsPath path) at
TestGraphics.Form1.Form1_Paint(Object sender, PaintEventArgs e) in C:
\Documents and Settings\Visual Studio Projects\TestGraphics
\TestGraphics\Form1.vb:line 20 at
System.Windows.Forms.Control.OnPaint(PaintEventArgs e) at
System.Windows.Forms.Form.OnPaint(PaintEventArgs e) 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.ScrollableControl.WndProc(Message& m) at
System.Windows.Forms.ContainerControl.WndProc(Message& m) at
System.Windows.Forms.Form.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) at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context) at
System.Windows.Forms.Application.Run(ApplicationContext context) at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine) at TestGraphics.My.MyApplication.Main(String[] Args)
in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at
System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args) at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args) at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state) at
System.Threading.ThreadHelper.ThreadStart()
InnerException:
It's the Pens DashPattern which is causing an out of memory exception.
Simply give it a value and no more errors.
penSchmutz.DashPattern = New Single() {1.0F}
However, your Pen now has a DashPattern which you may not want.
--
Mick Doherty
http://dotnetrix.co.uk/nothing.htm
<p...@twave.net> wrote in message
news:66fe7668-a6d8-4e6b...@64g2000hsu.googlegroups.com...
I like it! Looks like a good workaround to me.
How did you know it was the dash pattern?
Peter Bradshaw
p...@twave.net
> Looks like a bug to me.
>
> It's the Pens DashPattern which is causing an out of memory exception.
> Simply give it a value and no more errors.
>
> penSchmutz.DashPattern = New Single() {1.0F}
>
> However, your Pen now has a DashPattern which you may not want.
>
> --
> Mick Dohertyhttp://dotnetrix.co.uk/nothing.htm
> > System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
> > dwComponentID, Int32 reason, Int32 pvLoopData) at
> > System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
> > reason, ApplicationContext context) at
> > System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
> > reason, ApplicationContext context) at
> > System.Windows.Forms.Application.Run(ApplicationContext context) at
> > Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
> > at
> > Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
> > at
> > Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
> > commandLine) at TestGraphics.My.MyApplication.Main(String[] Args)
> > in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at
> > System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
> > args) at System.AppDomain.ExecuteAssembly(String assemblyFile,
> > Evidence assemblySecurity, String[] args) at
> > Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
> > at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
> > at System.Threading.ExecutionContext.Run(ExecutionContext
> > executionContext, ContextCallback callback, Object state) at
> > System.Threading.ThreadHelper.ThreadStart()
> > InnerException:- Hide quoted text -
>
> - Show quoted text -
I just pasted your code into a new project and ran it. When it failed I
hovered the mouse over the penShmutz argument in the DrawPath() call ( which
was automatically highlighted by VS). This allowed me to inspect the pen and
after expanding to the Properties view I could see the DashPattern property
had an "{Out of memory}" value. I then just gave it a value and problem
solved.
--
Mick Doherty
http://dotnetrix.co.uk/nothing.htm
<p...@twave.net> wrote in message
news:b6010ea2-54bf-4186...@d45g2000hsc.googlegroups.com...
Hello Mick,
Well now I'm *glad* I had that little error that stymied me for two
weeks. At this stage one of the biggest reasons I write programs is to
get experience in debugging them. I had assumed the error was in the
DrawPath method and had hovered over and expanded that, to no benefit.
It never occurred to me to interrogate one of the arguments.
Thanks again.
Peter Bradshaw
p...@twave.net