WPCubed Product Support

Problem with TWPCustomRtfEdit.SetPosition

Hi Julian,

i run into some trouble with TWPRichEdit.SetPosition and GetPosition. If i try to restore a previous saved position SetPosition sets the cursor to the wrong position. It this a bug or do i something wrong here?

The behaviour ist reproducable by the following code:
(WP is a TWPRichEdit)
...
ShowMessage(IntToStr(WP.CPPosition));
WP.GetPosition(pos, lin, par, pos_in_par);
WP.CPPosition := 0;
WP.SetPosition(pos, lin, par, pos_in_par);
ShowMessage(IntToStr(WP.CPPosition));
...

If this is a bug the solution seems very easy . I commented out the following line in WPCTRMemo.pas ~ line 16372 and it works for me.

if //-> this is maby wrong: (topos <> 0) or
((tolin = 0) and (topar = 0) and (topos_in_par = 0))

Greetings

Andy

#1 ♥ 0
4.1k Views 2 users read 1 min
support

Hi,

GetPosition is outdated. Please simply use CPPosition to save and restore a position. "lin" is kind of meaning less in WPTools 5 and later, a V4 relict.

During editing better use WP.TextCusror.DropMarker / CollectMarker to save a position. This markers are internally handled and also manage text insertion before the marker without change of position.

Julian

#2 ♥ 0
This category is archived. No new posts are possible.