|
-
May 9th, 2001, 12:00 PM
#1
Thread Starter
New Member
disabling edit menu on right click
hi all you VB gurus
How do I disable the annoynig popup menu every time
I press the right button on the mouse while over
textbox or combobx and maskeditbox?!!!!!!!!!
-
May 9th, 2001, 12:59 PM
#2
from MSDN
'Add the following code to the General Declarations section of Module1:
Option Explicit
Public Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
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 Const GWL_WNDPROC = (-4)
Public Const WM_CONTEXTMENU = &H7B
Global lpPrevWndProc As Long
Global gHW As Long
Public Sub Hook()
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _
AddressOf gWindowProc)
End Sub
Public Sub Unhook()
Dim temp As Long
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub
Public Function gWindowProc(ByVal hWnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_CONTEXTMENU Then
Debug.Print "Intercepted WM_CONTEXTMENU at " & Now
gWindowProc = True
Else ' Send all other messages to the default message handler
gWindowProc = CallWindowProc(lpPrevWndProc, hWnd, Msg, wParam, _
lParam)
End If
End Function
'Add the following code to the General Declarations section of Form1:
Private Sub Form_Load()
gHW = Text1.hwnd
Hook
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unhook
End Sub
-
Oct 29th, 2001, 10:00 AM
#3
sarun,
how can the code work for multiple textbox in one single form?
and how should I modify the code so that it work for textbox in a user control
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|