DocumentHeight

General TRichView support forum. Please post your questions here
Post Reply
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

DocumentHeight

Post 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!
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

It seems that OnResize event fire before than DocumentHeight update..
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do not use OnResize.
Call this code in OnChange event and in all places where you call Format method.
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

It's work!
Thanks a lot!
JonRobertson
Posts: 164
Joined: Tue Nov 08, 2011 5:11 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
JonRobertson
Posts: 164
Joined: Tue Nov 08, 2011 5:11 pm

Post 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).
Post Reply