Results 1 to 16 of 16

Thread: Menu API

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    Menu API

    I have problem,

    In this picture, I need doing this.

    Now, I can known How to do it {Blue}

    But [Red, Green]. how to do it,
    [red] (> small triangle
    [Green] maybe sub menu ?


    what is that correct name ?
    what API need ?
    any document to see more?

    Please!
    Attached Images Attached Images  
    Last edited by rpool; Sep 13th, 2009 at 05:47 PM.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Menu API

    Unless you are already using API's to create the menu, you don't need any API's to do that - just add the items using the normal menu editor, and click the right-arrow button (so they are a level deeper than Spell Check).

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    Re: Menu API

    Thanks, I used this code.

    Would you mind to tell me where changed?
    Code:
    
    Private Function make_popup_menu(ByRef myArr() As String, _
                                    ByVal myObj As Object, _
                                    ByVal myArrayLastRow_y0 As Integer, _
                                    ByVal showTitleNum As Integer, _
                                    ByVal execTitleNum As Integer) As Variant
                                    
    
    
    '////////////////////////////////////////////////////
    
    myObj.BackColor = &HC0C0FF 'red
    
    
    
    Dim ir As Integer
    Dim sID As Integer
    Dim myArrayLastRow_1 As Integer
    myArrayLastRow_1 = Val(myArrayLastRow_y0) + 1
    
    ReDim Preserve myArr(UBound(myArr), myArrayLastRow_1)
    
    sID = 5000
    
        For ir = LBound(myArr) To UBound(myArr)
            myArr(ir, myArrayLastRow_1) = "" & sID
            sID = sID + 1
        Next ir
    
    '//////////////////////////////////////////////////////////
    
    
    
    Dim hPopupMenu As Long    ' handle to the popup menu to display
    Dim mii As MENUITEMINFO   ' describes menu items to add
    Dim tpm As TPMPARAMS      ' identifies the exclusion rectangle
    Dim curpos As POINT_TYPE  ' holds the current mouse coordinates
    Dim menusel As Long       ' ID of what the user selected in the popup menu
    Dim FR_retval As Long     ' generic return value
        
    
    ' Create the popup menu that will be displayed.
    hPopupMenu = CreatePopupMenu()
    'form additem 0,1,2,3,4,5
    
    '//Insert Menu Open
    Dim cm As Integer
    
    
     For cm = LBound(myArr) To UBound(myArr)
    
        
         If myArr(cm, 0) = "MFT_SEPARATOR" Or myArr(cm, 1) = "MFT_SEPARATOR" Then
       
        ' Add the second item: a separator bar.
        With mii
            .fType = MFT_SEPARATOR
            .fState = MFS_ENABLED
            .wID = myArr(cm, myArrayLastRow_1) 'number
        End With
        FR_retval = InsertMenuItem(hPopupMenu, cm + 1, 1, mii)
        
        
        Else
    
        ' Add the second item: a separator bar.
        With mii
            .cbSize = Len(mii)
            .fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE
            .fType = MFT_STRING
            .wID = myArr(cm, myArrayLastRow_1) 'number
            .dwTypeData = "" & myArr(cm, showTitleNum)
            .cch = Len(.dwTypeData)
        End With
        
        FR_retval = InsertMenuItem(hPopupMenu, cm, 1, mii)
    
    
      End If
    
    
    Next cm
    
    '//Insert Menu Closed
    
    
        ' Determine where the mouse cursor currently is, in order to have
        ' the popup menu appear at that point.
        FR_retval = GetCursorPos(curpos)
        
        ' Make the exclusion rectangle empty because there's no need for it here.
        With tpm
            ' Size of the structure.
            .cbSize = Len(tpm)
            ' Make the exclusion rectangle empty.
            FR_retval = SetRectEmpty(.rcExclude)
        End With
        
        ' Display the popup menu at the mouse cursor.  Instead of sending messages
        ' to window Form1, have the function merely return the ID of the user's selection.
        menusel = TrackPopupMenuEx(hPopupMenu, TPM_TOPALIGN Or TPM_LEFTALIGN Or TPM_NONOTIFY _
            Or TPM_RETURNCMD Or TPM_LEFTBUTTON, curpos.x, curpos.y, Form1.hWnd, tpm)
        
        ' Before acting upon the user's selection, destroy the popup menu now.
        FR_retval = DestroyMenu(hPopupMenu)
        myObj.BackColor = &H8000000F  'gray
    
    
    '///////////////
    'Return KEY
    
    Dim crr As Integer
    Dim nothingA As Boolean
    
    Dim mmu_xtopic As String
    Dim mmu_xtitle As String
    Dim mmu_xRun As String
    
    
    
        For crr = LBound(myArr) To UBound(myArr)
        
        
            If myArr((crr), myArrayLastRow_1) = menusel Then
            
            mmu_xtitle = "mmu_title"
            mmu_xtopic = (myArr((crr), myArrayLastRow_1)) & vbCrLf & (myArr((crr), showTitleNum))
            mmu_xRun = (myArr((crr), execTitleNum))
     
            
            MsgBox mmu_xtitle
            MsgBox mmu_xtopic
            MsgBox mmu_xRun
            
                 
            Exit Function
            
            End If
    
        Next crr
    
    
    
    Erase myArr
    
    
    
    End Function '//make_popup_menu

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Menu API

    I'm afraid I can't help with that, as I don't use API's to create menus - because the built-in menu editor is far simpler (and gives you events for each item too, thus more organised). One thing you will need to think about is how you are going to specify sub menus in the parameters.

    Is there a particular reason that you are using API's for this?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    Re: Menu API

    Thanks, I hope :

    I have Array()
    Code:
    myArr(0, 0) = "BOY"
    myArr(0, 1) = "boy 1a"
    myArr(0, 2) = "run_boy_1a"
    myArr(1, 0) = "GIRL"
    myArr(1, 1) = "girl a5"
    myArr(1, 2) = "run_girl_a5"
    myArr(2, 0) = "BOY"
    myArr(2, 1) = "boy 2a"
    myArr(2, 2) = "run_boy_2a"
    Array(0) = main word ; example: (BOY, GIRL, CHILD, DOG, CAT...)
    I need
    Main Menu = Sort Array, Group Main word. main word
    Code:
    BOY (>
    GIRL (>
    CHILD (>
    DOG (>
    CAT (>
    Sub Menu = show all, base main word. sub name
    Code:
    BOY (> boy 1a
           boy 2a
    GIRL (>
    CHILD (>
    DOG (>
    CAT (>
    Or would you suggest need doing this, what other method ?
    Attached Images Attached Images  
    Last edited by rpool; Sep 13th, 2009 at 05:48 PM.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    Re: Menu API

    Any idea ?!
    I can do {blue} ref:
    http://www.xs4all.nl/~rjg70/vbapi/re...popupmenu.html

    but [red, green,] how to do it ?

    Please!

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Menu API

    Are the 'parent' items (Boy/Girl/Dog/Cat) known in advance?

    If so there is no need for the complexity of the API's - you can just use normal menus with a single child item for each, with Index set so it is an array that can be modified as needed.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    Re: Menu API

    Are the 'parent' items (Boy/Girl/Dog/Cat) known in advance?

    Yes: Main Classification is found. From Read Array(), sort Array to get it.


    And that

    {pic1} is build-in mmu create
    {pic2} BLUE Square , is API to create,

    pic2 can use build-in mmu to create it?
    Attached Images Attached Images   
    Last edited by rpool; Sep 16th, 2009 at 06:48 AM.

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Menu API

    If you want help, answer the questions you are asked... we don't ask them for the fun of it, we ask them because you have not given enough info yet

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    Re: Menu API

    Update #8. Please!

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Menu API

    Quote Originally Posted by rpool View Post
    Are the 'parent' items (Boy/Girl/Dog/Cat) known in advance?

    Yes: Main Classification is found. From Read Array(), sort Array to get it.
    If it is coming from an array, it is not known in advance - unless that array is hard-coded.

    Asking my question in another way: could you create the Boy/Girl/Dog/Cat menus in the menu editor?


    If so, do that - and create just one sub-item for each, with Index set to 0. You can then load more as needed, eg:
    Code:
    Load BoySubItem(1)
    BoySubItem(1).Caption = "Boy 1a"

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    Re: Menu API

    Asking my question in another way: could you create the Boy/Girl/Dog/Cat menus in the menu editor?
    Ans: NO


    You can see "Cmd1" Pink Color, this Command_1 is
    Code:
    Read .Database
    return .Database Keyword to Array()

    or i say my background:
    I have Access .MDB file {Database}
    I can doing something I need ,SQL langauge, is fine no problem.

    Code:
    .Acess database
    SuperMarket,
    Fruit,
    ...Brand name 1 to 10+
    Drink,
    ...Brand name 1 to 10+
    Rice,
    ...Brand name 1 to 10+
    Oil , maybe +50 items
    
    
    
    
    Now, I need changed to Menu Style
    that {Main Classification} in .MDB , 
        I can read that Key to Array{} MAIN, But I no sure how many total item list!
    that {Sub Class} in .MDB. When
        When "Main" Class found, get SubItem List,
    
    When SubItem _List _Click, 
        doing something...

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Menu API

    In that case if you want to use menus you will need to use API's... and as I said earlier, I can't help with that.


    A much simpler alternative would be to use controls (perhaps listboxes) for it, filling the first based on the data, then the second based on the users selection.

    If you don't have enough space on your form, you could use a separate form for those controls.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    Re: Menu API

    Thanks.

    Becuase I have no enought Main Item List, VB base mmu-Editor is can't help me!

    Other way , ListBox Method I was used. But no family. because can't automatice fix height & weight

    Anyway: doing this dimensional style. no confirm items, no API no talk ? no other method ?

    And you can look "Windows Start: When Start [Main Items], ->Programs -> [Sub Items]
    this styles used which method ?

  15. #15
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Menu API

    Quote Originally Posted by rpool View Post
    Other way , ListBox Method I was used. But no family. because can't automatice fix height & weight
    You can set the height + width automatically if you want (based on the TextHeight and TextWidth functions), and can have scrollbars if needed.
    Anyway: doing this dimensional style. no confirm items, no API no talk ? no other method ?
    Erm... I don't know what you mean.

    And you can look "Windows Start: When Start [Main Items], ->Programs -> [Sub Items]
    this styles used which method ?
    I don't know... it could be a menu (with various API's), or it could be multiple forms, or something else.

  16. #16
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Menu API

    Here is one option wrapped up in a handy class from DeveloperFusion

    The class is located on this page. Name the class mcPopupMenu
    An example of usage is on this page
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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