Click to See Complete Forum and Search --> : how to get range of visible lines in rtb?


mikledet
December 2nd, 1999, 01:03 AM
Hi,
I am writing an app, were the user can insert a string any where in an already text filled rtb.
But, if the the text is longer then can be shown at onece, than after the insretion the current line will jump to the top of the visible part of the rtb (since i am doing this: first_half_text & added_string & second_half_text).
my question is - is there a way to restores the rtb to show the same range of lines as before the adding of the string?

Thanks
Dani

Ravi Kiran
December 3rd, 1999, 04:56 AM
For this you will have to forego the "selected" look of the replaced string.

If API way is ok , then get the caret position before addiging, then add, then set the caret position back to the same point ( at which time your selection/highlite will vanish) and issue a em_setscroll message, to scroll the caret into view. But i dont know how to show exactly the same no. of lines as before!!. There is a message to get the top-visible line, EM_GETFIRSTVISIBLELine, but there is no equivalent, SET !!, so even if you get the position and save it before additing i dont know how it can be set back.

RK

mikledet
December 3rd, 1999, 03:13 PM
Ravi,
Well, for the benefit of others that might read this post, i just wanted to let you know - how your sugestion helped me solve the problem:
I indid used the EM_GETFIRSTVISIBLELINE in order to get the first visble line.
(mind you - i did not change nothing about the method of pasting the added text!)
Then, in order to restore the visible range of the text afetr the adding of the string, i just added three lines:
FirstLineStart = GetCharFromLine(rtfText, FirstLine)
gets the starting char position of the first visible line -
rtftext.selstart = FirstLineStart
this will scorll the text to the same position as before the adding of the staring.
and last - restored the selstart that was before the hole thing.
Thas it.
Thanks Ravi.
All the best
Dani

Ravi Kiran
December 5th, 1999, 12:50 AM
Good try, and nice way to do it. When i answered your question, i didn't think abt it.
One question: Doesn't the (edit) cursor jump around, causing some annoyance? Or does it look smooth?

RK

mikledet
December 6th, 1999, 07:06 AM
Well, the answer is - yes and no.
The cursor will not blink, but since i use mid function to select the parts of text to be joined, a selection accurs. so for an instance, the the hole selected text will be highlighted.
For my surprize, when using .textRTF - it all works much smoother and faster.
But all in all, it is ok, specialy - since the text returs to its original position - so the user doesnt have to search for the changes.
All the best
Dani.