Results 1 to 4 of 4

Thread: Is "Copy" Enabled ?? (Jop this might be one for you)

  1. #1
    Guest
    I need to know if the "Copy" menu is enabled in another program. Any ideas on how to go about this?

    Thanks,
    Jordan

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    I never did that before, but I'm willing to try, I post as soon as I get some ok?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Ok cool, I figured something out

    Code:
    Option Explicit
    Private Declare Function GetMenuItemInfo Lib "user32.dll" Alias "GetMenuItemInfoA" (ByVal _
        hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As _
        MENUITEMINFO) As Long
    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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
     Const MIIM_STATE = &H1
     Const MIIM_SUBMENU = &H4
     Const MIIM_TYPE = &H10
    
    Private 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
    Const MF_ENABLED = &H0&
    Const MFS_ENABLED = MF_ENABLED
    Const MFS_CHECKED = &H8
    Const MFT_SEPARATOR = &H800
    Const MFS_GRAYED = &H3&
    
    Private Sub Form_Load()
    Dim note&, Menu&, sMenu&
    'note = FindWindow("notepad", vbNullString)
    Menu = GetMenu(Me.hWnd)
    sMenu = GetSubMenu(Menu, 0)
    GetInfo sMenu, 2
    
    'I used a menu that look like this:
    'Jop 
    '>>> Hey (checked)
    '>>> ------------- (seperator)
    '>>> seconditem (disabled)
    'just play with the 
    'GetInfo sMenu, 2
    '               ^ pos of menu, play with it and see!
    End Sub
    
    Private Sub GetInfo(Menu As Long, pos as Long)
    Dim info As MENUITEMINFO
    info.cbSize = Len(info)
    info.fMask = MIIM_STATE Or MIIM_TYPE Or MIIM_SUBMENU
        GetMenuItemInfo Menu, pos, 1, info
        If info.fType = MFT_SEPARATOR Then MsgBox "-"
        If info.fState And MFS_GRAYED Then MsgBox "DISABLED!"
    End Sub
    Again, with help from http://www.vbapi.com

    but... in order to know if Cpoy is enabled, I need to know how the menu structure looks, anyway, I hope you can figure it out with this info
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    Guest
    Once again, thank you Jop. That code worked great.

    You the man!

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