unit Scrolling_Unit;
interface
uses
StdCtrls, Messages, ComCtrls;
procedure ScrollToFirstLine(AMemo: TMemo);
overload;
procedure ScrollToFirstLine(ARichEdit: TRichEdit);
overload;
procedure ScrollToLastLine(AMemo: TMemo);
overload;
procedure ScrollToLastLine(ARichEdit: TRichEdit);
overload;
implementation
// -----------------------------------------------------------------------------
procedure Scroll(AObject: TCustomMemo; ToFirstLine: Boolean);
var
CurrentLine: Integer;
Count: Integer;
begin
with AObject
do
begin
CurrentLine := Perform(EM_LINEFROMCHAR, SelStart, 0);
Inc(CurrentLine);
if ToFirstLine
then
Count := Lines.Count - CurrentLine
else
Count := -Lines.Count - CurrentLine;
Perform(EM_LINESCROLL, 0, Count);
end;
{end with}
end;
{end procedure}
// -----------------------------------------------------------------------------
procedure ScrollToFirstLine(AMemo: TMemo);
begin
Scroll(AMemo, True);
end;
{end procedure}
// -----------------------------------------------------------------------------
procedure ScrollToFirstLine(ARichEdit: TRichEdit);
begin
Scroll(ARichEdit, False);
end;
{end procedure}
// -----------------------------------------------------------------------------
procedure ScrollToLastLine(AMemo: TMemo);
begin
Scroll(AMemo, False);
end;
{end procedure}
// -----------------------------------------------------------------------------
procedure ScrollToLastLine(ARichEdit: TRichEdit);
begin
Scroll(ARichEdit, False);
end;
{end procedure}
// -----------------------------------------------------------------------------
end.