|
-
Mar 24th, 2001, 09:20 AM
#1
Thread Starter
Addicted Member
How do i click a menu in another application using API, and how do i disable a sub menu like:
File-
--Open
--Save
how would i go about disabling the open menu? Thanks
-
Mar 24th, 2001, 04:38 PM
#2
Fanatic Member
you will have to send the WM_COMMAND message. don't have the exact code now, have seen it on the forum, but search is disabled 
To disable menuitems
Code:
Private Const MIIM_SUBMENU = &H4
Private Const MIIM_STATE = &H1
Private Const MFS_GRAYED = &H1
Private Const MFS_ENABLED = &H0
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
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpmii As MENUITEMINFO) As Long
Private Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As MENUITEMINFO) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Sub SetEnabled(bEnabled As Boolean, hWnd As Long, index As Integer)
Dim hMenu As Long, hSubMenu As Long, MII As MENUITEMINFO
'get the handle of the current menu
hMenu = GetMenu(hWnd)
'get the handle of the first submenu
hSubMenu = GetSubMenu(hMenu, index)
'initialize the structure
MII.cbSize = Len(MII)
MII.fMask = MIIM_STATE 'state mask
If bEnabled Then
MII.fState = MFS_ENABLED
Else
MII.fState = MFS_GRAYED 'gray menu item
End If
SetMenuItemInfo hSubMenu, 0, True, MII
End Sub
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Oct 18th, 2002, 12:56 PM
#3
Member
Disable the Save sub item
How would you go about disabling the "Save" submenu item?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|