L
Lee Gillie
This one has me completely baffled. I am calling ShowDialog on this
form, and it is about the simplest form in any application. The form
presents a multi-line text box for viewing, copying to clipboard, or
printing.
Maybe someone has ideas???
WoComMenuHandler is a context menu handler on the main form.
WoComMenuHandler instances frmTextView, sets properties, and then calls
frmTextView.ShowDialog and crashes as follows. There is no form load or
activated event coded.
WoComMenuHandler does this setup prior to ShowDialog sets properties, as
follows:
Dim frm As New frmTextEditor
frm.Editable = True
frm.DialogTitle = "WO " & WoNum.ToString & " Comments"
frm.TextContent = wo.Comments
If frm.ShowDialog(Me) = DialogResult.OK Then
...
The properties (used above) in frmTextView are pretty straight forward.
It doesn't crash setting these properties. It crashes on ShowDialog.
Public Property Editable() As Boolean
Get
Return Not tbText.ReadOnly
End Get
Set(ByVal Value As Boolean)
tbText.ReadOnly = Not Value
If tbText.ReadOnly Then
Me.btnOK.Text = "OK"
Me.btnCancel.Visible = False
Else
Me.btnOK.Text = "SAVE"
Me.btnCancel.Visible = True
End If
End Set
End Property
Public Property DialogTitle() As String
Get
Return Me.Text
End Get
Set(ByVal Value As String)
Me.Text = Value
End Set
End Property
Public Property TextContent() As String
' tbText is a multiline text box.
Get
Return tbText.Text
End Get
Set(ByVal Value As String)
tbText.Text = Value
tbText.SelectionLength = 0
End Set
End Property
The exception I see is as follows...
************** Exception Text **************
System.ArgumentException: Invalid parameter used.
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height,
PixelFormat format)
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)
at System.Drawing.Icon.ToBitmap()
at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
at System.Windows.Forms.ThreadContext.OnThreadException(Exception t)
at System.Windows.Forms.Control.WndProcException(Exception e)
at
System.Windows.Forms.ControlNativeWindow.OnThreadException(Exception e)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at PPSManager.frmMain.WoComMenuHandler(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.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)
form, and it is about the simplest form in any application. The form
presents a multi-line text box for viewing, copying to clipboard, or
printing.
Maybe someone has ideas???
WoComMenuHandler is a context menu handler on the main form.
WoComMenuHandler instances frmTextView, sets properties, and then calls
frmTextView.ShowDialog and crashes as follows. There is no form load or
activated event coded.
WoComMenuHandler does this setup prior to ShowDialog sets properties, as
follows:
Dim frm As New frmTextEditor
frm.Editable = True
frm.DialogTitle = "WO " & WoNum.ToString & " Comments"
frm.TextContent = wo.Comments
If frm.ShowDialog(Me) = DialogResult.OK Then
...
The properties (used above) in frmTextView are pretty straight forward.
It doesn't crash setting these properties. It crashes on ShowDialog.
Public Property Editable() As Boolean
Get
Return Not tbText.ReadOnly
End Get
Set(ByVal Value As Boolean)
tbText.ReadOnly = Not Value
If tbText.ReadOnly Then
Me.btnOK.Text = "OK"
Me.btnCancel.Visible = False
Else
Me.btnOK.Text = "SAVE"
Me.btnCancel.Visible = True
End If
End Set
End Property
Public Property DialogTitle() As String
Get
Return Me.Text
End Get
Set(ByVal Value As String)
Me.Text = Value
End Set
End Property
Public Property TextContent() As String
' tbText is a multiline text box.
Get
Return tbText.Text
End Get
Set(ByVal Value As String)
tbText.Text = Value
tbText.SelectionLength = 0
End Set
End Property
The exception I see is as follows...
************** Exception Text **************
System.ArgumentException: Invalid parameter used.
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height,
PixelFormat format)
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)
at System.Drawing.Icon.ToBitmap()
at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
at System.Windows.Forms.ThreadContext.OnThreadException(Exception t)
at System.Windows.Forms.Control.WndProcException(Exception e)
at
System.Windows.Forms.ControlNativeWindow.OnThreadException(Exception e)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at PPSManager.frmMain.WoComMenuHandler(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.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)