unit WinForm;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data ;
type
TWinForm =
class(System.Windows.Forms.Form)
[...]
strict protected
/// <summary>
/// Ressourcen nach der Verwendung bereinigen
/// </summary>
procedure Dispose(Disposing: Boolean);
override;
private
{ Private-Deklarationen }
public
constructor Create;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]
var pfad: System.
String;
implementation
uses System.IO;
{$AUTOBOX ON}
[...]
procedure TWinForm.Dispose(Disposing: Boolean);
begin
if Disposing
then
begin
if Components <>
nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor TWinForm.Create;
begin
inherited Create;
//
with OpenfileDialog1
do
begin
DefaultExt:= '
txt';
Filter:= '
Textdateien (*.txt)|*.txt|Alle Dateien(*.*)|*.*';
CheckFileExists:=True;
InitialDirectory:= Application.ExecutablePath;
Title:= '
Bitte öffnen Sie eine Textdatei!';
end;
with SaveFileDialog1
do
begin
DefaultExt:= '
txt';
FileName:= '
Beispiel.txt';
AddExtension:= True;
OverwritePrompt:= True;
ValiDateNames:= True;
Filter:= '
Textdateien (*.txt)|*.txt|Alle Dateien(*.*)|*.*';
InitialDirectory:= Application.ExecutablePath;
Title:= '
Bitte speichern Sie die Textdatei!';
end;
// Erforderlich für die Unterstützung des Windows Forms-Designers
//
InitializeComponent;
//
// TODO: Fügen Sie nach dem Aufruf von InitializeComponent Konstruktorcode hinzu.
//
end;
procedure TWinForm.MenuItem4_Click(sender: System.
Object; e: System.EventArgs);
begin
Self.Close;
end;
procedure TWinForm.MenuItem3_Click(sender: System.
Object; e: System.EventArgs);
var writer: StreamWriter;
s: System.
String;
i: Integer;
begin
if (SaveFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK)
then
begin
pfad := SaveFileDialog1.FileName;
writer := System.IO.
File.CreateText(pfad);
for i := 0
to High(TextBox1.Lines)
do begin
s := TextBox1.Lines[i];
writer.WriteLine(s);
end;
writer.Close();
Self.Text := pfad;
end;
end;
procedure TWinForm.MenuItem2_Click(sender: System.
Object; e: System.EventArgs);
var reader: StreamReader;
begin
if (OpenFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK)
then
begin
pfad := OpenFileDialog1.FileName;
TextBox1.Text := '
';
reader := System.IO.&
File.OpenText(pfad);
while (reader.Peek > -1)
do
TextBox1.Text := TextBox1.Text + reader. ReadLine() + Environment.NewLine;
reader.Close;
Self.Text := pfad;
end;
end;
procedure TWinForm.MenuItem1_Click(sender: System.
Object; e: System.EventArgs);
begin
end;
procedure TWinForm.TWinForm_Load(sender: System.
Object; e: System.EventArgs);
begin
end;
end.