|
-
Sep 6th, 2000, 09:45 PM
#1
I am making a frontend application for an older windows application. Is is possible to get the handles of the menus somehow with the Windows API so that I can control some of the menu actions?
So if I clicked on a command button in my frontend, then it would click the "Preferences..." selection in the other windows application.
Please let me know if this is possible, and if it is, then how would I do this...
Thank you,
Simon Bingier
-
Sep 6th, 2000, 09:55 PM
#2
To get the menu items:
Code:
'Code by Aaron Young
Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Public 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 GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetMenuString Lib "user32" Alias "GetMenuStringA" (ByVal hMenu As Long, ByVal wIDItem As Long, ByVal lpString As String, ByVal nMaxCount As Long, ByVal wFlag As Long) As Long
Private Const MF_BYPOSITION = &H400&
Public Sub ListMenuStructure(ByVal hWnd As Long, ByRef oList As ListBox)
Dim lMenu As Long
lMenu = GetMenu(hWnd)
oList.Clear
If lMenu Then RecurseMenu lMenu, oList, 1
End Sub
Private Sub RecurseMenu(ByVal lMenu As Long, ByRef oList As ListBox, ByVal iLevel As Long)
Dim lItems As Long
Dim lItem As Long
Dim sCaption As String
lItems = GetMenuItemCount(lMenu)
If lItems Then
For lItem = 0 To lItems - 1
sCaption = Space(255)
sCaption = Left(sCaption, GetMenuString(lMenu, lItem, ByVal sCaption, 255, MF_BYPOSITION))
oList.AddItem String((iLevel - 1) * 2, "-") & sCaption
If GetSubMenu(lMenu, lItem) Then
RecurseMenu GetSubMenu(lMenu, lItem), oList, iLevel + 1
End If
Next
End If
End Sub
Private Sub Command1_Click()
ListMenuStructure FindWindowEx(0, 0, "NotePad", vbNullString), List1
End Sub
-
Sep 6th, 2000, 10:03 PM
#3
Thx
It worked on getting the names of all of the menus/submenus but how would I use this to actually click onto that menu? This the last piece of the puzzle :\
-Simon Bingier
-
Sep 7th, 2000, 03:42 PM
#4
-
Sep 7th, 2000, 09:28 PM
#5
Junior Member
RunMenu API
I'm @ work or I'd look through all my code and find the exact example but you can use RunMenu or something simular if I remember right. Try searching for AOL VB or AOL *.bas thats where ilearned it originally
Code:
If at work Then GoTo UseDifName
-
Sep 7th, 2000, 09:49 PM
#6
This thread now moved to the API section:
http://forums.vb-world.net/showthrea...threadid=29986
-Simon Bingier
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
|