amby 0 Light Poster

i want to send the right click sub routine that i've formulated, through send message funtion to windows in vb.net so that it can work same as normal right click does what i am doing is

Public Sub RightClick()
RightDown()
RightUp()
End Sub

Public Sub RightDown()
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
End Sub

Public Sub RightUp()
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
End Sub


Public Sub ClickButton(ByVal ButtonHandle As IntPtr)

'send the right mouse button "down" message to the button...
Call SendMessage(ButtonHandle, MOUSEEVENTF_RIGHTDOWN, 0, IntPtr.Zero)

'send the right mouse button "up" message to the button...
Call SendMessage(ButtonHandle, MOUSEEVENTF_RIGHTUP, 0, IntPtr.Zero)

'send the button state message to the button, telling it to handle its events...
Call SendMessage(ButtonHandle, BM_SETSTATE, 1, IntPtr.Zero)


Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
RightClick()
ClickButton(Windows.Forms.MouseButtons.Right)
'MessageBox.Show("show")
End Sub


please help me where i am going wrong