|
-
Feb 12th, 2012, 12:41 AM
#1
Re: get word(from textbox) on mousedown
 Originally Posted by DrUnicode
There is an API that finds the first character from cursor.
From there you should be able to search forward to get the word.
Code:
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Const EM_CHARFROMPOS As Long = &HD7
Function CharFromPos(ByVal hWnd As Long, ByVal xPixels As Long, ByVal yPixels As Long) As Long
Dim tP As POINTAPI
tP.X = xPixels
tP.Y = yPixels
CharFromPos = SendMessage(hWnd, EM_CHARFROMPOS, 0, tP)
End Property
This work for RichTextBox not TextBox, beside it doesn't help to get the word under the cursor because it just return the cursor position inside the RichTextBox, it is simulate RichTextBox1.SelStart
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|