|
-
Oct 17th, 2001, 01:38 PM
#1
Thread Starter
New Member
Cannot get EM_CHARFROMPOS to work with TextBox
I'm so tired.
really.
To get the character nearest to the mouse pointer, in my RichTextBox, I send the EM_CHARFROMPOS message.
It works just fine.
But when I try to do the same thing in my TextBox, it doesn't matter how much I yell or cry or change LPARAM's value... it just won't give me anything else then 0 in return.
Help?
Anyone?
---
This life is killing me
---
-
Oct 17th, 2001, 02:36 PM
#2
The LoWord of the return value is the x pos and the HiWord is the y pos.
-
Oct 17th, 2001, 02:53 PM
#3
Add Textbox and a Label:
VB Code:
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 Type POINTL
x As Long
y As Long
End Type
Private Const EM_CHARFROMPOS = &HD7
Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim pt As POINTL
Dim lngRet As Long
pt.x = x / Screen.TwipsPerPixelX
pt.y = y / Screen.TwipsPerPixelY
lngRet = SendMessage(Text1.hwnd, EM_CHARFROMPOS, ByVal 0&, ByVal pt.x)
Label1.Caption = lngRet
End Sub
-
Oct 18th, 2001, 02:00 AM
#4
Thread Starter
New Member
EM_CHARFROMPOS=WM_USER + 39 won't work with TextBox (Resolved)
Thanks!
Apperently the EM_CHARFROMPOS constant I used with my RichTextBox wasn't valid for the TextBox
Works only with RTB:
Private Const WM_USER=&H400
Private Const EM_CHARFROMPOS=WM_USER + 39
Works with both RTB & TextBox
Private Const EM_CHARFROMPOS=&HD7
---
This life is killing me
---
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
|