如何在应用程序中放置菜单栏

时间:2009-07-10 19:49:57

标签: vb6 menubar evb

我在使用eVB时遇到了一些问题。如何在eVB项目中放置菜单栏?我看不到任何组件,我不知道如何做到这一点。这是eVB中制作的菜单栏的示例,但它不是我的程序。我在Google中找到了这张图片:

This is a example of menu bar! http://msdn.microsoft.com/en-us/library/ms838303.aspx


谢谢,但我已经回复了MSDN的这篇文章:http://msdn.microsoft.com/en-us/library/ms838303.aspx,但我看到这个组件来自Odyssey Inc.,但当我尝试访问该网站时,我不能找到这个组件供下载。

3 个答案:

答案 0 :(得分:2)

我终于找到并重新安装了eVB。以下是添加从帮助文件中采取的菜单的代码。我先测试了它。有用。首先,添加一个CommandBar。 CommandBar和MenuBar已合并到此工具中。

Private Sub Form_Load()
    InitCommandBar
End Sub

Sub InitCommandBar()
  Dim mnuMain As CommandbarLib.CommandBarMenuBar
  Dim mnuFile As CommandbarLib.Item
  Dim mnuEdit As CommandbarLib.Item

  Set mnuMain = CommandBar1.Controls.Add(cbrMenuBar, "MainMenu")
  'add File menu items
  Set mnuFile = mnuMain.Items.Add(1, "File", "File")
  mnuFile.SubItems.Add , "Open", "Open"
  mnuFile.SubItems.Add , "Add", "Add"
  mnuFile.SubItems.Add , "Update", "Update"
  mnuFile.SubItems.Add , "Delete", "Delete"

  'add Edit menu items
  Set mnuEdit = mnuMain.Items.Add(2, "Edit", "Edit")
                mnuEdit.SubItems.Add , "Sort", "Sort"
                mnuEdit.SubItems.Add , "Find", "Find"

顺便说一句 - 我没找到菜单编辑器。

答案 1 :(得分:1)

答案 2 :(得分:0)

我在DevBUZZ foruns中问了同样的问题,我解决了我的问题,这里有更多细节的链接:http://forums.devbuzz.com/How_To_Put_a_Menu_Bar_in_an_Aplication/m_41726/tm.htm

以下是使用CommandBar执行此操作的代码:

Option Explicit

Private Sub Form_Load()
    InitCommandBar
End Sub

Sub InitCommandBar()
  Dim mnuMain As CommandbarLib.CommandBarMenuBar
  Dim mnuFile As CommandbarLib.Item
  Dim mnuEdit As CommandbarLib.Item

  Set mnuMain = CommandBar1.Controls.Add(cbrMenuBar, "MainMenu")
  'add File menu items
  Set mnuFile = mnuMain.Items.Add(1, "File", "File")
  mnuFile.SubItems.Add , "Open", "Open"
  mnuFile.SubItems.Add , "Add", "Add"
  mnuFile.SubItems.Add , "Update", "Update"
  mnuFile.SubItems.Add , "Delete", "Delete"

  'add Edit menu items
  Set mnuEdit = mnuMain.Items.Add(2, "Edit", "Edit")
                mnuEdit.SubItems.Add , "Sort", "Sort"
                mnuEdit.SubItems.Add , "Find", "Find"
End Sub