trichview.com

trichview.support




Problem with "bottomless" TRichViewEdit


Return to index


Author

Message

Andrew Chichlowski

Posted: 06/28/2004 11:54:17


Dear Sergey,


I took an example of implementing "bottomless" TRichViewEdit from the

RichView help file. This example is very simple:


if MyRichView.DocumentHeight>Screen.Height then

  MyRichView.Height := Screen.Height

else

  MyRichView.Height := MyRichView.DocumentHeight;


so I decided to use it as the base for implementing "bottomless" editor in

my application. This is what I did:


void __fastcall TForm1::RichViewEdit1Change(TObject *Sender)

{

  RichViewEdit1->Height = RichViewEdit1->DocumentHeight;

}


After first testing I detected the following problem:


PROBLEM SCENARIO >>>


1. Type in "111"

2. Press VK_RETURN

3. As the result, TRichViewEdit content is scrolled down, so that first line

becomes completely invisible. This is not nice. Since control is

bottomless, it should be sufficient to adjust itself to the height of the

text

and scrolling should be avoided.


PROBLEM SCENARIO <<<


After digging a bit I found that scrolling occurs in the following context:


Rvedit::TCustomRichViewEdit::AfterVScroll

Rvscroll::TRVScroller::SetVPos

Rvscroll::TRVScroller::ScrollTo

Rvrvdata::TRichViewRVData::ScrollTo

Crvfdata::TCustomRVFormattedData::ShowRectangle

Rvervdata::TRVEditRVData::ChangeCaret

UpdateCaretAtTheBeginningOfLine

AddEmptyLine

Rvervdata::TRVEditRVData::OnEnterPress_

Rvedit::TCustomRichViewEdit::OnEnterPress

Rvedit::TCustomRichViewEdit::KeyDown


and OnChange event is fired in the context:


Rvedit::TCustomRichViewEdit::DoChange

Rvedit::TCustomRichViewEdit::Change

Rvedit::TCustomRichViewEdit::OnEnterPress

Rvedit::TCustomRichViewEdit::KeyDown


An interesting code for us is TCustomRichViewEdit.OnEnterPress, there we

clearly see that TRVEditRVData::OnEnterPress_ is called prior to Change,

therefore scrolling occurs before RichViewEdit1Change adjusts "bottomless"

control height.


My request is: is it possible to make sure that "bottomless" TRichViewEdit

is not scrolled on changing text? Maybe, some additional event could give

application writer a chance to adjust control height after VK_ENTER but just

before scrolling?


Best regards, Andrew Chichlowski.





Powered by ABC Amber Outlook Express Converter