R
Russ Ryba
I believe I've found a bug in the compact framework. I don't see any
reference to it, but here's what I've found. I'm testing on a Dell Axim
X5, PocketPC 2002, A03 ROM.
If you create a new instance of a form inside a different forms Load
Event, the first form gets the seconds forms menu. I was creating the
child forms at startup so all the waiting happened at once and the rest
of the application loaded quicker. Everything worked great until I
tried adding a menu for the SIP control.
Starting the application will show the wrong menu in both the handheld
and the emulator. I've attached a zip of the files used to create the
project.
Here is the Minimum Code I've found to reproduce this bug.
----------------------------------------------------------------------------------
== Form1.vb ==
----------------------------------------------------------------------------------
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MainMenu1.MenuItems.Add(Me.MenuItem1)
Me.MenuItem1.Text = "FORM1"
Me.Menu = Me.MainMenu1
Me.Text = "Form1"
End Sub
#End Region
Dim A As Form2
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs)
A.Show()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
A = New Form2
End Sub
End Class
----------------------------------------------------------------------------------
== Form2.vb ==
----------------------------------------------------------------------------------
Public Class Form2
Inherits System.Windows.Forms.Form
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MainMenu1.MenuItems.Add(Me.MenuItem1)
Me.MenuItem1.Text = "FORM2"
Me.Menu = Me.MainMenu1
Me.Text = "Form2"
End Sub
#End Region
End Class
reference to it, but here's what I've found. I'm testing on a Dell Axim
X5, PocketPC 2002, A03 ROM.
If you create a new instance of a form inside a different forms Load
Event, the first form gets the seconds forms menu. I was creating the
child forms at startup so all the waiting happened at once and the rest
of the application loaded quicker. Everything worked great until I
tried adding a menu for the SIP control.
Starting the application will show the wrong menu in both the handheld
and the emulator. I've attached a zip of the files used to create the
project.
Here is the Minimum Code I've found to reproduce this bug.
----------------------------------------------------------------------------------
== Form1.vb ==
----------------------------------------------------------------------------------
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MainMenu1.MenuItems.Add(Me.MenuItem1)
Me.MenuItem1.Text = "FORM1"
Me.Menu = Me.MainMenu1
Me.Text = "Form1"
End Sub
#End Region
Dim A As Form2
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs)
A.Show()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
A = New Form2
End Sub
End Class
----------------------------------------------------------------------------------
== Form2.vb ==
----------------------------------------------------------------------------------
Public Class Form2
Inherits System.Windows.Forms.Form
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MainMenu1.MenuItems.Add(Me.MenuItem1)
Me.MenuItem1.Text = "FORM2"
Me.Menu = Me.MainMenu1
Me.Text = "Form2"
End Sub
#End Region
End Class