I have a text box on the form, when someone "Right clicks" A paste option comes up if they have something in their clipboard....how can i go about disabling this?
Printable View
I have a text box on the form, when someone "Right clicks" A paste option comes up if they have something in their clipboard....how can i go about disabling this?
I was thinking about disabling the right click, instead of worrying about actually clearing out the clipboard....maybe this would be a easier approach.
Code:'get rid of popup for text box on right click
'
'<<<<<<<<<< put this in a bas module >>>>>>>>>>>>>>>>>>
'
Option Explicit
Public Declare Function CallWindowProc Lib "user32" _
Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, _
ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Public Const GWL_WNDPROC = -4
Public Const WM_RBUTTONUP = &H205
Public lpPrevWndProc As Long
Public lngHWnd As Long
Public Sub Hook(hWnd As Long)
lngHWnd = hWnd
lpPrevWndProc = SetWindowLong(lngHWnd, GWL_WNDPROC, _
AddressOf WindowProc)
End Sub
Public Sub UnHook()
Dim lngReturnValue As Long
lngReturnValue = SetWindowLong(lngHWnd, GWL_WNDPROC, _
lpPrevWndProc)
End Sub
Public Function WindowProc(ByVal hw As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Select Case uMsg
Case WM_RBUTTONUP
'Do nothing
'Or popup your own menu
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hw, _
uMsg, wParam, lParam)
End Select
End Function
' <<<<<<<<<<<<<<<< form code >>>>>>>>>>>>>>>>>>>>>
'Add the following code to the Form_Load event of the form where the text box is placed:
Call Hook(Text1.hWnd)
'Where Text1 is the name of the text box you want to Subclass.
'Add the following code to the Form_Unload event:
Call UnHook
Im using VB3.0....so i can't using any functions such as user32, kernerl32....anything with 32...... So has to be another way to disable the right mouse click in just that text box.
Out of ideas already guys? Don't give up on me yet!
This code will work, except HeSaidJoe's way won't pop up a message, it will just be disabled.
Code:Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
MsgBox "Right Context Menu Disabled!", 16
End If
End Sub
that would work, but just like the javascript code for disabling the rightclick menu... well you can rightclick-escape-let go of right button... really fast, and that menu appears magicly!
which sucks :(
Another thing that a lot of people seem to forget is the button on the keyboard for right click. Which isnt a mousedown, mouseup or click event :-)
What do you want?!? A rocket scientists answer? Or Megatron's answer? ;]
Code:If Button = 2 Or Button = 3 Then
Msgbox "What do you think your doing!?!", 16
End If