Results 1 to 9 of 9

Thread: Text box question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344
    I have a text box on the form, when someone "Right clicks" A paste option comes up if they have something in their clipboard....how can i go about disabling this?
    -RaY
    VB .Net 2010 (Ultimate)

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Any suggestions?

    I was thinking about disabling the right click, instead of worrying about actually clearing out the clipboard....maybe this would be a easier approach.
    -RaY
    VB .Net 2010 (Ultimate)

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'get rid of popup for text box on right click
    '
    '<<<<<<<<<< put this in a bas module  >>>>>>>>>>>>>>>>>>
    '
    
    Option Explicit
    
    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 Declare Function SetWindowLong Lib "user32" _
    Alias "SetWindowLongA" _
    (ByVal hWnd As Long, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As Long) As Long
    
    Public Const GWL_WNDPROC = -4
    Public Const WM_RBUTTONUP = &H205
    Public lpPrevWndProc As Long
    Public lngHWnd As Long
    
    Public Sub Hook(hWnd As Long)
    lngHWnd = hWnd
    lpPrevWndProc = SetWindowLong(lngHWnd, GWL_WNDPROC, _
    AddressOf WindowProc)
    End Sub
    
    Public Sub UnHook()
    Dim lngReturnValue As Long
    lngReturnValue = SetWindowLong(lngHWnd, GWL_WNDPROC, _
    lpPrevWndProc)
    End Sub
    
    Public Function WindowProc(ByVal hw As Long, _
    ByVal uMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) As Long
    
    Select Case uMsg
    Case WM_RBUTTONUP
    'Do nothing
    'Or popup your own menu
    Case Else
    WindowProc = CallWindowProc(lpPrevWndProc, hw, _
    uMsg, wParam, lParam)
    End Select
    End Function
    
    ' <<<<<<<<<<<<<<<<   form code  >>>>>>>>>>>>>>>>>>>>>
    
    'Add the following code to the Form_Load event of the form where the text box is placed:
    
    Call Hook(Text1.hWnd)
    'Where Text1 is the name of the text box you want to Subclass.
    
    'Add the following code to the Form_Unload event:
    
    Call UnHook
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    That may work but

    Im using VB3.0....so i can't using any functions such as user32, kernerl32....anything with 32...... So has to be another way to disable the right mouse click in just that text box.
    -RaY
    VB .Net 2010 (Ultimate)

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Everyone..

    Out of ideas already guys? Don't give up on me yet!
    -RaY
    VB .Net 2010 (Ultimate)

  6. #6
    Guest
    This code will work, except HeSaidJoe's way won't pop up a message, it will just be disabled.

    Code:
    Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
    MsgBox "Right Context Menu Disabled!", 16
    End If
    End Sub

  7. #7
    Guest
    that would work, but just like the javascript code for disabling the rightclick menu... well you can rightclick-escape-let go of right button... really fast, and that menu appears magicly!

    which sucks

  8. #8
    Lively Member
    Join Date
    Mar 2000
    Posts
    87

    Exclamation

    Another thing that a lot of people seem to forget is the button on the keyboard for right click. Which isnt a mousedown, mouseup or click event :-)

  9. #9
    Guest
    What do you want?!? A rocket scientists answer? Or Megatron's answer? ;]

    Code:
    If Button = 2 Or Button = 3 Then
    Msgbox "What do you think your doing!?!", 16
    End If

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