Insertion Point's location in a RichTextBox
-
How would I capture the X and Y point location of the user's insertion point in a System.Windows.Forms.RichTextBox instance? :confused: Happy Programming and may God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp
-
How would I capture the X and Y point location of the user's insertion point in a System.Windows.Forms.RichTextBox instance? :confused: Happy Programming and may God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp
I've been hesitant to answer this since I don't have all of the specific calls to make...but lets assume this: You have an RTF box and the cursor is positioned somewhere inside a valid location in that control. You have a button which they press and it that button is [Insert Clipboard] for example. First you get the cursor location by getting this.Cursor.Postion and maybe even you can get this.Cursor.Position.X and .Y but it's not important. The part I cannot remember is you make a call (into the control?? or into Application???) which translates the relative location of the cursor on the desktop to the relative position of the cursor within the control. Maybe Nick can add to the reply as to the specific call....but if not, you have a starting point. This signature left intentionally blank
-
I've been hesitant to answer this since I don't have all of the specific calls to make...but lets assume this: You have an RTF box and the cursor is positioned somewhere inside a valid location in that control. You have a button which they press and it that button is [Insert Clipboard] for example. First you get the cursor location by getting this.Cursor.Postion and maybe even you can get this.Cursor.Position.X and .Y but it's not important. The part I cannot remember is you make a call (into the control?? or into Application???) which translates the relative location of the cursor on the desktop to the relative position of the cursor within the control. Maybe Nick can add to the reply as to the specific call....but if not, you have a starting point. This signature left intentionally blank
Thanks for your help. I finally figured out how to do this and it might help others who might need or want to know how to do this. Below is the bit of code I used to get the
Point
location of the insertion point.rchEdit.GetPositionFromCharIndex(rchEdit.SelectionStart)
This did it.GetPositionFromCharIndex(...)
when passed the selection start index, returns aPoint
instance at the insertion point's index (or at the beginning of a selection). Happy Programming and may God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp