Private Sub Form_Load()
Dim txt As String
GetMenuInfo GetMenu(hwnd), 0, txt
Text1.Text = txt
End Sub
Private Sub GetMenuInfo(hMenu As Long, spaces As Integer, _
txt As String)
Dim num As Integer
Dim i As Integer
Dim length As Long
Dim sub_hmenu As Long
Dim sub_name As String
num = GetMenuItemCount(hMenu)
For i = 0 To num - 1
' Save this menu's info.
sub_hmenu = GetSubMenu(hMenu, i)
sub_name = Space$(256)
length = GetMenuString(hMenu, i, sub_name, _
Len(sub_name), MF_BYPOSITION)
sub_name = Left$(sub_name, length)
txt = txt & Space$(spaces) & sub_name & vbCrLf
' Get its child menu's names.
GetMenuInfo sub_hmenu, spaces + 4, txt
Next i
End Sub
|