Results 1 to 2 of 2

Thread: How 2 disable menu items on other application?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    NJ
    Posts
    10

    Question

    Greetz.
    I am trying to find a way how to disable some of the menu items on other applications. Is it possible? Is there a way to re-enable them again?

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    Try this, didn't test
    Code:
    Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
    Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
    Public Const MF_DISABLED = &H2&
    Public Const MF_ENABLED = &H0&
    
    Private Sub Form_Load()
        'KPD-Team 1998
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
        Dim hMenu As Long, hSubMenu As Long, lngID As Long
        Dim hWnd As Long 'handle to the window you want to change
        'Get the handle of the form's menu
        hMenu = GetMenu(hWnd)
        'Get the handle of the form's submenu
        hSubMenu = GetSubMenu(hMenu, 0)
    
        'Change first item (index=0)
        'to disable
        lngID = GetMenuItemID(hSubMenu, 0)
        Call ModifyMenu(hMenu, lngID, MF_DISABLED, lngID, CLng(0))
    
        'to enable
        lngID = GetMenuItemID(hSubMenu, 0)
        Call ModifyMenu(hMenu, lngID, MF_ENABLED, lngID, CLng(0))
    End Sub
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

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