Page 1 of 1
DocumentHeight
Posted: Wed Feb 04, 2009 8:58 am
by vit
Hi!
I try to set height of RichEditView to DocuemntHeight value in OnResize event:
Code: Select all
procedure TForm1.rveResize(Sender: TObject);
begin
rve.Height := rve.DocumentHeight;
end;
But when user input line and press enter vertical scrollbar make active! And user can scroll it down on one line.
What I need to do to vertical scrollbar be inactive always and height of rve be enough to display text.
Thanks!
Posted: Wed Feb 04, 2009 9:29 am
by vit
It seems that OnResize event fire before than DocumentHeight update..
Posted: Thu Feb 05, 2009 3:52 pm
by Sergey Tkachenko
Height is scrollable area is divisible by rve.VSmallStep property.
By default it is 10.
So, for example, if document height is 23, the height of srollable area is 30. In addition, rve.Height includes border width.
So, assign rve.VSmallStep := 1 before calling rve.Format, and use rve.ClientHeight instead of rve.Height.
Posted: Fri Feb 06, 2009 10:18 am
by vit
Is needed to while user input text, height of rve be enouth to display it without scrollbar.
So, I try this:
Code: Select all
procedure TForm1.rveResize(Sender: TObject);
var
c: Integer;
begin
rve.OnResize := nil;
try
c := Trunc(rve.DocumentHeight / rve.VSmallStep);
if (rve.DocumentHeight mod rve.VSmallStep) > 0 then
c := c + 1;
rve.ClientHeight := rve.VSmallStep * c// Now height of rve is equal to height of scrollable area?
finally
rve.OnResize := rveResize;
end;
end;
I'm use OnResize event because it's fired when user press Enter key or remove line.
But scroll bar is still active. If I call rve.Format than scrollbar will be deactive, but carret will move to beginning of document.
Where I must call Format and assign VSmallStep to 1?
Posted: Fri Feb 06, 2009 4:00 pm
by Sergey Tkachenko
Do not use OnResize.
Call this code in OnChange event and in all places where you call Format method.
Posted: Fri Feb 06, 2009 4:14 pm
by vit
It's work!
Thanks a lot!
Posted: Wed Aug 01, 2012 3:11 pm
by JonRobertson
Code: Select all
c := Trunc(rve.DocumentHeight / rve.VSmallStep);
if (rve.DocumentHeight mod rve.VSmallStep) > 0 then
c := c + 1;
rve.ClientHeight := rve.VSmallStep * c// Now height of rve is equal to height of scrollable area?
Is something like this still necessary? According to the help file, DocumentHeight is already a multiple of VSmallStep.
Thanks
Posted: Wed Aug 01, 2012 5:19 pm
by Sergey Tkachenko
The help file is wrong, I'll correct it.
While the height of a scrollable area is really a multiple of VSmallStep, DocumentHeight is not. This is the exact document height.
Posted: Wed Aug 01, 2012 5:21 pm
by JonRobertson
Sergey Tkachenko wrote:The help file is wrong, I'll correct it.
While the height of a scrollable area is really a multiple of VSmallStep, DocumentHeight is not. This is the exact document height.
Thanks. This explains one of the issues I was seeing.
Still not sure on the other one where DocumentHeight is much greater than I expect it to be (see
http://www.trichview.com/forums/viewtopic.php?t=5539).