unit MainFrame;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, Buttons, ComCtrls, Library_U, types;
type
{ TForm1 }
TForm1 =
class(TForm)
Button1: TButton;
//button zum probieren
Edit1: TEdit;
//Edit Feld zum sachen testen
Edit2: TEdit;
//Edit Feld zum sachen testen
Image1: TImage;
btnNew: TSpeedButton;
btnOpen: TSpeedButton;
btnSave: TSpeedButton;
btnSaveAs: TSpeedButton;
btnDrucken: TSpeedButton;
btnFormular: TSpeedButton;
Memo1: TMemo;
Aktuelloffen: TMemo;
Memo3: TMemo;
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
btnExit: TSpeedButton;
StatusBar: TStatusBar;
TabCon: TTabControl;
TBar: TToolBar;
procedure btnExitClick(Sender: TObject);
procedure btnFormularClick(Sender: TObject);
procedure btnNewClick(Sender: TObject);
procedure btnOpenClick(Sender: TObject);
procedure btnSaveAsClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormChangeBounds(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
MousePos: TPoint;
var Handled: Boolean);
procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
MousePos: TPoint;
var Handled: Boolean);
procedure Memo1Change(Sender: TObject);
procedure TabConChange(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
//INTEGER
btnbreit : integer;
btnhoch : integer;
tabindex01 : integer;
//BOOLEAN
change : boolean;
// change gibt an ob der Text nach dem Speichern noch bearbeitet wurde
save01 : boolean;
//STRING
savepath :
string;
// savepath ist eine zwischen Variable und den save Pfad abzuspeichern
hist :
string;
// hist ist die variable die gebraucht wird um eine "History" also die letzte offene Datei zu begin anzuzeigen :D
implementation
uses
FormularFrame;
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
btnbreit:=70;
btnhoch:=62;
change:=true;
save01:=true;
// Memo3
if FileExists('
history')=true
then
begin
Memo3.Lines.Delete(0);
Memo3.Lines.LoadFromFile('
history');
hist:=Memo3.Lines[0] + '
.txt';
Edit1.Text:=hist;
// Controlle
end;
// Memo1
if FileExists(hist)=true
then
begin
Memo1.Lines.LoadFromFile(hist);
end;
Memo1.Focused;
// TabCon
TabCon.SetBounds(0,0,Form1.Width,42+TBar.Height);
// btnNew
btnNew.SetBounds(0,0,btnbreit,btnhoch);
btnNew.Font.Size:=09;
btnNew.Font.
Name:='
Calibri';
// btnOpen
btnOpen.SetBounds(btnNew.BoundsRect.Right+5,0,btnbreit,btnhoch);
btnOpen.Font.Size:=09;
btnOpen.Font.
Name:='
Calibri';
// btnSave
btnSave.SetBounds(btnOpen.BoundsRect.Right+5,0,btnbreit,btnhoch);
btnSave.Font.Size:=09;
btnSave.Font.
Name:='
Calibri';
// btnSaveAs
btnSaveAs.SetBounds(btnSave.BoundsRect.Right+5,0,btnbreit,btnhoch);
btnSaveAs.Font.Size:=08;
btnSaveAs.Caption:='
Sichern Unter';
btnSaveAs.Font.
Name:='
Calibri';
// btnDrucken
btnFormat(btnDrucken,btnSaveAs.BoundsRect.Right+5,0,btnbreit,btnhoch,09,'
Calibri',true);
// btnFormular
btnFormat(btnFormular,0,0,btnbreit,btnhoch,09,'
Calibri',false);
// btnExit
btnFormat(btnExit,TBar.Width,0,btnbreit,btnhoch,09,'
Calibri',true);
btnExit.Caption:='
Schließen';
// StatusBar
if FileExists(hist)=true
then
begin
StatusBar.Panels.Items[0].Text:=hist;
end;
end;
procedure TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
MousePos: TPoint;
var Handled: Boolean);
begin
tabindex01:=TabCon.TabIndex;
If (TabCon.TabIndex<2)
then
begin
TabCon.TabIndex:=tabindex01+1;
end;
end;
procedure TForm1.FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
MousePos: TPoint;
var Handled: Boolean);
begin
tabindex01:=TabCon.TabIndex;
If (TabCon.TabIndex>0)
then
begin
TabCon.TabIndex:=tabindex01-1;
end;
end;
procedure TForm1.Memo1Change(Sender: TObject);
begin
change:=true;
button1.Caption:=booltostr(change);
// TEST :D :D :D :D :D
end;
procedure TForm1.FormChangeBounds(Sender: TObject);
begin
TabCon.SetBounds(0,0,Form1.Width,42+TBar.Height);
end;
// SICHERN
//btnSave
procedure TForm1.btnSaveClick(Sender: TObject);
begin
if save01=true
then
begin
Save(btnSave);
end
else
begin
Memo1.Lines.SaveToFile(savepath);
end;
Aktuelloffen.Lines.Delete(0);
Aktuelloffen.Lines.Add('
1');
Aktuelloffen.Lines.Text := SysToUTF8(savepath);
Aktuelloffen.Lines.SaveToFile('
History');
end;
// ÖFFNEN
//btnOpen
procedure TForm1.btnOpenClick(Sender: TObject);
var
open :
string;
begin
If OpenDialog.Execute
then
begin
open:= OpenDialog.FileName;
Memo1.Lines.LoadFromFile(open);
Aktuelloffen.Lines.Delete(0);
Aktuelloffen.Lines.Add('
1');
Aktuelloffen.Lines.Text := SysToUTF8(open);
Aktuelloffen.Lines.SaveToFile('
History');
change:=false;
end;
end;
procedure TForm1.btnExitClick(Sender: TObject);
begin
Close;
end;
procedure TForm1.btnFormularClick(Sender: TObject);
begin
Form2 := TForm2.Create(Self);
Form2.ShowOnTop;
//Form1.Enabled:=false;
end;
procedure TForm1.btnNewClick(Sender: TObject);
begin
Memo1.Lines.Clear;
end;
procedure TForm1.btnSaveAsClick(Sender: TObject);
begin
Save(btnSaveAs);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
textb : boolean;
texts :
string;
long, long01, i : integer;
begin
long:= length(Edit1.Text);
textb:=false;
i:=1;
repeat
begin
texts:=copy(Edit1.Text,long,i);
long:= long-1;
i:=i+1;
if texts[1]='
\'
then
begin
long01:= length(texts);
texts:=copy(texts,2,long01-1);
textb:=true;
end;
end;
until textb=true;
Edit2.Text:=texts;
end;
// REGISTER
procedure TForm1.TabConChange(Sender: TObject);
begin
case TabCon.TabIndex
of
0:
begin
btnNew.Visible:=true;
btnOpen.Visible:=true;
btnSave.Visible:=true;
btnSaveAs.Visible:=true;
btnDrucken.Visible:=true;
btnFormular.Visible:=false;
btnExit.SetBounds(TBar.Width,0,btnbreit,btnhoch);
end;
1:
begin
btnNew.Visible:=false;
btnOpen.Visible:=false;
btnSave.Visible:=false;
btnSaveAs.Visible:=false;
btnDrucken.Visible:=false;
btnFormular.Visible:=true;
btnFormular.SetBounds(0,0,btnbreit,btnhoch);
btnExit.SetBounds(TBar.Width,0,btnbreit,btnhoch);
end;
2:
begin
{ btnNew.
btnOpen
btnSave
btnSaveAs
btnDrucken
btnFormular
btnNewFormular
btnExit }
end;
end;
end;
end.