Results 1 to 3 of 3

Thread: disabling edit menu on right click

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Location
    telaviv
    Posts
    6

    Question 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?!!!!!!!!!

  2. #2
    sarun
    Guest
    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

  3. #3
    vking
    Guest
    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
  •  



Click Here to Expand Forum to Full Width