I want to select a word from a line of RichTextBox using rightclick of mouse............ is there any way to do this..........
I've sleceted a word from the line of Rich TextBox but by using LEFT click of mouse n = InStrRev(txtSpellCheck.text, " ", txtSpellCheck.SelStart)
this code work fine but only with left button click
but I want to do it with righ click
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
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:
Option Explicit
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
Private Const WM_USER = &H400
Private Const EM_CHARFROMPOS = WM_USER + 39
Private Type POINTL
x As Long
y As Long
End Type
Private Sub RTB_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim mypoint As POINTL
Dim Index As Long
If Button = vbRightButton Then
mypoint.x = ScaleX(x, vbTwips, vbPixels)
mypoint.y = ScaleY(y, vbTwips, vbPixels)
Index = SendMessage(RTB.hwnd, EM_CHARFROMPOS, 0, mypoint)
Re: want to select a word from line using right click
HG,
I don't know why it works for us but not for you.
Again I ask what value does Index return?
Are you using it with a RichTextBox or just a TextBox?
Upload your project so I can see it.
Re: want to select a word from line using right click
Originally Posted by moeur
HG,
I don't know why it works for us but not for you.
Again I ask what value does Index return?
Are you using it with a RichTextBox or just a TextBox?
Upload your project so I can see it.
Re: want to select a word from line using right click
OK your project works OK for me.
I guess the next thing to test would be versions of software.
I'm running Windows XP pro
VB 6.0 SP6
So I've got the RichTextBox control from service pack 6
You can download the service packs for free.
Re: want to select a word from line using right click
Originally Posted by moeur
OK your project works OK for me.
I guess the next thing to test would be versions of software.
I'm running Windows XP pro
VB 6.0 SP6
So I've got the RichTextBox control from service pack 6
You can download the service packs for free.
all right Moeur, i downloaded and installed VB SP6 on Win 98. but still nothing. it's still returning "0" Index value??