📄 fmmemo.pas
字号:
unit FmMemo;
{
Exports TMemoForm and a var instance MemoForm.
C.A. van Beest, R.P. Sterkenburg, TNO-PML, Rijswijk, The Netherlands
12 Mar 97: - Added method ClrLine
27 Mar 97: - Corrected method ClrLine
15 May 97: - Added method AddMemo
28 May 97: - Changed method AddMemo
21 Aug 97: - Added method AddStrings
2 Jan 98: - deleted var OutForm; MemoForm as instance of TMemoForm kept
for easier use (add unit to project manager and form is
auto-created by the application)
}
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TMemoForm = class(TForm)
Memo: TMemo;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
NewLine: Boolean;
public
{ Public declarations }
procedure AddLine(Line: String);
procedure AddMemo( Memo: TMemo);
procedure AddStrings(Strings: TStringlist);
procedure Clear;
procedure ClrLine;
procedure Write(Line: String);
procedure Writeln(Line: String);
end; { TMemoForm }
var
MemoForm: TMemoForm;
implementation
{$R *.DFM}
uses
MoreUtil; { Imports FreeObject }
procedure TMemoForm.FormCreate(Sender: TObject);
begin
NewLine := True;
end; { TMemoForm.FormCreate }
procedure TMemoForm.AddLine(Line: String);
{ Adds a line to the content of the memo }
begin
Memo.Lines.Add(Line);
end; { TMemoForm.AddLine }
procedure TMemoForm.AddStrings(Strings: TStringlist);
begin { TMemoForm.AddStrings }
Memo.Lines.AddStrings(Strings);
end; { TMemoForm.AddStrings }
procedure TMemoForm.Clear;
begin
Memo.Lines.Clear;
end; { TMemoForm.Clear }
procedure TMemoForm.ClrLine;
{ Clears the line in the memo where the (imaginative) pointer is }
begin
if not NewLine
then Memo.Lines[Memo.Lines.Count - 1] := '';
end; { TMemoForm.ClrLine }
procedure TMemoForm.AddMemo( Memo: TMemo);
{ Adds a memo to the form, starting and ending with empty line }
var
j: longint;
begin
for j := 0 to Memo.Lines.Count - 1 do begin
Writeln( Memo.lines[j]);
end;
Writeln( '');
end; { TMemoForm.AddMemo }
procedure TMemoForm.Write(Line: String);
{ See also Writeln }
begin { TMemoForm.Write }
Writeln(Line);
NewLine := False;
end; { TMemoForm.Write }
procedure TMemoForm.Writeln(Line: String);
{ Same as AddLine. This function makes transition from BP to Delphi
easier: replace Writeln by MemoForm.Writeln }
var OldLine: String;
begin { TMemoForm.Writeln }
if NewLine
then AddLine(Line)
else begin
OldLine := Memo.Lines[Memo.Lines.Count-1];
OldLine := OldLine + Line;
Memo.Lines[Memo.Lines.Count-1] := OldLine;
end;
NewLine := True;
end; { TMemoForm.Writeln }
procedure TMemoForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -