Results 1 to 3 of 3

Thread: right mouse click on textbox

  1. #1

    Thread Starter
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872

    right mouse click on textbox

    when I click on a textbox with my right mousebutton I get a little menu(with undo, copy, pasten etc). I do not want to see this menu. I just want that some code is excecuted on right mouse click. is there any way to hide this menu?
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

  2. #2
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    you could try doing a SetFocus but you will probably get the menu flash for a split second if it worked.

    On the code where it says the RightMouseClick, put

    TextBox1.SetFocus and see if it takes he menu away.

    then put ur code for ur right mouse click after it. good luck

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    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
    22.  
    23.  
    24.  
    25. 'Add To a Form With a TextBox (called Text1)
    26.  
    27.  
    28. Private Sub Form_Load()
    29.     SubClassWnd Text1.hwnd
    30. End Sub
    31.  
    32. Private Sub Form_Unload(Cancel As Integer)
    33.     UnSubclassWnd Text1.hwnd
    34. End Sub

    picked this up somewhere... not sure where though...
    -= a peet post =-

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