Results 1 to 3 of 3

Thread: select first item in a popup menu

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    34

    select first item in a popup menu

    Hello all,

    I am displaying a popup menu using the TrackPopupMenu API function which works fine, except I want the first item in the menu to be the active item. In a standard application (Notepad for example) if you press Alt+F, the File menu pops up and the item 'New' is already the active item. Pressing down on the keyboard from that point moves to the next item ('Open' in this case). However when I display a menu via TrackPopupMenu, no item is selected by default. I can set the flags on the first item in the menu to contain MFS_HILITE which makes it look right, only you have to press the down arrow twice before it moves to the next item. All the MFS_HILITE flag does is make the button appear highlighted, it doesn't make it the active item. I know it can be done, Internet Explorer does it on its' fake toolbar/menubar thingy..then again, Microsoft does not always play fair . Sorry if this was a long post. Any help is most appreciated.

  2. #2
    Lively Member
    Join Date
    Aug 2001
    Location
    Crossroads of America
    Posts
    72
    Try the following API function:

    Declare Function SetMenuDefaultItem Lib "user32" Alias "SetMenuDefaultItem" (ByVal hMenu As Long, ByVal uItem As Long, ByVal fByPos As Long) As Long


    Good luck!

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    34
    Thank you for your reply but that won't work. SetDefaultMenuItem just changes the specified item to the "default" item meaning it appears in bold text. What I am trying to accomplish is to show a popup menu with the first item already selected so that when the user presses down on the keyboard, focus moves to the second item on the menu (as opposed to the first item which is what is happening now)

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