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.