I need help with positioning selected text in a TWPRichText control. Basically my app needs to select a word in the document and then center the selection vertically in the control.
Thanks for any help!
Jim
I need help with positioning selected text in a TWPRichText control. Basically my app needs to select a word in the document and then center the selection vertically in the control.
Thanks for any help!
Jim
Hi,
Maybe the property TopOffset helps. It can be used to scroll under program control.
Or you modify the text attributes, such as spacing before and after.
This code seems to do what I'm looking for.
// Determine Y coordinate of current cursor position
// (WPRichText1.Height div 2) is the vertical center
// Difference between these is how much to scroll TopOffset
WPRichText1.GetParXYBaselineScreen( WPRichText1.ActiveParagraph, WPRichText1.ActivePosInPar, X, Y);
WPRichText1.TopOffset := WPRichText1.TopOffset + (Y - (WPRichText1.Height div 2));