
01/06/2004, 09:48
|
 | | | Fecha de Ingreso: mayo-2004 Ubicación: Lucentum
Mensajes: 6.192
Antigüedad: 20 años, 9 meses Puntos: 74 | |
Aca tenes un ejemplo hiper simple (a tono con VB) para hacerlo:
Un form con 2 listbox (List1 y List2) y un boton (Command1).
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos 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 Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Const WM_COMMAND = &H111
Private Const MF_BYPOSITION = &H400&
Public Ventana As Long
Public hMenu As Long
Private Sub Command1_Click()
Dim SubMenu As Long
Dim y As Long
Dim Item As Long
For y = 0 To List1.ListCount - 1
If List1.Selected(y) = True Then
SubMenu = GetSubMenu(hMenu, y)
End If
Next
For y = 0 To List2.ListCount - 1
If List2.Selected(y) = True Then
Item = GetMenuItemID(SubMenu, y)
SendMessage Ventana, WM_COMMAND, Item, 0
End If
Next
End Sub
Private Sub Form_Load()
Dim Total As Long
Shell "notepad", 1
Ventana = GetForegroundWindow
hMenu = GetMenu(Ventana)
Total = GetMenuItemCount(hMenu)
Dim X As Long
For X = 0 To Total - 1
Dim buff As String
buff = Space(256)
GetMenuString hMenu, X, buff, Len(buff), MF_BYPOSITION
List1.AddItem buff
Next
End Sub
Private Sub List1_Click()
List2.Clear
Dim SubMenu As Long
Dim y As Long
Dim Total As Long
For y = 0 To List1.ListCount - 1
If List1.Selected(y) = True Then
SubMenu = GetSubMenu(hMenu, y)
End If
Next
Total = GetMenuItemCount(SubMenu)
For y = 0 To Total - 1
Dim buff As String
buff = Space(256)
GetMenuString SubMenu, y, buff, Len(buff), MF_BYPOSITION
List2.AddItem buff
Next
End Sub
__________________ ¡Peron cumple, Evita dignifica! VIVA PERON CARAJO |