* BluDog said:
A bit premature I feel... it only works on the first line of textbox,
if the mouse is over the second (or subsequent) on a multiline text
box it returns the equivalent character on the first line...
\\\
....
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal handle As IntPtr, _
ByVal msg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer _
) As Integer
Private Const EM_CHARFROMPOS As Integer = &HD7
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TextBox1.Text = New StreamReader("C:\WINDOWS\WIN.INI").ReadToEnd
End Sub
Private Sub TextBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseMove
Dim MyPoint As Point = New Point(e.X, e.Y) 'Me.TextBox1.PointToClient(New Point(e.X, e.Y))
Dim w As WordConverter
w.LoWord = CShort(MyPoint.X)
w.HiWord = CShort(MyPoint.Y)
Dim lResult As Integer = SendMessage(Me.TextBox1.Handle, EM_CHARFROMPOS, 0, w.LongValue)
Me.Text = Mid(Me.TextBox1.Text, New WordConverter(lResult).LoWord, 1)
End Sub
End Class
<StructLayout(LayoutKind.Explicit)> _
Public Structure WordConverter
<FieldOffset(0)> Public LongValue As Integer
<FieldOffset(0)> Public LoWord As Short
<FieldOffset(2)> Public HiWord As Short
Public Sub New(ByVal LoWord As Short, ByVal HiWord As Short)
Me.LoWord = LoWord
Me.HiWord = HiWord
End Sub
Public Sub New(ByVal LongValue As Integer)
Me.LongValue = LongValue
End Sub
End Structure
///