Results 1 to 4 of 4

Thread: Hiding Menu - Help Please!!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    Hi, I need to hide a menu in another program. I don't want to kill the menu because I need to invoke it for the user, but I do want to hide it.

    Thanks so much for any help,
    Wade

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    Anyone out there? Aaron? Serge?


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post Someone must know!

    Am I really trying to do something that difficult? Or did you guys just forget about me?


  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    There's no HideMenu API or anything like that, but you can use RemoveItem API to remove it and then use InsertMenu API to put it back in.
    In this example, I'm removing the first menu (File) from the Notepad with one button. Then with another button, I'm inserting it back again.

    Code:
    Private Declare Function InsertMenu Lib "user32" Alias "InsertMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
    Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    Private Const MF_BYCOMMAND = &H0&
    Private Const MF_BYPOSITION = &H400&
    Private Const MF_POPUP = &H10&
    
    Private m_lSubMenu As Long
    Private m_lMenu As Long
    
    
    Private Sub cmdReInsertmenu_Click()
        Call InsertMenu(m_lMenu, 0, MF_BYPOSITION Or MF_POPUP, m_lSubMenu, "&File" )
    End Sub
    
    Private Sub cmdRemoveMenu_Click()
        Dim lNotepad As Long
        Dim lRet As Long
        
        lNotepad = FindWindowEx(0, 0, "Notepad", vbNullString)
        m_lMenu = GetMenu(lNotepad)
        m_lSubMenu = GetSubMenu(m_lMenu, 0)
        lRet = RemoveMenu(m_lSubMenu, 0, MF_BYPOSITION Or MF_POPUP)
        lRet = RemoveMenu(m_lMenu, 0, MF_BYPOSITION)
    End Sub
    Good luck




    Edited by Serge on 02-23-2000 at 07:13 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