Results 1 to 3 of 3

Thread: A Q about Textbox

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Location
    Sweden
    Posts
    15

    A Q about Textbox

    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

  2. #2
    Megatron
    Guest
    Add to a Module
    VB Code:
    1. Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    2. Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
    3. 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
    4. Const GWL_WNDPROC = (-4)
    5. Const WM_RBUTTONDOWN = &H204
    6.  
    7. Global WndProcOld As Long
    8.  
    9. Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    10.     If wMsg = WM_RBUTTONDOWN Then Exit Function
    11.     WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
    12. End Function
    13.  
    14. Sub SubClassWnd(hwnd As Long)
    15.     WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
    16. End Sub
    17.  
    18. Sub UnSubclassWnd(hwnd As Long)
    19.     SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
    20.     WndProcOld& = 0
    21. End Sub

    Add to a Form with a TextBox (called Text1)
    VB Code:
    1. Private Sub Form_Load()
    2.     SubClassWnd Text1.hwnd
    3. End Sub
    4.  
    5. Private Sub Form_Unload(Cancel As Integer)
    6.     UnSubclassWnd Text1.hwnd
    7. End Sub

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Read this tip

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