I want to disable the menu that pops up when i do a rightclick on a textbox ... it's the menu with ..cut copy paste stuff
Printable View
I want to disable the menu that pops up when i do a rightclick on a textbox ... it's the menu with ..cut copy paste stuff
Add to a Module
VB Code:
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) 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 Const GWL_WNDPROC = (-4) Const WM_RBUTTONDOWN = &H204 Global WndProcOld As Long Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If wMsg = WM_RBUTTONDOWN Then Exit Function WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&) End Function Sub SubClassWnd(hwnd As Long) WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc) End Sub Sub UnSubclassWnd(hwnd As Long) SetWindowLong hwnd, GWL_WNDPROC, WndProcOld& WndProcOld& = 0 End Sub
Add to a Form with a TextBox (called Text1)
VB Code:
Private Sub Form_Load() SubClassWnd Text1.hwnd End Sub Private Sub Form_Unload(Cancel As Integer) UnSubclassWnd Text1.hwnd End Sub
Read this tip