You can also use the SendMessage API.
Code for a module.
Make 2 CommandButton's on your Form and put the following code in it.Code:Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Public Const WM_LBUTTONDBLCLK = &H203 ' Left Button Double Clicked Public Const WM_LBUTTONDOWN = &H201 ' Left Button Down Public Const WM_LBUTTONUP = &H202 ' Left Button Up Public Const WM_RBUTTONDBLCLK = &H206 ' Right Button Double Clicked Public Const WM_RBUTTONDOWN = &H204 ' Right Button Down Public Const WM_RBUTTONUP = &H205 ' Right Button Up
Now, when you press Command1, the program will end, as if you pressed Command2.Code:Private Sub Command1_Click() ' Set a Message to Command2 with the Leftbutton Down retval = SendMessage(Command2.hwnd, WM_LBUTTONDOWN, CLng(0), CLng(0)) End Sub Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) ' You you press Command1, it should trigger this event End End Sub




Reply With Quote