用菜单编辑器生成一个菜单,将其中一项的INDEX设为0,然后用Load去动态生成,呵呵。

解决方案 »

  1.   

    Private Sub CreateMenus()
    Dim hFormMenu As Long
    Dim hSubMenu2 As Long
    Dim hSubMenu2List As Long
    Dim iCounter As Integer
    Dim hSystemMenu As Long
        
        ' Get the handle to the Menu on the
        ' current form
        hFormMenu = GetMenu(Me.hwnd)
        
        ' Create a new popup menu to be used to
        ' place the required menu items in
        hSubMenu2List = CreatePopupMenu()
            
        ' Modify the second menu option on the Form
        ' Menu (denoted by the position 1 -
        ' menu positions start with 0 for the first
        ' item, so 1 specifies the second item).
        ' Specify that the Submenu option will
        ' activate the new popup menu just created
        ' (given the new popup menu handle). Note:
        ' The last string parameter in the function
        ' call specifies the new menu option caption
        ' so if it is to stay the same, make this
        ' string the same as the original caption
        ModifyMenu hFormMenu, 0, MF_BYPOSITION + MF_POPUP, hSubMenu2List, "New Menu Item"
        
        ' Get the handle of the second menu
        ' option on the Form Menu (denoted by the
        ' position 1)
        hSubMenu2 = GetSubMenu(hFormMenu, 0)
        
        ' Add new items to the second menu option
        ' list ("Document List")
        For iCounter = 1 To 10
            Call AppendMenu(hSubMenu2, MF_STRING + MF_ENABLED, 1000 + iCounter, "Document " & CStr(iCounter))
        Next    ' Add "About" to the system menu.
        hSystemMenu = GetSystemMenu(hwnd, False)
        AppendMenu hSystemMenu, MF_SEPARATOR, 0, ""
        AppendMenu hSystemMenu, MF_STRING + MF_ENABLED, IDM_ABOUT, "About..."
    End Sub
      

  2.   

    可以到www.planetsourcecode.com上查一下,有一个例子甚至是直接在菜单中插入了一张硕大的图片。