Board index » delphi » RichEdit scrolling and height limit

RichEdit scrolling and height limit

Is there anything inherent in RichEdit that would cap its height at
32767?

I have been manipulating Top to achieve scrolling behavior in a RE
control, because I wanted to display objects in a side panel which move
along with the text in the control. This fails miserably for larger text
files, because of the above cap on RE height.

As an alternative I experimented with sending scroll messages to the
control, but that makes it very messy to calculate character position on
the screen using the POSFROMCHAR message and its siblings (basically the
whole frame of reference gets scrolled, and I do not know of a way to
tell of where the current frame of reference is anchored, and whether
someone else sent prior scroll messages to the control). Any ideas?

Thanks,
Paul

 

Re:RichEdit scrolling and height limit


On Tue, 03 Dec 2002 20:18:48 GMT, "Pawel Slusarz"

Quote
<REMOVEwiedz...@yahoo.comME> wrote:
>Is there anything inherent in RichEdit that would cap its height at
>32767?

>I have been manipulating Top to achieve scrolling behavior in a RE
>control, because I wanted to display objects in a side panel which move
>along with the text in the control. This fails miserably for larger text
>files, because of the above cap on RE height.

>As an alternative I experimented with sending scroll messages to the
>control, but that makes it very messy to calculate character position on
>the screen using the POSFROMCHAR message and its siblings (basically the
>whole frame of reference gets scrolled, and I do not know of a way to
>tell of where the current frame of reference is anchored, and whether
>someone else sent prior scroll messages to the control). Any ideas?

I'm not totally sure I understand what you want (faking scrolling by
changing the Top property??). You've got objects in a side panel which
need to scroll with the text, so I'd probably start by associating
each object with its line of text using the TStrings.AddObject method.

I'd probably also create a descendant of TRichEdit, and handle the
WM_COMMAND message in such a way as to give me an "OnScroll" event
(you're looking for EN_VSCROLL notifications).

You might find the EM_GETFIRSTVISIBLELINE message useful, as it'll
tell you the index of the first visible line, whatever the scroll
position. Your TRichEdit descendant could also implement a "TopLine"
property quite easily with this.

Now, your code can react whenever the text or scroll position changes,
and line up the side objects with their correct lines.
--
jc

Re:RichEdit scrolling and height limit


Quote
"Jeremy Collins" <jd.coll...@ntlworld.com> wrote in message

news:86jruu08bi53773bf041ms336hhhe83l6s@4ax.com...

Thanks for your comments Jeremy. Some of my thoughts below...

Quote
> I'm not totally sure I understand what you want (faking scrolling by
> changing the Top property??).

MyRichEdit.Top := -10; //will make it appear as if RE was "scrolled" 10
pixels down

Quote
> You've got objects in a side panel which
> need to scroll with the text, so I'd probably start by associating
> each object with its line of text using the TStrings.AddObject method.

Yup, done it that way.

Quote
> I'd probably also create a descendant of TRichEdit, and handle the
> WM_COMMAND message in such a way as to give me an "OnScroll" event
> (you're looking for EN_VSCROLL notifications).

Is that the only way that scroll messages will come through? What about
methods like PostMessage, SendMessage and Perform? There also seem to be
different scroll messages that the control responds to, like scroll
caret, linescroll, etc. Sorry, I'm a little ignorant about how the
Windows messaging works deep down, and reading MS Help didn't help so
far.

Quote
> You might find the EM_GETFIRSTVISIBLELINE message useful, as it'll
> tell you the index of the first visible line, whatever the scroll
> position. Your TRichEdit descendant could also implement a "TopLine"
> property quite easily with this.

Ok, seems like this would work (provided I can catch every scroll
message). First visible line should have Y screen position 0 (or
thereabouts). Then I could calculate Y screen position of every
following line of text, until I reached the value of the control's
height.

Thanks,
Paul

Re:RichEdit scrolling and height limit


On Thu, 05 Dec 2002 17:01:56 GMT, "Pawel Slusarz"

Quote
<REMOVEwiedz...@yahoo.comME> wrote:
>Is that the only way that scroll messages will come through? What about
>methods like PostMessage, SendMessage and Perform? There also seem to be
>different scroll messages that the control responds to, like scroll
>caret, linescroll, etc. Sorry, I'm a little ignorant about how the
>Windows messaging works deep down, and reading MS Help didn't help so
>far.

Yep. SendMessage is used to notify a control that you want something
to happen - change the border style for example. You need the
opposite, to be notified when a user action has occurred in the
control.

(For example you would *send* the EM_SCROLLCARET message to the
richedit if you wanted the caret to become visible).

--
jc

(apologies ifyou get two versions of this reply - something odd
happened in my newsreader).

Other Threads