I'm trying to implement the GetPositionFromCharIndex for a TextBox. As
all the RichTextBox uses is the windows api EM_POSFROMCHAR SendMessage
call, it looks like quite an easy thing to do, however my call never
populates my Point object. Here's the code:
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int wMsg, ref POINTL
p, int lParam);
private const int EM_POSFROMCHAR = 0xD6;
public struct POINTL
{
public int X,Y;
}
public Point GetPositionFromCharIndex(int index)
{
POINTL point = new POINTL();
int n = SendMessage(this.Handle,EM_POSFROMCHAR,ref point,index );
System.Diagnostics.Debug.WriteLine(string.Format(" index:{0}
point.X:{1}",index,point.X));
return new Point(point.X,point.Y);
}
I've seen a post where Nicholas Paldino suggests using a standard Point
object (http://www.dotnet247.com/247referenc...6/182264.aspx),
which I've tried with no luck.
Can anyone point me in the right direction?