Results 1 to 5 of 5

Thread: Using APIs to Create submenu or submenu array ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    BC, Canada
    Posts
    142
    I know the code to create a popupmenu and fill it with items. Here is the code:
    Code:
    Public Declare Function CreatePopupMenu Lib "user32.dll" () As Long
    Public Type MENUITEMINFO
        cbSize As Long
        fMask As Long
        fType As Long
        fState As Long
        wID As Long
        hSubMenu As Long
        hbmpChecked As Long
        hbmpUnchecked As Long
        dwItemData As Long
        dwTypeData As String
        cch As Long
    End Type
    Public Declare Function InsertMenuItem Lib "user32.dll" Alias "InsertMenuItemA" (ByVal _
        hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As _
        MENUITEMINFO) As Long
    
    
    
        Dim hPopupMenu As Long    
        Dim mii As MENUITEMINFO 
        Dim retval As Long        
    
    
    'inside an event procedure
    
      hPopupMenu = CreatePopupMenu()
      With mii
            .cbSize = Len(mii)
            .fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE
            .fType = MFT_STRING
            .fState = MFS_ENABLED Or MFS_DEFAULT
            .wID = ID_ABOUT
            .dwTypeData = "&About This Example..."
            .cch = Len(.dwTypeData)
        End With
        retval = InsertMenuItem(hPopupMenu, 0, 1, mii)
    This will produce an menu item for popupmenu. But I tried to change the ftype, fmask value to create submenu or submenu array within popupmenu without success.
    Anyone could help me?





  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    should be able to get your answer here:

    http://www.vbapi.com/ref/c/createpopupmenu.html
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    BC, Canada
    Posts
    142
    Thanks. That is the place I got above code. The sample doesn't address how to creat submenu issue.


  4. #4
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516

    Wink Where there's a will, there's a dozen long lost nephews

    If .fmask add Or MIIM_SUBMENU and in .hSubMenu add the handle to a menu which is the submenu (this could be one created eith VB's menu editor, or by CreatePopupMenu)

    Courgettes.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    BC, Canada
    Posts
    142
    Thanks V(ver)y Basic, I am still struggling to get it work

    Here is the code
    Code:
     hsubMenu = CreatePopupMenu()  'create submenu
      With mii
            .cbSize = Len(mii)
            .fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE or miim_submenu
            .fType = MFT_STRING or MFT_MENUBREAK
            .fState = MFS_ENABLED Or MFS_DEFAULT
            .wID = 1
            .dwTypeData = "subMenu Item"
            .cch = Len(.dwTypeData)
        End With
        retval = InsertMenuItem(hsubMenu, 0, 1, mii) 'insert first submenu item
    
     hPopupMenu=CreatePopupMenu() ' Create popup menu
        With mii
            .cbSize = Len(mii)
            .fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE
            .fType = MFT_STRING
            .fState = MFS_ENABLED Or MFS_DEFAULT
            .wID = 2
            .dwTypeData = "menu item"
            .cch = Len(.dwTypeData)
            .hsubmenu = hsubmenu
        End With
        retval = InsertMenuItem(hPopupMenu, 0, 1, mii)
    Only first level menu shows up. Any Help?





    [Edited by Winla on 08-17-2000 at 02:05 PM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width