How can i Disable the Right click in my program?
Printable View
How can i Disable the Right click in my program?
On what specific control?
What you mean?
Right-click will only pop-up a menu in specific controls or if you call it on the form_click event.Quote:
Originally Posted by VBN00b001
If you are trying to disable a right-click on a textbox or richtextbox, we need to know to show you how to disable it.
If i understand you correctly, you want to disable right click - as you said, right? So, standard controls don't "react" on right click if not specified - with code (MouseUp, MouseDown... events). If you have some code for those, simply remove/comment it.
Well I guess Its for a text Box Which displays the output
Here is how to do it for a textbox
vb Code:
Option Explicit Dim bIsRightClk As Boolean Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 2 Then bIsRightClk = True End If End Sub Private Sub Form_Load() bIsRightClk = False End Sub Private Sub Text1_GotFocus() If bIsRightClk = True Then Text1.Enabled = False Me.SetFocus Text1.Enabled = True End If End Sub
Wow thanks a lot, just one more question what does enabled do
And what does the 2 value doCode:Text1.Enabled
Code:If Button = 2 Then
Quote:
Originally Posted by VBN00b001
.Enabled means can you click it or not. It basically "locks" it so you can't do anything with it if set to False.
Button=2 means the 2nd button, or right-mouse button
Thank you
Just a tip... rather use built-in constant/s instead of a number/s:Type vb in your code editor and press CTRL+SPACE and you'll get a complete list of theme ;)Code:If Button = vbRightButton Then