Public Class BtnForm
  Inherits System.Windows.Forms.Form

  Private evh As EventHandler
  Private mnMain As MainMenu
  Private mnFile As MenuItem
  Private mnOpen As FileOpen
  Private mnQuit As ExitMenu

  Private Sub init()
    evh = New EventHandler(AddressOf commandHandler)
    AddHandler rdbutn.Click, evh
    rdbutn.setForm(Me)
    mnMain = New MainMenu()
    mnFile = New MenuItem("File")
    mnOpen = New FileOpen()
    mnQuit = New ExitMenu(Me)
    mnMain.MenuItems.AddRange(New MenuItem() {mnFile})
    mnFile.MenuItems.AddRange(New MenuItem() {mnOpen, mnQuit})
    Me.Menu = mnMain
    AddHandler mnOpen.Click, evh
    AddHandler mnQuit.Click, evh
  End Sub
#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call
    init()
  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub
  Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
  Friend WithEvents rdbutn As New BtnMenu.redButton()

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    Me.rdbutn = New BtnMenu.redButton()
    Me.SuspendLayout()
    '
    'rdbutn
    '
    Me.rdbutn.Location = New System.Drawing.Point(104, 48)
    Me.rdbutn.Name = "rdbutn"
    Me.rdbutn.Size = New System.Drawing.Size(80, 32)
    Me.rdbutn.TabIndex = 0
    Me.rdbutn.Text = "Red"
    '
    'BtnForm
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(296, 173)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.rdbutn})

    Me.Name = "BtnForm"
    Me.Text = "BtnMenu"
    Me.ResumeLayout(False)

  End Sub

#End Region


  Private Sub commandHandler( _
       ByVal sender As System.Object, _
       ByVal e As System.EventArgs)
    Dim cmd As Command
    cmd = CType(sender, Command)
    cmd.Execute()
  End Sub
End Class
