Link to home
Start Free TrialLog in
Avatar of puruknoy
puruknoyFlag for United States of America

asked on

Disable Right Click shortcutkey on keyboard.

Is there a way to disable the rightclick shortcut key (found on the right side on my keyboard beside the right-CTRL key)? Menu always pops-up when Im on my textBox and MaskeditTextbox and I want to remove it.
ASKER CERTIFIED SOLUTION
Avatar of caraf_g
caraf_g

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of caraf_g
caraf_g

Hello puruknoy,

Seeing that you're quite new to the site and you've already awarded a "C", I would appreciate it if you could read the following URL: http://oldlook.experts-exchange.com/bin/Q.10220959 

This is not a reflection on you and does not oblige you to any course of action. Just want to raise awareness.
Did you want to replace it with one of your own or just get rid of the right click for a textbox..mskedit completely.
You can hook the popup and add your own menu if you wish.

'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 menu Your Code goes here
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

Juilette - puruknoy is not talking about the right mouse button but about the popup menu button that you'll find on the newfangled Windows keyboards.
Oooops...No biggie..been wrong on more than one occassion in my life.
Thanks,
Wayne

Ps...guess I need some new equipment.