HOW TO: Get the caret position in the Rich Text control.

Hi, I want to get the caret position in Rich Edit control. Is there any method in C# which i can use? I tried to use the GetCaretPos API but unbale to use it. [System.Runtime.InteropServices.DllImport("user32.dll")] static extern bool GetCaretPos(Intptr point); Point curPos; GetCaretPos( curPos ); This gives me compilation error as type mismach. How sould i use this API. Thanks, AN

1 Reply

AD Administrator Syncfusion Team June 21, 2002 06:25 PM UTC

Hi, First declare this struct: public struct POINT { public int X; public int Y; public POINT(int x, int y) { this.X = x; this.Y = y; } } and then try chaning the declaration as: static extern bool GetCaretPos(ref POINT point); and then use the method as: POINT pt = new POINT(0, 0); GetCaretPos(ref pt); I think this should work. Regards, -Praveen Ramesh Syncfusion, Inc. > Hi, > > I want to get the caret position in Rich Edit control. Is there any method in C# which i can use? > I tried to use the GetCaretPos API but unbale to use it. > > [System.Runtime.InteropServices.DllImport("user32.dll")] > static extern bool GetCaretPos(Intptr point); > > Point curPos; > GetCaretPos( curPos ); > This gives me compilation error as type mismach. > > How sould i use this API. > > Thanks, > AN

Loader.
Up arrow icon