Resumen Eliminar el menu contextual

Mensaje enviado por Quintero Rojas Daniel <dquintero@meximed.com>

Subject: Re: [VB] How can I disable the Pop-up menu item "Paste" of a
TextBox?


You have to hook the textbox and 'eat' the right mouse-click. Do NOT use the VB Stop button when you use something like this. Exit with a normal Unload to allow hook to be removed.

John
======================
' in a form with textbox called Text1
Option Explicit
Private Sub Form_Load()
    DefaultWindowProc = SetWindowLong(Text1.hwnd, GWL_WNDPROC, AddressOf
WindowProc)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Call SetWindowLong(Text1.hwnd, GWL_WNDPROC, DefaultWindowProc)
End Sub

'in a module
Option Explicit

Public Const GWL_WNDPROC = (-4)
Public Const WM_RBUTTONUP = &H205
Public DefaultWindowProc As Long

' API function declarations frim USER23.DLL
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) 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, lParam As Any) As Long

' New custom window prodc that will handle the user defined system menu entries IDM_MENU_1/2/3
Public Function WindowProc(ByVal hwnd As Long, ByVal iMsg As Long, ByVal wParam As Long, lParam As Long) As Long

    If iMsg = WM_RBUTTONUP Then
        ' eat it
    Else
        WindowProc = CallWindowProc(DefaultWindowProc, hwnd, iMsg, wParam, lParam)
    End If
End Function



Resumen Resumen

Visual Basic Página de Visual Basic

Página principal Página principal

www.jrubi.com