can anybodyhelp me with the right click problem
-
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 farah
-
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 farah
farah mazhar wrote:
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
This doesn't make any sense at all. Are you trying to send a right-click to a control in your app?? Or are you trying to send a right-click to another application's window?? Your other problem is that you copied and pasted this code from another website without understanding what it's doing. I'm willing to be that you have the Declares statements wrong because the code on the other site is written for VB6 and you're using VB.NET. Since there are big differences between the data types with the same names in the two languages, most notably the
Long
type, the code is not going to work in VB.NET without some conversion.A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007