Results 1 to 20 of 20

Thread: want to select a word from line using right click

Hybrid View

  1. #1
    Lively Member
    Join Date
    Feb 2001
    Posts
    71

    Re: want to select a word from line using right click

    VB Code:
    1. If Button = 2 Then
    2.  
    3.    'This code will be executed when the user clicks on the right mouse button.
    4.  
    5. End if

    This should work, I hope.

  2. #2

    Thread Starter
    Member
    Join Date
    Dec 2005
    Location
    Rawalpindi , Pakistan
    Posts
    37

    Re: want to select a word from line using right click

    If Button = 2 Then

    n = InStrRev(txtSpellCheck.text, " ", txtSpellCheck.SelStart)

    End if


    when this code 'll be Exicuted then this statement "txtSpellCheck.SelStart"
    'll return 0 because it will simply ignore the right click of mouse . the property only work with left click button

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: want to select a word from line using right click

    I've actually thought about this problem before so thanks for bringing it up so that I could think about it again. Here is some code that will move the cursor position to the spot where you right click
    VB Code:
    1. Option Explicit
    2. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    3. Private Const WM_USER = &H400
    4. Private Const EM_CHARFROMPOS = WM_USER + 39
    5. Private Type POINTL
    6.         x As Long
    7.         y As Long
    8. End Type
    9.  
    10. Private Sub RTB_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    11.     Dim mypoint As POINTL
    12.     Dim Index As Long
    13.     If Button = vbRightButton Then
    14.         mypoint.x = ScaleX(x, vbTwips, vbPixels)
    15.         mypoint.y = ScaleY(y, vbTwips, vbPixels)
    16.         Index = SendMessage(RTB.hwnd, EM_CHARFROMPOS, 0, mypoint)
    17.         RTB.SelStart = Index
    18.     End If
    19. End Sub
    Now it is just like the left mouse button

  4. #4
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Thumbs up Re: want to select a word from line using right click

    Thanks moeur.

    It work.

    Thanks again
    software engineer

  5. #5
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: want to select a word from line using right click

    sorry moeur, but it's not working for me!
    Show Appreciation. Rate Posts.

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