Home > Back-end >  Memo automatic scrolling problem. I hope someone to help
Memo automatic scrolling problem. I hope someone to help

Time:10-27

Procedure TForm1. Memo1Change (Sender: TObject);
Var
ContentHeight: Integer;
The begin
Canvas. The Font:=Memo1. The Font;//what it mean. What is the use canvas. Why give it assignment
ContentHeight:=Canvas. TextHeight (' good ');//this is completely don't understand. And what the (' good ') and is a
ContentHeight:=(Memo1. Lines. The Count + 1) * ContentHeight;//what's the meaning of this sentence.
If ContentHeight & lt; Memo1. Height then//here I know below. Determine whether beyond the Height of the memo
The begin
Memo1. ScrollBars:=ssNone;
End
The else
The begin
Memo1. ScrollBars:=ssVertical;
end;
end;
End.

Good people to do it. Give me a detailed answer

CodePudding user response:

Procedure TForm1. Memo1Change (Sender: TObject);
Var
ContentHeight: Integer;
The begin
Canvas. The Font:=Memo1. The Font;//canvas, canvas is memo1 controls memo1 show is painted on it,
ContentHeight:=Canvas. TextHeight (' good ');//it is the height of the one line alone, "good" word doesn't make sense, just use one word to get the current font, the height of a line of text, you can be replaced by other words,
ContentHeight:=(Memo1. Lines. The Count + 1) * ContentHeight;//this sentence got memo1 all rows in text height
If ContentHeight & lt; Memo1. Height then//here I know below. Determine whether beyond the Height of the memo
The begin
Memo1. ScrollBars:=ssNone;
End
The else
The begin
Memo1. ScrollBars:=ssVertical;
end;
end;
end.

CodePudding user response:

reference 1st floor CDCHQ response:
procedure TForm1. Memo1Change (Sender: TObject);
Var
ContentHeight: Integer;
The begin
Canvas. The Font:=Memo1. The Font;//canvas, canvas is memo1 controls memo1 show is painted on it,
ContentHeight:=Can...

ContentHeight:=(Memo1. Lines. The Count + 1) * ContentHeight;
It still don't understand. Why Memo1. Lines. Count + 1 to 1. Also left ContentHeight

CodePudding user response:

ContentHeight:=(Memo1. Lines. The Count + 1) * ContentHeight;
In front of the multiplication are not performed, ContentHeight is the height of each row
Memo1, have memo1. Lines. The Count so many Lines, so the total height should be (memo1. Lines. The Count + 1) * ContentHeight;

+ 1 should be to make memo1 ahead of a line has a scroll bar, it doesn't matter that you remove the + 1, show a little different,

CodePudding user response:

Scroll bars appear not? Why do you judge?

CodePudding user response:

MEM0 scroll bars have four kinds of state, said only pick up two,
SsNone: no scroll bar, do not appear, even beyond the scope of (interface does not display the scroll bar)
SsVertical: when beyond Memo height when the scroll bar, (interface part always display the scroll bar).
So I mean the combination of the two, can show beyond, but no more than to the scroll bar can not be displayed at the part! Default attributes but Memo always show or don't show, it's a bit stiff!

  • Related